cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, I have an STM32F413ZH Discover board.I have imported FREE RTOS on to the board.Now I have been trying to implement LOW POWER mode in it.For that I have enabled the macro configUSE_TICKLESS_IDLE to 1. But even though the low.

Smedi
Associate II

I have tried calling the function HAL_PWR_EnterSLEEPMODE function call also but even though the Controller is not entering sleep mode.I want to know how to configure the sleep mode in the FREE RTOS for this controller.

Regards

Srikanth.

2 REPLIES 2
Jack Peacock_2
Senior III

Entering sleep mode is fairly simple, as documented in the STM32 reference manuals. The complicated part is staying in sleep mode. Any interrupt will exit sleep, which means the next SysTick will wake up the core. And if you have any other kind of periodic interrupt, like circular DMA, timed ADC sequences, etc., those will wake up the core too. The FreeRTOS tickless mode is supposed to get around this but it's not a simple task.

FreeRTOS does have an example for tickless mode (link in the FreeRTOS website) but it has to be added in and edited to fit your setup, which is why you don;t see any change just by enabling tickless mode in the config file. How to do it with HAL I have no idea or even if ST supports it, but if you control your interrupts you have to disable any periodic source which isn't needed in idle mode. This is application dependent so there is no one answer to your question.

One of the first problems you'll encounter is SysTick. It has to be turned off while sleeping, but you still need to track elapsed ticks while the core is stopped. This means using another timer (I use TIM6 for this) clocked at a lower frequency to measure equivalent ticks over many seconds or minutes. After a wakeup you have to update the RTOS tick count with the elapsed ticks in order to keep any time dependent RTOS call in sync.

To make it more interesting you have to account for "partial" ticks from both SysTick and the alternate timer When you stop these timers there's some time already lapsed; you can't ignore it.. If ignored it's a cumulative error that shows up in erratic timing the longer the application runs.

One suggestion: use a timer that's base don the same source oscillator as SysTick. That way your elapsed time works out to an equivalent number of SysTick ticks. Using the RTC and subseconds will have a cumulative error you have to manage.

There are also timing issues if you use an RC oscillator (HSI, MSI) instead of HSE. The RC oscillators have a 1% tolerance (and yes it really does vary by that much). That's not strictly a tickless issue but it will affect your timing.

A good way to test your tickless mode is to set up an LED blink using a soft timer. If the LED isn't changing on time you know there's a problem.

Jack Peacock

Hi Jack,

Thanks for reply and I have used Time base Source as TIM1 not SYSTick.If possible can you share reference code for this implementation.

Srikanth.