Stack Overflow - UWCubeSat/DubSat1 GitHub Wiki

Stack overflow

Code composer studio does not report stack overflows automatically. Stack overflows can cause mysterious memory related bugs. To check for stack overflow, start the debugger and click the breakpoint dropdown, then "Break on Stack Overflow" (this may require CCS version 8 or higher). Be sure to remove and re-add this breakpoint after every change to the maximum stack space.

Solution

Raise the maximum stack space or use less stack space.

To find the maximum stack space required by your program, navigate to View -> Stack Usage (warning: this view is slow and buggy -- especially in CCS 7). The maximum inclusive size listed in the view is approximately the maximum stack space used by the program. Set the maximum stack space to 10 bytes greater for safety.

Configure the maximum stack space by right clicking the project and navigating to Properties -> Build -> MSP430 Linker -> Basic Options, "Set C system stack size". If you have a breakpoint on stack overflow, remove and re-add it as this change is not detected automatically.

The stack space configuration can fail after a build if the program is out of RAM. Check View -> Memory Allocation and look under RAM to see how much is potentially available to the stack.