TI MSP430 Microcontroller Stacks

Troubleshooting Stack Over / Under Flow Crashes.

Stuart says:

The in past, I have created "guard bytes" which are located immediately above and below each stack. The words are initialized with some kind of magic number (i.e. "0xABCD", "0xFEED", "0xDEAD", "0xBEEF"...) If the stack overflows or underflows (or they get trashed some other way), the guard words will be overwritten. You can then carefully craft a check that tests the value of the guard words. If it is a simple matter of a stack over or underflow, you'll know which task is causing the problem. If you really want to instrument the code, you can modify your RTOS scheduler/task switch such that it tests the guard bytes whenever leaving a task. This will hurt your timing a little, but it's only for debugging.