Checking the actual stack size and heap size in PSoC Creator

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

cross mob
NaMo_1534561
Level 5
Level 5
Distributor - Macnica (Japan)
100 replies posted 100 sign-ins 50 replies posted

Hello,

The amount of RAM that can be checked at PSoC Creater's build or in the Resource Meter view is the sum of the stack size and heap size that reserved space in advance, not the size actually used during program operation.

Is there a way to check the actual stack size and heap size?

Software version    PSoC Creator 4.2  (4.2.0.641)

Best Regards,

Naoaki Morimoto

0 Likes
1 Solution
Takashi_M
Moderator
Moderator
Moderator
1000 replies posted 500 solutions authored 750 replies posted

Unfortunately, there is no functionality to monitor runtime heap/stack size in PSoC Creator.

Regarding the stack, even though it is not runtime monitor, it can be checked with PSoC Creator Debugger mode.

0) Implement the debug code to fill the known value (e.g 0xAA55) in stack area in beginning of main() function.

1) Start debug in PSoC Creator (PC is stopped at b/o main() fuction)

2) Run the software

3) Stop the software

4) Check how many data in stack area is changed from the know value (e.g. 0xAA55).

The above example has been introduced in AN89056, even though it is not exactly same.

https://www.cypress.com/documentation/application-notes/an89056-psoc-4-iec-60730-class-b-and-iec-615...

Specially, please refer to the section 6.8 Stack Overflow Test in AN89056.

https://www.cypress.com/file/141001/download

And AN89056_Ram project (SelfTest_Stack.c) in zip file.

https://www.cypress.com/file/140996/download

View solution in original post

0 Likes
6 Replies
Takashi_M
Moderator
Moderator
Moderator
1000 replies posted 500 solutions authored 750 replies posted

Just confirmation...

Do you want to know if there is any way to check run time stack and heap size (during system is running)?

0 Likes
NaMo_1534561
Level 5
Level 5
Distributor - Macnica (Japan)
100 replies posted 100 sign-ins 50 replies posted

TakashiM-san,

Yes, it is. If you have a tutorial or manual link, it will be helpful.

Best Regards,

Naoaki Morimoto

0 Likes
NaMo_1534561
Level 5
Level 5
Distributor - Macnica (Japan)
100 replies posted 100 sign-ins 50 replies posted

Hello,

I can't find the information about it on PSoC Creator user's guide, Knowlede Base, Application note and this community.

Is there no way to measure actual heap and stack size on PSoC Creator?

If you can measure the actual heap and stack size of the PSoC Creator project with other tools, please let me know.

Best Regards,

Naoaki Morimoto

0 Likes
ScottA_91
Employee
Employee
10 solutions authored 100 replies posted 50 replies posted

You might be able to get your stack size, but not the heap size.

Differences between Stack and Heap

The heap is affected by the call graph at any given point.  I'm not aware of any tools in PSoC Creator to figure out the maximum stack or heap used by your code.

0 Likes
Takashi_M
Moderator
Moderator
Moderator
1000 replies posted 500 solutions authored 750 replies posted

Unfortunately, there is no functionality to monitor runtime heap/stack size in PSoC Creator.

Regarding the stack, even though it is not runtime monitor, it can be checked with PSoC Creator Debugger mode.

0) Implement the debug code to fill the known value (e.g 0xAA55) in stack area in beginning of main() function.

1) Start debug in PSoC Creator (PC is stopped at b/o main() fuction)

2) Run the software

3) Stop the software

4) Check how many data in stack area is changed from the know value (e.g. 0xAA55).

The above example has been introduced in AN89056, even though it is not exactly same.

https://www.cypress.com/documentation/application-notes/an89056-psoc-4-iec-60730-class-b-and-iec-615...

Specially, please refer to the section 6.8 Stack Overflow Test in AN89056.

https://www.cypress.com/file/141001/download

And AN89056_Ram project (SelfTest_Stack.c) in zip file.

https://www.cypress.com/file/140996/download

0 Likes
NaMo_1534561
Level 5
Level 5
Distributor - Macnica (Japan)
100 replies posted 100 sign-ins 50 replies posted

Hello TakashiM-san,

Thank you for your answer.

I will give the feedback from customer later.

Best Regards,

Naoaki Morimoto

0 Likes