cancel
Showing results for 
Search instead for 
Did you mean: 

Stackoverflow flag on STM32F4

jdcowpland
Associate II
Posted on November 30, 2015 at 16:47

Anyone know if there is somesort of flag on an STM32F4 that can be set if a stack overflow occurs?

3 REPLIES 3
Posted on November 30, 2015 at 17:38

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
manuel239955
Associate II
Posted on December 01, 2015 at 10:11

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.
jdcowpland
Associate II
Posted on December 02, 2015 at 10:01

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?