cancel
Showing results for 
Search instead for 
Did you mean: 

Stack Memory start address

VChau
Associate II

HI All,

How to test Stack Over flow in Keil (STM32L0)

Is there any document ? or any process to test Stack over flow

3 REPLIES 3

The top of the stack is computed via a symbol in startup.s and it moves downward.

Typical method to determine usage is to start from bottom checking for normal fill pattern, and/or checking ​SP periodically at function or interrupts entry.

You'd have thought this would be taught in classes..​

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

You'd have thought this would be taught in classes.

Website programming doesn't deal with any kind of memory management other than the state bag passed with the URL. Chances are the instructor lets the PC OS trap the stack overflow.

in a single task design, all that's required is a relatively high priority timer driven interrupt that checks the MSP and PSP to see if it's too close to the lower stack limits (remember, M series has two stack pointers).

For a multi-tasking design, check the system MSP and task PSP for boundary limit when the pre-emptive timer is triggered.

Another solution is to use an MCU (M3, M4 and newer) with a memory management unit. The MMU is programmed with the stack size and will fault if the SP tries to access memory outside the stack region. The CM0 doesn't have an MMU.

S.Ma
Principal

It is a typical need and usually max out the stack area until the heap size fails build.

Some compilers estimate stack depth recursively when function are not. ISR are added to it and it makes a pretty expectable stack size. Use function pointers also defeat it. RTOS simplify multitask at the expense of creating an extra stack per task.... I guess to be able to program a memory segment by user to create exception is worth exploring (pcrop?)