High Water mark for ISR Stack


We are working on some instrumentation for FreeRTOS in CCS. I see how to do the high water mark for task stacks, but I don’t see anything for the ISR stack. Is it up to the application to initialize the ISR stack accordingly itself. If so, where do you recommend doing it?

We specifically looking at this for the CortexM devices.


Stack overflow detection is relatively simple for tasks because the scheduler knows where the task’s stack ends, but relatively difficult for ISRs because [in the Cortex-M case] ISRs use the stack that was used by main() before the scheduler was started. In the generalised case, the kernel doesn’t know where the stack used by main() ends because it is allocated by the C run-time, and there is no commonality between different build systems in how that is done.

However, yours is a specific case, not a generalised case, as you also provide the tools. We can therefore work together to provide a method.

Ports, such as the MIPS and RISC-V ports, give users the option to statically allocate the ISR stack, in which case the kernel does know where it is, which then enables the kernel to check for overflows.

Hi Todd - Here’s a port.c with added ISR stack use checking:

Best Regards, Dave

Cool. I’ll give this a try.

Fyi…here’s what the prototype for FreeRTOS I’m working on looks like


A little bit of a tangent…
I see the Task function address is placed on the task stack. I’m able to display it until it potentially gets wiped out as the task stack starts getting used. Is there some other way to get the task’s function address?