EasyManuals Logo

ARM Cortex-M3 User Manual

ARM Cortex-M3
410 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #122 background imageLoading...
Page #122 background image
Exceptions
5-26 Copyright © 2005-2008 ARM Limited. All rights reserved. ARM DDI 0337G
Non-Confidential
Unrestricted Access
Example 5-5 Implement a simple context switcher
; Example Context Switch (Assumes Thread is already on PSP)
MRS r12, PSP ; Recover PSP into R12
STMDB r12!, {r4-r11, LR} ; Push non-stack registers
LDR r0, =OldPSPValue ; Get pointer to old Thread Control Block
STR r12, [r0] ; Store SP into Thread Control Block
LDR r0, =NewPSPValue ; Get pointer to new Thread Control Block
LDR r12, [r0] ; Acquire new Process SP
LDMIA r12!, {r4-r11, LR} ; Restore non-stacked registers
MSR PSP, r12 ; Set PSP to R12
BX lr ; Return back to Thread
Note
In Example 5-4 on page 5-25 and Example 5-5, the only time the decision to move
Thread from MSP to PSP can be made, or the non-stacked registers can be guaranteed
not to have been modified by a stacked Handler, is when there is only one active
ISR/Handler.

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the ARM Cortex-M3 and is the answer not in the manual?

ARM Cortex-M3 Specifications

General IconGeneral
ArchitectureARMv7-M
Instruction SetThumb-2
Pipeline Stages3-stage
InterruptsNested Vectored Interrupt Controller (NVIC)
Interrupt ControllerNested Vectored Interrupt Controller (NVIC)
Memory Protection UnitOptional
Power ConsumptionVaries by implementation
Max Clock SpeedUp to 100 MHz
DebuggingJTAG and Serial Wire Debug (SWD)
Operating Voltage1.8V to 3.6V
Manufacturing ProcessVaries by implementation
Core Type32-bit

Related product manuals