My Lecture9 CortexM3
My Lecture9 CortexM3
Development Environment
November 2011
Agenda
ARM CortexM3 – Programmers view and Development Environment
1
ARM CortexM3 – Programmers view
Introduction to ARM CortexM3
2. Great performance at low cost and many new features available only in high-end
processors
3. Enhanced determinism, guaranteeing that critical tasks and interrupts are serviced as
quickly as possible, but in a ”known” number of cycles.
4. Improve code density, ensuring that code fits even the smallest memory footprints
5. Ease of use, providing debugability and easy programmability for those applications
which are migrating from 8, 16bit to 32bit.
6. Can be used in ”device aggregation”, where multiple traditional 8bit devices can get
replaced by a single 32bit high performance device.
7. Through the compilers, the amount of code reuse across other ARM systems can
take place.
2
ARM CortexM3 – Programmers view
Introduction to ARM CortexM3
1. The use model for ARM and other integrators is :-
3
ARM CortexM3 – Programmers view
Introduction to ARM CortexM3 – ARM and Thumb Instruction Sets
2. During program execution, the processor can be dynamically switched between the
ARM state or Thumb state to use either of the instruction sets
3. The Thumb instruction set provides only a subset of the ARM instructions, but can
provide high code density.
4. M3 processor supports only the Thumb-2 (and traditional Thumb) instruction set. It
uses Thumb-2 instruction set for all operations
4
ARM CortexM3 – Programmers view
5
1. The processor has a Harvard architecture, ie., has a separate instruction bus and data
bus. However, the instruction and data buses share the same memory space (unified
memory system). i.e, Cannot get 8GB space just because there are separate bus
interfaces.
4. Link Register :: R14 → When a subroutine is called, the return address is stored in
the link register.
5. Program Counter :: R15 → The current program address. This register can be written
to control the program flow
6
ARM CortexM3 – Programmers view
Introduction to ARM CortexM3 – Operation Modes
2. Operation Modes :: What kind of operation the M3 is doing. Whether the processor
is running a normal program or running an exception handler like an interrupt handler
or system exception handler.
(a) Thread Mode :: Thread mode is entered on reset, and can be entered as a result
of an exception return. Privileged and User code can run in Thread mode.
(b) Handler Mode :: Handler mode is entered as a result of an exception. All code is
privileged in Handler mode.
7
ARM CortexM3 – Programmers view
Introduction to ARM CortexM3 – BuiltIn Nested Vectored Interrupt Con-
troller
1. The M3 Processor includes an Interrupt Controller called the NVIC (Nested Vectored
Interrupt Controller with following main features :-
(a) Nested Interrupt Support :: All interrupts and most of the system exceptions can
be programmed to different priority levels. When an interrupt occurs, the NVIC
compares the priority of this interrupt to the current running priority level. If the
priority of the new interrupt is higher than the current level, the interrupt handler
of the new interrupt will override the current running task.
(b) Vectored Interrupt Support :: When an interrupt is accepted, the starting address
of the ISR is located from a vector table in memory. There is no need to use
software to determine and branch to the starting address of the ISR. Thus it takes
less time to process the interrupt request.
(c) Dynamic Priority changes Support :: Priority levels of interrupts can be changed
by software during run time. Interrupts that are being serviced are blocked from
further activation until the ISR is completed, so their priority can be changed
without risk of accidental re-entry.
(d) Reduction of Interrupt Latency :: M3 includes automatic saving and restoring
some register contents, reducing delay in switching from one ISR to another and
handling late arrival interrupts.
(e) Interrupt Masking :: Interrupts and system exceptions can be masked based on
their priority level or masked completly using interrupt masking registers BASEPRI,
8
PRIMASK, FAULTMASK. They can be used to ensure that time-critical tasks can
be finished on time without being interrupted.
ARM CortexM3 – Programmers view
Introduction to ARM CortexM3 – Memory Map
1. M3 has a predefined memory map. This allows the built-in peripherals, such as NVIC,
and debug components to be accessed by simple memory access instructions.
4. M3 has an optional Memory Protection Unit (MPU). The MPU is setup by an OS,
allowing data used by privileged code to be protected from User programs. The
MPU can be used to make memory regions ReadOnly to prevent accidental erasing of
data, or to isolate memory regions between different tasks in a multi-tasking system.
Overall, helps in making systems more robost and reliable.
9
ARM CortexM3 – Programmers view
10
ARM CortexM3 – Programmers view
Introduction to ARM CortexM3 – Instruction Set
11
ARM CortexM3 – Programmers view and Develop-
ment Environment
Acknowledgements
12