Become a leader in the IoT community!
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Hi @Middleware & OS , When using FreeRTOS each thread has its own stack space it is dedicated to. So what happens with Interrupt Service Routines that’s ISRs? Do they have a separate stack in memory, or is this behavior configurable?
If it doesn’t have a dedicated stack, how are local variables declared within the ISR handled?
@marveeamasi the behavior is not usually configurable. The stack of the task that triggered the interrupt is always used to store the local variables of the ISR(Interrupt Service Routine). These ISRs might be running multiple tasks at the same time.
And secondly,try to allocate your local variables which you declared within an ISR on the task which triggers the interrupt in your program.
In FreeRTOS, ISRs share the stack of the current running task. They don’t have a dedicated stack by default, but you can configure FreeRTOS to use a separate stack for ISRs by defining configUSE_ISR_STACK in your FreeRTOSConfig.h file. Local variables in ISRs are allocated on the interrupt stack, so keep ISRs short and simple to avoid stack overflow.
I have different understanding, i was in the impression that ISR execution uses the main stack that is used before os initialisation API is called. `configUSE_ISR_STACK` is this new feature in freertos ?
CONTRIBUTE TO THIS THREAD