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.

SysCtlDelay not working in the idle thread

Hello,

In my main.cpp program I start the BIOS and it has an idle thread. BIOS is calling the idle function successfully (I can set a breakpoint there and it will get called). The only thing I do there is to turn an LED on/off with a couple of delays in between. I'm using SysCtrlDelay for the delays. The problem is that SysCtrlDelay is not working, it is not pausing for the expected number of cycles, resulting in much shorter delays than expected.

Before starting BIOS, I use the same function to blink the same LED's a couple of times with a 500ms interval. It works fine.

Since I'm using C++ (and main.cpp), I had to decorate my idle handler with extern "C". That's the only thing that might be non-standard.

Any hints? Is there a better way to delay in the RTOS?

I'm using CCS 6.1 with TI-RTOS 2.12.01.33 and TivaWare 2.1.1.71 on a TM4C 129X.

TIA

  • Hi Paulo,
    First thing I've observed is that you're trying to delay or block the idle function which isn't recommended. The idle task is what is supposed to run when every other task is blocked. You should create a separate task for this purpose. Next thing we don't recommend is using the SysCtrlDelay with TI-RTOS. SysCtlDelay is part of TivaWare which is independent of TI-RTOS and so it probably makes assumptions about the clock settings to calculate its delay. The TI-RTOS kernel (BIOS) configures the system including the clock in a way that probably invalidates the SysCtrlDelay.
    In TI-RTOS you can use a Task_sleep within a task to achieve a delay. Other synchronization modules example Semaphores can be used along with a Timer module to achieve a delay. With this method, you pend on a Semaphore, start the Timer and post the Semaphore in the Timer function when it time expires.

    Let me know if this helps.

    Regards,
    Moses
  • Thanks for the help.

    I'll move that to a task then.

    If not for situations like this, for what purposes should I considering using the idle function?
  • It depends on your application but I'd say as long as it's a non-blocking functionality.

    Moses