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/TM4C1294NCPDT: TI-RTOS heartbeat task stack grows

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

Hello,

i have an TM4C1294NCPDT µC with TI-RTOS running on it with an heartbeat Task which is toggling an LED.

void heartBeatFxn(void)
{
    while (1)
    {
        Task_sleep(1000);
        GPIO_toggle(OUTPUT1);
    }
}

I let the program run for 16 hours and i looked at the Task stack peak. At start it used 252 bytes from 512 bytes. After 3 hours it grew to 264 and after 11 hours to 288.

I do not understand this behaviour. My expectations with a simple task like that was that the task stack peak would be constant. Is this something to worry about or is this a normal behaviour?

Thanks in advance!

Best regards

Akos

  • Hi Akos,

    Is the heartbeat task part of a larger application or have you isolated your application to only include this task?

    Observing both the GPIO_toggle() and Task_sleep() API implementations, I suspect that the Task_sleep() API is going through variable execution paths.

    Depending on the execution path, the max task stack may grow.

    Derrick

  • When an ISR occurs, a few things are written onto the running task stack. So the task peak stack usage will be at the task's stack usage + ISR switching overhead.

    Here's an example. Let's say the overhead is 32 bytes (I'm travelling and don't have access to get the exact number). Let' say that the task is 99.99% of the time in the Task_sleep when a timer ISR occurs. Let's say that stack usage while pending on the sleep is 200. So the peak will be 200 + 3= 232. Now let's say there is a stack usage of 220 while in the GPIO_toggle. If the timer ISR occurs at that time, the peak would climb to 220 + 32=252. So it's normal that over time, the stack peak might creep up a bit due to when an ISR occurred, but it should hit a maximum. I expect if you let the application run over the weekend, the 288 would still be the peak.

    Todd

  • Thank you very much!