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.

TMS320F280039C: Questions about stack

Part Number: TMS320F280039C


Hi Champ,

I am confirming for my customer.

(1). Where could I find the source code of dealing and clearing stack ? Is it in boot.asm ?

(2). User is interested in the piece of code how we handle to clear the stack, could the expert show me the source code, and explain how we implement it ?

(3). As user could define the stack section, are the functions' and variables' starting position & range fixed every time in stack ? Or would the starting position and range be different ?

Thanks and regards,

Johnny

  • Johnny

    The stack pointer is initialized in boot.asm . Size of the stack is defined by the compiler option --stack.  and the stack section address is determined by the entry in the linker command file,

    Following is snippet of code from boot.asm that declares and initializes stack pointer. 

    Stack is used for storing function parameter values, hence it will be updated at runtime.

    Best Regards

    Siddharth

  • Hi Siddharth,

    Thanks for the timely reply.

    Following question about as below snippet, the line declares the stack address and size. Does the line also reset the stack address and clear the .stack(size) ? Does it count as a reset / clear the stack declaration ? 

    If not, where will the stack be cleared and reset at some point in boot28.asm or any other places ?

    Thanks and regards,

    Johnny

  • Hi, 

    The stack pointer is initialized by the code in boot.asm. 

    In the above snapshot, there is a line "MOV SP, #__stack" which initialzes the stack.

    Best Regards

    Siddharth

  • Hi Siddharth,

    The line "MOV SP, #__stack" appears to refer the stack position to SP.

    We did a test, after reset, then set the breakpoints as below. We found out the line was been executed, while there are values for the stack(not 0). 

    If it runs in first time and stops at the line, it is confirmed that the values of stack are all 0.

    (1). Does the two conditions make sense ? 

    (2). As the snippet below, may I reconfirm the part pointed down is the stack, correct ? 

    (3). Customer is planning to re-define the code_start to replace the original f28003x_codestartbranch.asm and boot28.asm. 

    If these two .asm files are still placed in this project, will the code execute the files in project, or the files in ~ ccs1220\ccs\tools\compiler\ti-cgt-c2000_22.6.0.LTS\lib..? The reason for asking this is because there is an error showing redefined as below : 

    error #10056: symbol "_c_int00" redefined: first defined in "./source/boot28_sysinit_boot.obj"; redefined in "C:\ti\ccs1220\ccs\tools\compiler\ti-cgt-c2000_22.6.0.LTS\lib\rts2800_fpu32_eabi.lib<boot28.asm.obj>"

    Should we suggest the customer to exclude f28003x_codestartbranch.asm and boot28.asm from build ? Any comment on the correct handler should be ?

    Thanks and regards,

    Johnny

  • Johnny, 

    You can take a look at the map file to find the size and end address of the stack. (TI_STACK_SIZE for size, TI_STACK_END for end of stack )

    The stack pointer points to the top of the stack. 

    If the customer is planning to have custom _c_int00 and code entry point , then they need not include any RTS library in their project. They will need to exclude rts2800_fpu32_eabi.lib along with f28003x_codestartbranch.asm from their project.

    Best Regards

    Siddharth

  • Hi Siddharth,

    Thanks you for the update.

    I am still confused that I couldn't get the answer to where is the reset/clear the stack performed? If I want to reset (clear) the stack, how to achieve it ?

    Would the lines in below snippet be able to clear the stack ?

    they need not include any RTS library in their project. They will need to exclude rts2800_fpu32_eabi.lib along with f28003x_codestartbranch.asm from their project.

    We removed the RTS library as you suggested. We have tried to either remove the path or temporarily remove rts2800_fpu32_eabi.lib and libc.a. The following error remains. How to deal with it ?

    Thanks for any input.

    - Johnny

  • Johnny , 

    What do you mean by clearing stack ? Do you want to initialize it to all zeros or reset the stack pointer ?

    RTS library provides these functions for memory handling,  You cannot use these functions in the code without using the RTS lib.  I would suggest to retain the boot.asm and then change the entry point.

    Best Regards

    Siddharth