I've been reading various sections in the ARM Information Center to try and find my answer, however I came to a point where the documentation confused me so I'm hoping someone here can help.
I understand that there are two stacks in Cortex-M processors:
- MSP (main stack pointer)
- PSP (process stack pointer)
I'm trying to figure out how each one is used by the ARM core.
The documentation in the ARM Information Center when discussing the Cortex-M3 states the following:
The main stack is used at reset, and is always used in Handler mode (when entering an exception handler). The process stack pointer is only available as the current stack pointer when in Thread mode.
Okay, this tells me that the MSP is used at reset. However, the documentation also states the following:
Thread mode
Used to execute application software. The processor enters Thread mode when it comes out of reset.
Handler mode
Used to handle exceptions. The processor returns to Thread mode when it has finished all exception processing.
Okay, so this is what confuses me. If the MSP is used at reset and is always used in Handler mode, and the PSP is used in Thread mode, then how can the MSP be used at reset if the processor is in Thread mode at reset?