51
SAM4CP [DATASHEET]
43051E–ATPL–08/14
12.4
Cortex-M4 Models
12.4.1 Programmers Model
This section describes the Cortex-M4 programmers model. In addition to the individual core register descriptions, it con-
tains information about the processor modes and privilege levels for software execution and stacks.
12.4.1.1 Processor Modes and Privilege Levels for Software Execution
The processor
modes
are:
Thread mode
Used to execute application software. The processor enters the Thread mode when it comes out of reset.
Handler mode
Used to handle exceptions. The processor returns to the Thread mode when it has finished exception processing.
The
privilege levels
for software execution are:
Unprivileged
The software:
Has limited access to the MSR and MRS instructions, and cannot use the CPS instruction
Cannot access the System Timer, NVIC, or System Control Block
Might have a restricted access to memory or peripherals
Unprivileged software
executes at the unprivileged level.
Privileged
The software can use all the instructions and has access to all resources.
Privileged software
executes at the
privileged level.
In Thread mode, the Control Register controls whether the software execution is privileged or unprivileged, see
“Control
Register”
. In Handler mode, software execution is always privileged.
Only privileged software can write to the Control Register to change the privilege level for software execution in Thread
mode. Unprivileged software can use the SVC instruction to make a
supervisor call
to transfer control to privileged
software.
12.4.1.2 Stacks
The processor uses a full descending stack. This means the stack pointer holds the address of the last stacked item in
memory When the processor pushes a new item onto the stack, it decrements the stack pointer and then writes the item
to the new memory location. The processor implements two stacks, the
main stack
and the
process stack
, with a pointer
for each held in independent registers, see
“Stack Pointer”
.
In Thread mode, the Control register controls whether the processor uses the main stack or the process stack, see
“Con-
trol Register”
.
In Handler mode, the processor always uses the main stack.
The options for processor operations are:
Note:
1.
See
“Control Register”
.
Table 12-1.
Summary of processor mode, execution privilege level, and stack use options
Processor Mode
Used to Execute
Privilege Level for
Software Execution
Stack Used
Thread
Applications
Privileged or unprivileged
(1)
Main stack or process stack
(1)
Handler
Exception handlers
Always privileged
Main stack