how are local variables declared within the ISR handled?

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?
3 Replies
UC GEE
UC GEE2w ago
@Marvee Amasi 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.
Joseph Ogbonna
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.
K_G_C
K_G_C2w ago
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 ?
Want results from more Discord servers?
Add your server
More Posts