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.

CCS/TMS570LS0432: SCI Interrupt Causing Stack Overflow

Part Number: TMS570LS0432
Other Parts Discussed in Thread: LAUNCHXL-TMS57004

Tool/software: Code Composer Studio

Hi all,

I am currently developing code for the TMS570LS0432BPZQQ1 (on the LAUNCHXL-TMS57004). I am running into issues where the stack will overflow if an sci interrupt occurs within nested functions.

For instance if I do:    main->function1->function2->sciReceive(), then the device will have a stack overflow and not return to the higher functions.

I can remedy this issue by putting all of the code from the functions in the main, but as you can imagine this clutters the main function quite a bit. Is there any way to avoid this while keeping the function calls?

I've read through spna219 ("Nested Interrupts on Hercules™ ARM® Cortex®-R4/5- Based Microcontrollers"), but would like to see if there is an easier way to fix the issue as I never intend on interrupting the sci interrupt.

Thanks!

Vince Toledo

  • Hi Vince,

    TMS570 device doesn't support nesting interrupt in HW, so I don't recommend using the nested interrupt.

    What happens if you increase the stack size? The stack size is defined in sys_core.asm, and cmd file.

  • Hi QJ,

    I have increased my stack size as follows:

    RAM Length: 0x00008000 (Base Address: 0x08000000)

    Stack Length: 0x00006C00

    User Stack Length: 0x00005000

    Supervisor Stack Length: 0x00001000

    FIQ Stack Length: 0x00000300

    IRQ Stack Length: 0x00000300

    Abort Stack Length: 0x00000300

    Undefined Stack Length: 0x00000300

    Unfortunately the code still exits early due to stack overflow and the return address getting overwritten. Let me know if these stack length values suffice.

    The place that the code exits into is in sys_intvecs.asm, prefetchEntry->"b prefetchEntry".

    Thanks!

    Vince

  • Vince,

    If I understand correctly, you are not using nested interrupts. Rather you just have functions calling other functions: main->function1->function2->sciReceive()

    This is perfectly okay to do. The return addresses are successively pushed onto the stack for the mode the CPU is in when you call the main function. A stack overflow typically occurs when you have temporary variables defined in one of the callee functions, with the usual suspects being large arrays or look-up tables. Please make sure that the stack size allocated for the specific CPU mode is sufficient for these temporary variables.

    Regards, Sunil

  • Sunil,

    Thank you for the suggestions, I went ahead and reduced the overall number of arrays and variables that were declared/instantiated within functions, and this seemed to fix the issue!

    Thank you again for your help!

    Regards,

    Vince