-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to Achieve Long Periods of Deep Sleep on STM32 #7156
Comments
cc @ARMmbed/team-st-mcd |
Related issue #6081 |
ARM Internal Ref: MBOTRIAGE-581 |
That is correct. For longer periods, we shall consider an enhancement to the current solution. What I did not understand was the difference between The question is, how to achieve the longest sleep with the current solution we have, what are limitations for STM32L4 (or is this generic to any mbed target, no further limitation from target implementation) ? |
I think that is the question I'm asking! The related issue asks for a shutdown mode. I'm not bothered about selecting the shutdown low-power mode. As I understand it, |
I second needing an answer to this question. We also want deep sleep for days at a time. |
Same here. Looking for extended deep sleep on STM32F1. Hoping to use LowPowerTicker on PlatformIO with mbed , which I understand is an additional complication. |
As no one who really understands has taken the bait so I'll make a couple of comments and see if it leads anywhere. My guess is there is some balancing of power vs accuracy. If we want to sleep for longer the wake-up is likely to be less accurate. Someone in the Med or ST teams has tried to a create a general solution that is a reasonable compromise.
AFAICT, when both LPTIM1 and RTC are both available LPTIM1 is preferred. I assume this is because it provides better accuracy than the RTC although the RTC can create events over hours. Is this correct? If so what is the difference in accuracy? How far in the future can an RTC event be created? |
This was effectively a cross-post of a https://os.mbed.com question, deepsleep - LPTIM1 Vs RTC on STM32?, and I've just had an answer there. In summary, because the LPTIM1 is only 16-bit on the STM32L4 it is necessary to use the RTC. I haven't looked to see if other STM32 devices have a wider LPTIM1. I'm going to post to deepsleep - LPTIM1 Vs RTC on STM32? again and I'll close this issue once I think I understand! |
Hi @mattbrown015 and all I am going to try to answer few questions about LPTIM versus RTC...
LPTICKER configuration:
RAM/FLASH :
Execution time:
I let you make the conclusion... |
About TICKLESS, goal is of course to enable it for all STM32 as soon it is possible. |
About long period of deep sleep, our advice would be to use the RTC alarm feature. |
Hi @naveenkaje and @jeromecoutant, I feel bad about cross posting but thanks to both your efforts I believe I understand better now. From your advice it is now my belief that In future I will stick to asking questions here, it feels to me that questions on the Mbed forum get less attention. Thanks, Matt |
using LPTIM = 32768Hz and prescalar as 128 we can further reduce the clock right? |
See https://os.mbed.com/docs/v5.10/porting/low-power-ticker.html |
Hi @jeromecoutant, I'm looking at my sleep time again! After instrumenting This surprised me because your comment above made me think it could stay in deepsleep for hours:
After a bit of investigation I realised that you're using the STM32L4 auto wake-up counter, aka 'wake-up timer', see (As you know) This is a 16-bit down-counter providing a maximum interrupt period of 32 s. You're using RTC clock divided by 4 hence the maximum deepsleep period of 8 s. In #8778 you've made it possible to configure the LPTIM clock divider and say that selecting 4 gives a deepsleep time of about 8 s. I assume making the divider bigger is not an option because it is not accurate enough(?). All this means I'm no longer sure what the correct approach is. If the maximum deepsleep time is that same for the RTC and LPTIM I guessing it's better to use the LPTIM(?). On Monday I'll try switching back to the LPTIM and see what happens. |
Hi @mattbrown015 |
Ah, yes, that looks better! :-) I will actually try it later. Let's see if I now understand correctly... Fundamentally the longest possible deepsleep when using the RTC wake-up timer on STM32L4 is 32s. Theoretically it could be possible to deepsleep for longer using the RTC programmable alarms but this would not work with Mbed OS because they don't tick with the required accuracy. #8777 chooses the RTC clock divider based on the expected length of sleep. This should balance sleeping for as long as possible with maintaining the tick accuracy. 👍 Once #8777 is tested and merged the RTC will provide an advantage over the LPTIM because we'll get a 32s deepsleep instead of 8s |
Description
I'm working on a battery a powered application and therefore power consumption is very important. Our board is based on a STM32L4.
I'm looking for a better description and/or an example of how to use Mbed OS with long periods of deep sleep because our application may may go hours or even days with nothing to do.
I've defined
MBED_TICKLESS
and I can seedeepsleep()
being called.If I leave
MBED_CONF_TARGET_LOWPOWERTIMER_LPTIM
as 1 it appears we wake up every few seconds even if the wait is much longer. I'm guessing this is because the maximum timeout of LPTIM1 is only a few seconds.I changed
MBED_CONF_TARGET_LOWPOWERTIMER_LPTIM
to 0 and I can see this changes the behaviour but I've no understanding of the ramifications. Is this the correct approach?Any thoughts greatly appreciated.
I last updated my mbed-os clone on 22 May 18:
Issue request type
[X] Question
[ ] Enhancement
[ ] Bug
The text was updated successfully, but these errors were encountered: