|ARM Technical Support Knowledge Articles|
Applies to: C51 C Compiler
How can I determine the maximum stack size of my program?
There is no automatic way the tools can tell you the maximum stack depth or stack utilization. Because of asynchronous events and interrupts, the automation is too difficult.
However, you can use the uVision Simulator which provides the sp_max value in the register window. When you execute all features of your application, this gives you the maximum sp value that has been reached by your application. Make sure that your assumptions about the available stack are correct. Some 8051 variants have just 128 bytes on-chip RAM and therefore the stack space ends at 0x7F.
You should have more bytes available for executed interrupts. As a guideline, there should be enough space to execute the most complex interrupt of your application.
If you cannot use the uVision Simulator, use the following method, which works in any debugging tool. You may use the Monitor, the ISD51 In-system debugger, or any in-circuit emulator. The results should be similar.
Article last edited on: 2004-05-10 21:23:14
Did you find this article helpful? Yes No
How can we improve this article?