Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training



Posted by brunopaillard on November 9, 2016


I am working on an STM32L432. I am trying to implement low-power features. Specifically, I am using the Tickless-Idle mode to put the MCU to sleep when it enters the Idle task. I am using a periodic interrupt to wake it up periodically, and do a minimal processing (about 100 us worth of MCU cycles). I would like to have the following behaviour: - The MCU wakes up at periodic intervals (once every 125 ms). - It does its 100us processing. - It falls back to sleep immediately upon entering the Idle task (if there is no other task ready of course) The behaviour that I see instead when configEXPECTEDIDLETIMEBEFORESLEEP is set to the default (and minimum) value of 2, is that after waking up, the MCU stays awake for a minimum of 1 tick period (1ms in my case: too long).

I tried to set configEXPECTEDIDLETIMEBEFORESLEEP to 1, and then I have the behaviour that I need. But setting configEXPECTEDIDLETIMEBEFORESLEEP to 1 creates a compile error that says: "#error configEXPECTEDIDLETIMEBEFORESLEEP must not be less than 2".

I can easily disable that error message, but before I do that, I would like to understand better what the risks are.

Note that in that project, a tight accounting of ticks is not requried. The tick counter can freeze once in a while, or skip a beat, without any noticeable effect.




Posted by edwards3 on November 9, 2016

I guess the reason will be something to do with rounding the value down in the algorithm because you enter sleep part of the way through a tick period, and you dont want an underflow. Guessing though. Try setting it to 1 and see what happens. You say clock accuracy is not a problem for you so if you get underflows just edit the code to guard that from happening.


Posted by brunopaillard on November 9, 2016

When I set it to 1, it does what I need: i.e. falls to sleep the very next time the MCU enters the Idle task... usually a few 100us after waking up.

I am worried about unforeseen side-effects though, and so I would like to understand what the rationale was for keeping configEXPECTEDIDLETIMEBEFORESLEEP > 2


Posted by rtel on November 10, 2016

The following line, and one other...

ulTimerCountsForOneTick * ( xExpectedIdleTime - 1UL ) );

...requires the expected idle time to be 1 or higher.

In addition, in a normal application it is not desirable to enter low power mode for too short a sleep, as that can increase power consumption rather than reduce it. That is because you need to do additional execution to calculate the time going into the sleep and then going out again, plus you have to power down then get inrush when powering up the CPU again.

[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists