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

PSoC™ 6 SDK Forum Discussions

micro-atama
Level 1
First like given 10 sign-ins First reply posted
Level 1

Hello,

When I use modus,through the function uxTaskGetStackHighWaterMark(),I could confirm the task stack.

But,I don't know how to comfirm the maximum usage of system stack .

Question 1  : Is there any way to do it?

※When I use Keil, an htm file will be generated after the project is compiled, and I can find the maximum usage of the stack through this file. 

Question 2:  Is there a similar file after compiling?

0 Likes
1 Solution
AlenAn14
Moderator
Moderator 100 solutions authored 250 replies posted 250 sign-ins
Moderator

Hi @micro-atama ,

After you complete the build procedure in Modus Toolbox, you get a summary of the memory usage in the console window as shown below:

AlenAn14_0-1656906643812.png

 

The system stack usage can only be observed at runtime as this parameter is dynamic.
You can observe the stack pointer value from the Registers view while debugging the device:

AlenAn14_1-1656906901467.png

Warm Regards
Alen

 

 

View solution in original post

0 Likes
5 Replies
AlenAn14
Moderator
Moderator 100 solutions authored 250 replies posted 250 sign-ins
Moderator

Hi @micro-atama ,

After you complete the build procedure in Modus Toolbox, you get a summary of the memory usage in the console window as shown below:

AlenAn14_0-1656906643812.png

 

The system stack usage can only be observed at runtime as this parameter is dynamic.
You can observe the stack pointer value from the Registers view while debugging the device:

AlenAn14_1-1656906901467.png

Warm Regards
Alen

 

 

0 Likes
micro-atama
Level 1
First like given 10 sign-ins First reply posted
Level 1

Thank you for your reply,@AlenAn14

Following your method ,I can confirm the current usage of system stack .It is really helpful.

But there is still no way about call chain for maximum stack depth

 

Best Regards

0 Likes
AlenAn14
Moderator
Moderator 100 solutions authored 250 replies posted 250 sign-ins
Moderator

Hi @micro-atama ,

The actual stack depth is a run time parameter which increases as you increase the number of functions you use recursively in your project.
If you require to know the total stack size that is allocated for your project in the RAM then, you can find the same in the linker script of the CM4 core in the following path:
<Path to project>\libs\TARGET_CY8CKIT-062-WIFI-BT\COMPONENT_CM4\TOOLCHAIN_GCC_ARM\cy8c6xx7_cm4_dual.ld

In the above mentioned .ld file, you can look for the macro STACK_SIZE which tells you how much of RAM is allocated for stack.

I will check on this internally and see if there is a way to get the maximum stack depth that is utilized by a project.

Hope this helps.

Warm Regards
Alen

0 Likes
micro-atama
Level 1
First like given 10 sign-ins First reply posted
Level 1

Thank you,@AlenAn14

Actually,I'm writing a report about stack.And I wish to add some theoretical value such as maximum stack depth.

If there is,then better.If not, it doesn't matter.

Best Regards

0 Likes
AlenAn14
Moderator
Moderator 100 solutions authored 250 replies posted 250 sign-ins
Moderator

Hi @micro-atama ,

If its for a theoretical sense, then the only thing that mainly decides the stack depth is the number of recursive function calls that you do in your project.

Now another important detail here is the amount of RAM available in your embedded device as stack is taken form the RAM and you do not want your stack memory to grow and exceed the maximum RAM size nor do you want it to grow into your heap area (also present in RAM)  there by corrupting the heap memory segment when the stack grows down from the top of RAM.

So it is difficult to give a theoretical value for stack unless you are aware/specify a specific project but you can always know the maximum stack size based on the RAM supported provided you are aware of the device you are using.

Hope this helps.

Warm Regards
Alen