Hi everyone. I am using MSP430F5438A on IAR embedded workbench for MSP.
I have two questions:
1. How to change the size of the stack segment?
2. How to detect stack overflow?
Thank you in advance.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi everyone. I am using MSP430F5438A on IAR embedded workbench for MSP.
I have two questions:
1. How to change the size of the stack segment?
2. How to detect stack overflow?
Thank you in advance.
Dennis Eichmann said:Isn't that only the warning threshold?
Well, yes and no.
It is a linker error if there isn't enough RAM left to fufill the stack reservation you make.
Also, if you use an .xcl linker control file in your project, that is the place to make your stack size reservation.
There is no automatic way to catch stack overflow (no MMU), but if you must you can code up a stack check function. You would fill the stack in a custom startup code (prior to cstart) with a known value and then in your main loop you could check the bottom X words of the stack to make sure there is buffer.
Not directly. It depends on the toolchain you use.
For example, in IAR, you would make a project-specific cstartup.s43 and put your changes in that and include it as part of your project.
In that file:
// --------------------
// Initialize SP to point to the top of the stack.
//
MOV #SFE(CSTACK), SP
--> Code here to fill stack with known value
//
// Ensure that main is called.
//
REQUIRE ?cstart_call_main
So, read the manual for your toolchain and poke around to figure out what you need to override. Note that stack filling needs to occur before your C environment is initialized and function calls are made so that you don't trash the stack while it's in use.
**Attention** This is a public forum