IT lexicon › Hardware › MSP and PSP

MSP and PSP

Hardware På svenska → Updated: 2026-11-04

The two Cortex-M stack pointers: one for interrupts and the kernel, one for ordinary tasks — so no task stack has to budget for the worst-case interrupt depth.

At reset the processor loads the first word of the vector table into MSP, the main stack pointer. A bare-metal program never needs anything else. Interrupt handlers, which run in handler mode, always use MSP; ordinary code in thread mode can switch to PSP, the process stack pointer, by setting a bit in the CONTROL register.

The split pays off under an RTOS. Each task gets its own stack and PSP points at the current one, while the kernel and every interrupt share MSP. Without it, every task stack would need room for the deepest nest of interrupts on top of its own needs — multiply by twenty tasks and that is a lot of RAM. The context switch in PendSV saves registers on the old PSP, swaps the pointer and returns with the magic value 0xFFFFFFFD, meaning "back to thread mode, on PSP".

← Back to the lexicon