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.

TMS320F28386D: Stack overflow

Expert 1400 points
Part Number: TMS320F28386D

When use the  example from TI: erad_ex3_stack_overflow_detect

In the CMD file  

 RAMM1            : origin = 0x000400, length = 0x0003F8     /* on-chip RAM block M1 */

.stack              : > RAMM1

Length is 0x0003F8(1016 *2= 2032 bytes)     

I suppose the addr_params.address shall be 2032-10=2022.

But as below debug window shows that the value is 2030.

Another question is When first enter into the RTOSISR Interrupt.

Take the above debug infotmation, addr_params.addres =2030(3F7)

The start address of stack is 0x000400.

So I suppose when SP more than 0x400+0x3F7= 7F7, it shall enter into the RTOSISR Interrupt.

I suppose when  first enter into the RTOSISR Interrupt, the SP value shall be 0X7F7+0X06=0X7FD. Not the 0x806.

Is must be something wrong with my understand.

Hoep TI expert can help

  • For the second question.

    Does the stackflow dection start at SP is 0x40A?

    Then add addr_params.addres =2030(3F7)

    0x40A+0X3F7 =0X801.

    When the SP is more than 0x801. it will enter into the RTOSISR Interrupt.

    Then 0x801+0x06 = 0x807 

    But still have 0x01 gap.

  • Hi,

    The ISR also needs some stack. Compiler inserts register save instructions at the start of the ISR (total number registers saved will depends on the function implementation and optimization levels). In effect, the SP would be incremented to few more words by the time it is inside the ISR. You may check the assembly code to understand how many registers are saved and how much stack memory is being used. 

    Regards,

    Veena

  • Could you please help with the above first question?

    The value of ddr_params.addres =2030(3F7)

    I suppose the addr_params.address shall be 2032-10=2022.

    But as below debug window shows that the value is 2030.

  • In above description, I already add the ISR Stack, it is 6.

    For the second question.

    Does the stackflow dection start at SP is 0x40A?

    Then add addr_params.addres =2030(3F7)

    0x40A+0X3F7 =0X801.

    When the SP is more than 0x801. it will enter into the RTOSISR Interrupt.

    Then 0x801+0x06 = 0x807 

    But still have 0x01 gap

  • I dont understand why you mentioned 0x40A?

    addr_params.address = (uint32_t)&__TI_STACK_END - threshold; -> 0x7F8 - 10 = 0x7EE.

    C28x CPU automatically saves a set of registers. From the TMS320C28x CPU and Instruction Set Reference Guide : 

    There are in addition to the set of registers saved by the compiler in the ISR code

    Regards,

    Veena

  • This picture shows that When run at addr_params.address = (uint32_t)&__TI_STACK_END - threshold;  the SP value is 0x40A

  • The stack is from 0x400 to 0x7F8.

    We set the threshold is 0x7EE.

    It means that when the value of SP more than 0X7EE. It shall enter into the RTOSISR Interrupt. Am I right?

    As bebug window shows that when enter into the RTOSISR Interrupt, the value of SP is 0x806.

    The CCS window of stack usage which show the stack size of  RTOSISR  is 6. Does this is not trusted? Cannot use it as stack size calculation?

  • As mentioned in my previous reply, C28x CPU automatically saves a set of registers to the stack. This is not included in the compiler inserted stack usage, which is 6.

    Regards,

    Veena

  • Thanks for your patience. 

    Could please help confirm the below point?

    The stack is from 0x400 to 0x7F8.

    We set the threshold is 0x7EE.

    It means that when the value of SP more than 0X7EE. It shall enter into the RTOSISR Interrupt. Am I right?