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.

Debugging stack issues

Other Parts Discussed in Thread: MSP430F435

I'm trying to troubleshoot some variable corruptions issues on a MSP430F435. I'm thinking the stack is overflowing but I'm not 100% sure. I've read that filling in unused memory with a dummy variable, like 0xAB, and having the controller run and checking back to see how much has been overwritten can help troubleshoot stack issues. Is there a tutorial online somewhere I'm missing that shows how to do this? I'm guessing I have to write a function that goes and does this before the compiler puts the program in?

I should add that, since I'm building on an existing project, I'm stuck using Code Composer V2.

  • You may want to add a pre-init function that only uses registe variables and fills the ram before the C init code initializes stack and global variables.

    How this is done is compiler/linker specific and shoul dbe in the IDE documentation. However, there have been some threads about this recently.

    But you may also just put breakpoints here and there  and check the stack pointer. I don't knmow whether CCS support sthis, but on most MSPs one can set breakpoints that are tiggered when a specific memory location is written to.When the stack grows to thsi point it will trigger the breakpoint. However, this doesn't work if you 'reseve' a large area on teh stack (e.g. a local array) and do not writ eto it. Maybe the trigger point is then inside the array and never written to.

  • Thanks for the reply. I'll try and do more research into the areas you specified.