1 Reply Latest reply on Apr 19, 2018 1:18 AM by JoMe_264151

    how can i detect stack overflow?

      Hi everyone,

      I wish detect the stack overflow in psoc 4 CY8C4245LQI-483.


      I tried this :

      1- initialize a stack pointer to the last row of SRAM (i found  SRAM  address range from 0x20000000 to 0x20000FFF in PSOC4 architecture TRM. The stack is in upper SRAM).

            char* stackPtr = (char*) 0x20000FFF.

      2- give it a value:

           *stackPtr = 0xAA;

      3- during execution, check for changing its value:

           if(*stackPtr != 0xAA)


                  flag_stack_overflow = true;



      It does not working.

      Unfortunately I cannot use the debug mode because the used flash is over the 90% and the debug exceeds the available flash.


      Thanks for your help!

        • 1. Re: how can i detect stack overflow?

          You still can debug your project, even when compiled as release. When you stop execution you may look at the memory in the debugger. You can fill the memory manually with fixed values and check how much gets altered after a while.

          <furthermore to help debugging is: You may set the optimization level on a file basis. So you can allow the debugging for a single file only.



          1 of 1 people found this helpful