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?
Solution:
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.
Jump to solution
3 Replies
UC GEE
UC GEE7mo 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.
Solution
Joseph Ogbonna
Joseph Ogbonna7mo ago
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_C7mo 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