EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

MSp430 stack tracing

Started by july...@gmail.com March 13, 2014
Hi
I am using CCS version 5.
I want to check if my stack allocation is correct or not?
i had done some testing by directly writing into stack area and check the value in debugger.

is there a way through which CCS can generate some information like which function is going to use how much stack.

thanks for the help.

Beginning Microcontrollers with the MSP430

I do not know exactly what you mean by "stack allocation is correct or not". I think CCS Linker allocates as much as physically possible the amount of SRAM for the stack. Thus in a sense, this is correct. However, this does not mean that (a) the stack will never overflow at run-time, and (b) all that memory will actually be used by the stack.

The amount of stack needed depends mostly on the code you wrote and the input at run-time. (To a lesser degree, the stack size also depends on how the compiler translated your code into machine code.) CCS is unable to estimate how much stack is needed. It does have the option that you can tell it an estimated stack size (and this has a default value in case you did not tell it). In case there is not enough SRAM with this estimated stack size, CCS Linker will generated an error msg and abort. Otherwise, it will allocate all the available SRAM to the stack (not just the estimated size).

The default value of the estimated stack size is not very meaningful.
CCS has option to set the Stack Size. By default it has some fixed size.
my only question was is there way to know if i am overflowing the expected
stack size.
and answer is Yes .I figured it out in CCS there is an option which check
the stack over flow and breaks the code execution on stack overflow.

i am not sure but some tools used to have info options which generates
which function uses how much stack. and it is very useful.

On Sat, Mar 15, 2014 at 11:27 AM, wrote:

> I do not know exactly what you mean by "stack allocation is correct or
> not". I think CCS Linker allocates as much as physically possible the
> amount of SRAM for the stack. Thus in a sense, this is correct. However,
> this does not mean that (a) the stack will never overflow at run-time, and
> (b) all that memory will actually be used by the stack.
>
> The amount of stack needed depends mostly on the code you wrote and the
> input at run-time. (To a lesser degree, the stack size also depends on how
> the compiler translated your code into machine code.) CCS is unable to
> estimate how much stack is needed. It does have the option that you can
> tell it an estimated stack size (and this has a default value in case you
> did not tell it). In case there is not enough SRAM with this estimated
> stack size, CCS Linker will generated an error msg and abort. Otherwise, it
> will allocate all the available SRAM to the stack (not just the estimated
> size).
>
> The default value of the estimated stack size is not very meaningful.
>
>

The 2024 Embedded Online Conference