Running multiple FreeRTOS tasks on AVR

In the previous post, we just run a single task. Running RTOS with single task has no meaning at all. This can be quickly done with a conventional program. But what if we need to have more separate functions. To execute them at exact timing would require a separate timer or interrupt. But microcontroller cannot guarantee an interrupt for every task. This way it is hard to make code modular, and testing can be painful. Using RTOS solves this kind of problem. It allows programming each task as an endless loop. Kernel scheduler takes care of assuring each task gets its chunk of processing time. Additionally, it does bearing the priority systems – more critical tasks are executed before less important ones. Let us go further with our example code and add more tasks to our FreeRTOS engine. We already have LED flashing task that toggles LED every second. Additionally, we are going to create another task that checks the button state. Also, we are going to send some information to the LCD. As always let’s take care of drivers for all of them.

Continue reading