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.

Idle Task Usage

Other Parts Discussed in Thread: SYSBIOS

Hello,

I have some questions about Idle task functions. If I understand correctly Idle task is created and managed by SYS/BIOS where each Idle functions are called periodically and sequentially.

I would like to implement an algo. based on periodically time elapsed, that's why I think Idle task could be a good choice. For each function call a state machine is updated and make some stuff.

Please correct me if I am wrong: Using Idle task for this purpose is not advised, because I need to preserve and update the state machine value between each function calls, so the variables declared in idle functions are locals. -> I need to use Global variables. That also increase the complexity of the code. Consequently idle functions must be very simple: such as GPIO_Toggle(), and system_printf().

I do more better if I make a standard Task() and instantiate a timer for periodic calls, the variables defined in Task are accessible locally and no globals are required.

I would like to know that my conclusion is right or wrong.

Thank you for your reply 

  • Hi Daniel,
    The Idle task runs only when there are no Hwi's, Swi's, or other Tasks running. So if you want your functions to run periodically, you could use a Clock object. Your functions can reference static variables, or static structures containing the state. You don't have to use global variables. It is fine to have functions in the idle loop that update state each time they run (the ti.sysbios.utils.Load module is an example), but if you want to update state periodically, I would go with the Clock.
    Best regards,
    Janet