This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430 Call Stack Depth using CCS5

Is there a way to determine the static call stack depth of a program using the TI MSP430 tools provided with CCS5?

  • Hello Darren,

    This is more of a function of how much you allocate for your stack and heap sizes which are configurable in your project options.

    You need to have a rough idea of how much you need to push/pop on your stack and then you need to allocate that in the project.

    There are some examples out there on how to write your own stack probe if you think that is what you need.

    Regards,
    jwest 

  • Darren Beckwith said:
    Is there a way to determine the static call stack depth of a program

    Only by observation. Besides the space needed for the calls itself (which could be determined by analyzing the code), there's the space required for local varibles (also analyzable), then the space needed for saving processor registers (requires analyzing of the generated assembly code) and the space needed for storing the return address of ISRs and the register saves it does. Which cannot be analyzed at all.

    You can get a rough estimation, but the real worst case value cannot be determined. Even observation won't give any proof that it will be the worst case value.

    Do it the engineers way: calculate what you can calculate to ten decimal digits. Add a 10% safety margin, and then double the result, just to be safe.

  • Darren Beckwith said:
    Is there a way to determine the static call stack depth of a program using the TI MSP430 tools provided with CCS5?

    Not as part of the CCS5 install.

    However, Code Generation Tools XML Processing Scripts are available. Finding out static stack usage describes how to use call_graph to build a static call graph, along with stack usage.  

    Note that with CCS5 you have you use the cg_xml programs from the command line, since Code Generation Tools XML Processing Scripts Plug-in for CCS (CG_XML_CCS) not working in CCS5

  • I would also be really interested in that kind of solution to check my stack usage...

    Is there any way of finding static stack usage as suggested in your links but that would work on CCs v5.3 ?

  • The tools described in the previous posts work for CCS 5.3, they just need to be lunched from the command line.

  • You can also employ some runtime dynamic analysis too. Make the stack as large as possible, and before the C-runtime evironment is setup, initialize the entire stack space to a known magic number.

    Then use the debugger to break into your application after some time of operation and dump the memory to see how much stack has been used. This, plus static analysis should give you a good clue as to actual usage.

**Attention** This is a public forum