Cortex-M interrupt call stack usage

HugPeter-9392 246 Reputation points


I'm curious if and how ThreadX handles interrupt call stacks.

Is each thread required to preserve stack memory for the worst case sum of nested interrupt call stacks?

Or alternatively does ThreadX handle all (nested) interrupts on a single dedicated stack? If so what API needs to be called within the vector table handler function to make ThreadX aware of the executing interrupt?

I'm aware that Cortex-M contain a process stack pointer and a main stack pointer. But I'm not sure how ThreadX makes use of these. For me relevant are Cortex-M0+/Cortex-M4 and Cortex-M7.


Azure RTOS
Azure RTOS
An Azure embedded development suite including a small but powerful operating system for resource-constrained devices.
302 questions
0 comments No comments
{count} votes

Accepted answer
  1. Scott Azure RTOS 4,046 Reputation points

    Hi @HugPeter-9392 , for the Cortex-M, ThreadX utilizes the automatic hardware stacking of the Cortex-M architecture. When a thread is interrupted, its stack is used (the "process stack"). Any nested interrupts use the "main stack" in "handler mode." There is nothing that you need to do to manage these stacks. The main stack address is placed in the first slot of the vector table. This main stack is set up in the linker file, so just make sure you are giving this stack enough memory to handle all your nested interrupts.

    0 comments No comments

0 additional answers

Sort by: Most helpful