Tickless Mode in FreeRTOS Explained: Sleep Longer, Save More Power
Introduction
One of the biggest challenges in today’s microcontroller-based systems is reducing power consumption. A common technique is to put the MCU into sleep or deep-sleep modes whenever the system is idle, only waking it up on interrupts. In a FreeRTOS-based project, this becomes tricky because the kernel relies on the SysTick timer, a periodic interrupt that fires at a fixed rate such as every 1 ms. This constant tick means the CPU is regularly woken up even when no tasks are running, which prevents it from staying in low-power modes for long periods. To solve this problem, FreeRTOS introduced tickless idle mode, a feature that suppresses unnecessary SysTick interrupts and allows the processor to remain in sleep longer, resulting in significant power savings.
2. What is Tickless Mode?
In a traditional FreeRTOS setup, the SysTick timer generates an interrupt at a fixed frequency, often every 1 millisecond. This tick drives the scheduler, timeouts, and task delays, but it also forces the CPU to wake up constantly, even if there is nothing useful to do.
Tickless mode changes this behavior. Instead of running periodic ticks at all times, FreeRTOS suppresses them when the system is idle. The kernel calculates when the next task or timeout is due and programs a hardware timer to wake the MCU at exactly that moment. Until then, the processor can stay in sleep or deep-sleep mode.
When the timer or an external interrupt finally wakes the system, FreeRTOS updates its internal tick counter to account for the time that has passed. To tasks, it looks as if all the ticks occurred normally, but in reality the CPU stayed asleep, saving power.
This approach allows microcontroller-based devices to extend battery life significantly without changing application code. Tasks continue to use the same delay and timeout APIs, while the OS takes care of the low-power optimization behind the scenes.
How to Use Tickless Mode in FreeRTOS:
Get Wadix Technologies’s stories in your inbox
Join Medium for free to get updates from this writer.
To enable tickless idle in FreeRTOS, you simply set configUSE_TICKLESS_IDLE = 1 in your FreeRTOSConfig.h. Once this is enabled, the kernel will call the function vPortSuppressTicksAndSleep() whenever the system becomes idle. Inside this function, you decide how the MCU should sleep. In the simplest case, the CPU can just execute a Wait For Interrupt (WFI) instruction, which puts it into a low-power state until the next interrupt occurs. When the processor wakes, FreeRTOS adjusts its internal tick counter with vTaskStepTick() to account for the time spent sleeping. This way, tasks still resume at the right time, but the system avoids unnecessary periodic wake-ups from the SysTick timer. The following example shows a minimal implementation:
void vPortSuppressTicksAndSleep(TickType_t expectedIdleTicks)
{
if (expectedIdleTicks > 10 )
{
if (eTaskConfirmSleepModeStatus() != eAbortSleep)
{
disable_interrupts();
/* Enter low-power mode until the next interrupt */
__DSB();
__WFI();
__ISB();
/* Correct the RTOS tick count */
vTaskStepTick(expectedIdleTicks);
enable_interrupts();
}
}
}With this simple setup, FreeRTOS no longer wakes the CPU on every SysTick interrupt while idle. Instead, the processor stays in sleep mode until the next real event, which can lead to significant power savings in applications where the system spends most of its time waiting.
3. Benefits of Tickless Mode
The primary benefit of tickless idle mode is power efficiency. By suppressing unnecessary SysTick interrupts during idle periods, the CPU can remain in sleep or deep-sleep states for much longer stretches. This directly reduces energy consumption and extends the lifetime of battery-powered devices.
Another important advantage is that tickless mode is transparent to application code. Developers do not need to change how they write tasks — functions like vTaskDelay() or timeouts continue to work exactly as expected. FreeRTOS internally tracks the elapsed time and ensures tasks resume correctly after sleep.
Finally, tickless idle mode is highly effective in systems where the processor spends most of its time waiting. Examples include IoT devices, wireless sensors, and wearables, where workloads are often bursty. In such cases, the reduction in unnecessary wakeups can translate into days, weeks, or even months of additional battery life
4. Conclusion
Tickless mode lets FreeRTOS cut down unnecessary wakeups, keeping the CPU asleep longer and saving power its a simple feature that can make a big difference in battery-powered systems.
If you enjoyed this article, keep learning with structured embedded systems courses at Wadix Technologies.