Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

configEXPECTED_IDLE_TIME_BEFORE_SLEEP Lower than 2?

Posted by brunopaillard on November 9, 2016

Hi

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.

Thanks

Bruno


configEXPECTED_IDLE_TIME_BEFORE_SLEEP Lower than 2?

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.


configEXPECTED_IDLE_TIME_BEFORE_SLEEP Lower than 2?

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


configEXPECTED_IDLE_TIME_BEFORE_SLEEP Lower than 2?

Posted by rtel on November 10, 2016

The following line, and one other...

ulReloadValue = portNVIC_SYSTICK_CURRENT_VALUE_REG + ( 
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 ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner