2015-11-30 07:47 AM
Anyone know if there is somesort of flag on an STM32F4 that can be set if a stack overflow occurs?
2015-11-30 08:38 AM
You could put the stack at the bottom of SRAM or CCMRAM, and have it trap as it drops through the bottom.
Normally, you'd just fill the stack with a known marker, and periodically check that it hasn't gone too deep. Or at the least you can see worst case usage. The compiler may offer an option for ''stack checking'' as it enters the functions.2015-12-01 01:11 AM
Actually,
FreeRTOS does exactly this if wanted. It can check Stack by checking the stack pointer and by patterns in the upper part of each tasks stack. If it detects an overflow, it calls a callback function.2015-12-02 01:01 AM
I like the idea of filling the stack with a value and then checking it periodically to see if that value is still at the end of the stack. Where in my code would I need to put that? When I enter debug mode my stack already contains data, so would I need to put it in the Default_Reset_Handler assembly code in the startup file?