All posts filed under: RTOS

The FreeRTOS Tick – Unravel the Mystery to Master the Tick

Over the last few years, I have become a fan of FreeRTOS for a few different reasons: It’s free (though a paid versions allow for some protection) Portable as it abstracts well from the hardware it runs on Provides an easy way to separate┬ásections of code Allows for control of when, and how often, tasks are run It’s the last point that this post will delve into. How does each thread (tasks in FreeRTOS speak) control when they run? It all comes down to the ‘tick,’ the magical trigger that FreeRTOS uses to know when to switch which task is running or give up waiting for a semaphore that will never be given. What Drives the FreeRTOS Tick It all comes from the FreeRTOS Tick – the function that is called at a periodic interval. As we will see below, this tick drives the context switch between tasks. But first, what drives this tick? At the simplest level, the tick is just a timer that has a period set to match the desired tick rate. …