Skip to main content
jdcowpland
Associate III
November 30, 2015
Question

Stackoverflow flag on STM32F4

  • November 30, 2015
  • 3 replies
  • 1044 views
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?

    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    November 30, 2015
    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 VenmoUp vote any posts that you find helpful, it shows what's working..
    manuel239955
    Associate II
    December 1, 2015
    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 III
    December 2, 2015
    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?