cancel
Showing results for 
Search instead for 
Did you mean: 

How to Detect the Stack Overflow in the STM32F207Vgt

NMuth
Associate II

I am using Stm32f207....i am Suspecting there is stack overflow happening in my code.how to Check it actually?

4 REPLIES 4

Although not entirely reliable, the easiest method is to fill the memory with a easily recognizable pattern, run the program and observe in the debugger how far the stack has reached.

A more rigorous method is a static analysis, but that needs to have support from the toolchain, and also it gets complicated as soon as indirect calls (known as function pointers) are called, and/or stack usage changes dynamically e.g when using alloca().

RTOS pose a whole new group of problems in this regard.

JW

NMuth
Associate II

is there any Memory Mapping we can use t check it?

I don't know what do you mean by Memory Mapping.

JW

You can have your own code check how much of the pattern remains in memory.

You could put the stack at the bottom of memory so it hard faults as you drive it through the floor.​

You might be able to use the MPU settings to Mem Fault in a similar manner. Review the chip TRM.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..