How to trace stack overflow in running mode?

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

cross mob
Sewa_1343851
Level 1
Level 1

Hi Everyones!

     I have encountered a stack overflow problem due to the allocation of large arrays in some of my functions.

     Does anyone know how to check the stack usage in running mode?  Or how to access the SP(stack pointer) register in running mode?

     BTW, the MCU that I am using now is a CY8C6347.

     Any hint or code snippet will be appreciated!

Sean Wang

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

You could set an address write breakpoint at the top of the stack.This will fire when the stack overflows. Keep in mind that interrupts will need some stack space which might shorten the amount of headroom.

Bob

View solution in original post

4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You could set an address write breakpoint at the top of the stack.This will fire when the stack overflows. Keep in mind that interrupts will need some stack space which might shorten the amount of headroom.

Bob

Hi Bob,

Thank you so much for your reply.

But could you tell me the details about 'how to set an address write breakpoint at the top of the stack' ?

I do know how to set a breakpoint at some specific line of my source code inside the PSoC Creator, and use F10 or F11 to trace my codes step by step. I just don't know how to set a breakpoint at the top of the stack.

Sincerely looking forward to your reply!

0 Likes

Creator help can describe the breakpoints better than me. Open the PCoC Creator Help, select "search" and enter "breakpoint" into the search field. First result entry will show "Address Breakpoint". Scroll a bit down to see how (and where) the dialog windows for breakpoins are to be found.

Set the breakpoint to be a "write" BP since you want to know from where the memory is written.

Bob

Thank you very much and I will try it!

Sean

0 Likes