Making the sleep time in tickless idle shorter

I have FreeRTOS using tickless idle running on an STM151. Clock frequency is 32MHz. When in the tickless idle state, RTOS wakes it every 1/2 second, and with no tasks pending, it goes straight back to sleep. When I go into a power saving state, I reduce the clock freq to 133KHz. Now the tickless idle sleep time is about 240 seconds. This however is longer than the max possible timeout for my watchdog, so the watchdog fires when it goes into the low power mode. Is there a way I can reduce this sleep time on the fly when I go into low power mode, and reinstate the original period when I come out of low power mode? Many thanks, Steve Krenek

Making the sleep time in tickless idle shorter

I assume you are running the tickless idle mode with the SysTick? What you see is that your max idle time possible is depending on the max 24bit SysTick counter value: the faster you run it, the shorter it is (around 800 ms for a 20 MHz clock, see https://mcuoneclipse.com/2013/07/06/low-power-with-freertos-tickless-idle-mode/). You can solve your watchdog problem with using a FreeRTOS timer (see https://mcuoneclipse.com/2018/05/27/tutorial-understanding-and-using-freertos-software-timers/), depending on how you are dealing with the watchdog. Or use a normal periodic task for your watchdog handling. I hope this helps, Erich

Making the sleep time in tickless idle shorter

Thanks Erich – that is very helpful. Steve