Cortex-M interrupt call stack usage

HugPeter-9392 246 Reputation points
2022-03-28T08:00:46.04+00:00

Hello

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.

Thanks

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

Accepted answer
  1. Scott Azure RTOS 4,051 Reputation points
    2022-03-28T23:56:25.273+00:00

    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.