Stack Pointer in Cortex Mx processor

reference

Stack pointer in cortex Mx process will point to either SP_process or SP_main.

What are SP_process and SP_main?

  • SP_process = PSP(Process Stack Pointer) = Task's private stack

  • SP_main = MSP(Main Stack Pointer) = Kernel stack

RTOS scheduler decides which task to run every sysTick. A higher-priority task will be scheduled and during the execution of the task, it will use its stack which is called SP_process. r13(SP) will point to SP_process.

When ISR executes, it will use SP_main. r13(SP) will point to SP_main.