Using LPTIMTick in a Low-Power Tracking Application #23
Replies: 1 comment 7 replies
-
When you configure FreeRTOS for tickless idle, the FreeRTOS scheduler automatically induces tickless sleep when conditions permit. You don't have to do anything. The scheduler calls vPortSuppressTicksAndSleep(). The implementation of vPortSuppressTicksAndSleep() implements both the sleep and the scheduled wakeup at the end of the sleep period. So code in lptimTick.c automatically calculates and sets wakeup times (using the CMP register). But with the code you posted, the scheduler will never induce tickless sleep because the conditions for tickless sleep never exist. If a task will be ready to execute in <= 1 OS tick, then the scheduler simply executes the idle loop until the task is ready to execute.
Yes, software timers work properly with lptimTick.c. Timing is as accurate as LPTIM's reference clock.
No I don't recommend changing GPIO configs in the pre/post sleep routine. Any changes to GPIO config related to sleep should be controlled by the same application software module that normally controls them. Those software modules should be written to keep their GPIO signals in the most quiescent state possible at all times unless they are actively being used. And when they are actively being used, if the pre-sleep function happens to run, it will select normal sleep instead of deep sleep because it sees that the application is not currently ready for deep sleep. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Jeff,
I’m working on a low-power tracking application (STM32 + FreeRTOS).
The tracking device periodically acquires environmental sensor data and transmits it once per cycle (cycle configurable to 5, 15, or 60 minutes).
Within each cycle, sensors are read at a fixed reading period derived from the configured sampling rate (e.g., reading period = 300000ms or 900000ms or 3600000).
In software, a 1 ms software timer checks when the reading period is reached, pushes a message into a queue, and a task processes the reading and data handling.
To reduce power consumption between readings, I have integrated your LPTIMTick library with configUSE_TICKLESS_IDLE = 2.
I’d like to confirm I’m using it correctly:
Entering low-power mode
Do I need to explicitly do anything to enter STOP1/STOP2, or will FreeRTOS automatically call vPortSuppressTicksAndSleep() (and therefore your configPRE/POST_SLEEP_PROCESSING hooks → vUlpPre/PostSleepProcessing) whenever no tasks are ready?
Waking up at the right time
Who exactly sets LPTIM1->CMP for the next wake-up?
Is it vPortSuppressTicksAndSleep() that calculates the required counts and sets CMP so the MCU wakes just before the next expected deadline (software timer expiry, task delay, etc.)?
In other words, is the wake-up time computed automatically by LPTIMTick from the FreeRTOS tick count, or do I need to manually configure LPTIM’s period?
Interaction with my timers
In my design, the software timer triggers sensor reading (via the queue).
Does LPTIMTick guarantee that wake-up happens in time to run the callback exactly at the expected deadline (without noticeable drift)?
GPIO analog mode during sleep
In an other project, I have reduced current draw further by reconfiguring all GPIOs as analog inputs in configPRE_SLEEP_PROCESSING and restoring them in configPOST_SLEEP_PROCESSING.
Would you recommend doing this here as well with LPTIMTick? If yes, should I perform the GPIO reconfiguration inside your vUlpPreSleepProcessing() / vUlpPostSleepProcessing() hooks?
This my supervisor task :
I would really appreciate your help on this, and I’d be very grateful for your feedback. Thank you!
Beta Was this translation helpful? Give feedback.
All reactions