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.

Detect stack overflow

Other Parts Discussed in Thread: TMS570LS3137

Good morning,

The TMS570LS3137 have some hardware detection of stack overflow? Othewise, is there a programmatic way to check an stack overflow?

Thank you & Best Regards

Davide

  • Davide,

    You can accomplish this type of checking by using the MPU and using one of the regions to map the stack space as read/write memory.
    Make sure that there is a gap in the memory map on either side of this space so that an abort is generated if your stack wanders outside the space.
    (by this I mean make sure none of the other memory regions of the MPU map the space above/below the stack).

    Since the stack pointer grows downward (decrementing address) another good idea is to locate the stack at the bottom of SRAM so that an overflow will go into an unmappped area of memory naturally. Of course with the multiple stacks on the device you can only really allocate one stack this way but it is still a good idea - secondary to using the MPU.

    -Anthony