Electronic – Must FreeRTOS task stack size account for interrupt stack size

cortex-m0freertosinterruptsstack

I have FreeRTOS running on a MKE06 Cortex-M0+ (based on SAMD20 demo), GCC toolchain. I am trying to figure out optimal task stack sizes (with the help of avstack.pl).

I want to use only static memory allocation.
In the FAQ I have read this:

The stack requirements of interrupt service routines – which for many RTOS ports is zero as the RTOS will switch to use a dedicated interrupt stack on entry to an interrupt service routine.

I use this port. I don't know much assembly, but I think I do not see anything that would configure stack pointer separately for the interrupts (is such thing even supported by M0+?). I allocated stack for the idle task manually (with vApplicationGetIdleTaskMemory), but I did not find a function to provide stack space for interrupts. Interrupts work fine, I do not use nested interrupts.

My questions:

  1. Should my task stack size be enlarged by at least the biggest possible interrupt stack size?
  2. Can I allocate a separate interrupt stack on Cortex M0+ in plain C (ie. without adding own assembly to each ISR)?

Best Answer

Interrupt service routine will use the stack you are also using for main(). You have a stack defined in your linker script, this is the one used for main and ISR, separate from the stack of the FreeRTOS tasks.