how can i detect stack overflow?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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!

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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.

Bob

View solution in original post

1 Reply
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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.

Bob