cancel
Showing results for 
Search instead for 
Did you mean: 

Setting up FreeRTOS for low-power usage using LPTIM not possible in CubeMX

Andres1
Associate II

I just wonder why I am not able to set up LPTIM1 as time base for FreeRTOS.

Background: For battery powered applications I often use FreeRTOS with tickless mode and a sleep instruction in the idle hook function. This, allows automatic switching in sleep mode, when there is nothing to do. Perfect,

Problem: When I use a normal timer as time base for my RTOS then I am only allowed to use the "Sleep Mode". But in sleep mode the µC consumes a high amount of power. So I would like to use the "Stop Mode" But in "Stop Mode", the core is stopped and the only oscillators that are able to run are the LSE and LSI.

Setting up FreeRTOS for low-power usage using LPTIM1 or LPTIM2 as clock base is not possible in CubeMX. See the attached screenshot.

Does anybody ran into a similar problem? How do you setup your RTOS based systems for ultra-low-power applications?

3 REPLIES 3
Rogers.Gary
Senior II

Good luck on this. Low power modes using FreeRTOS is a "hogged" subject and it appears everyone who knows how to implement this in FreeRTOS keeps this secret society knowledge to themselves. Yes, you may find tidbits and generalities, but no examples that actually work. I'm speaking of not just a basic sleep, but the stop modes, etc. It is ST themselves should provide a real working example of this. I find it stunning and annoying that they don't! Think about that for a second - they provide both the low power capability of the silicon, and within CubeMX the ability to implement the FreeRTOS framework, and then expect a user to magically "wave the wand" and figure out the rest. I don't get it! Why do they bother writing any examples on the subject at all? Doesn't FreeRTOS count since it's so widely used? They have made some amazing devices, and CubeMX is a great tool. Next step - examples using low power modes in FreeRTOS!

Why doesn't someone from ST explain why they have zero examples on this critical and key area, because power saving is important in our "green" endeavors?

Andres1
Associate II

Thank you for sharing your experience.

It is still not possible to use CubeMX for RTOS based low-power applications. Yo have to generate it as it is and then do the modifications like activating tickless mode. Usage of CubeMX want be possible after modifications. However, there are examples included in both, FreeRTOS and CubeMX example folder.

(1) Example at FreeRTOS page using STM32L3

Low Power RTOS Demo - ST STM32L

Using IAR and the STM32L-Discovery Board

https://www.freertos.org/STM32L-discovery-low-power-tickless-RTOS-demo.html

(2) CUBE MX Example for IoT board STM32L4 for the Board B-L475E-IOT01A

Therefore you need to install CubeMX and navigate to

\STM32Cube\Repository\STM32Cube_FW_L4_V1.12.0\Projects\B-L475E-IOT01A\Applications\FreeRTOS\FreeRTOS_LowPower_LPTIM\Src

Jeff Tenney
Senior

I just finished a solution here, using LPTIM. Wouldn't think of "hogging" it. 😉 I did it because I needed accurate kernel time -- no drift like other solutions.

https://gist.github.com/jefftenney/02b313fe649a14b4c75237f925872d72

  • It doesn't use systick or the RTC at all.
  • It never stops the LPTIM.
  • It eliminates drift in kernel time normally associated with tickless idle.
  • It eliminates drift due to rounding the OS tick width to a whole number of timer counts.

Jeff