-
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
nrf52 power regression using wait_ms #7763
Comments
copying @MarceloSalazar @marcuschangarm |
It seems that calling wait_ms even once is enough to cause the extra current draw. It looks like this is due to the call to ticker_read and presumably then firing up the ticker via mbed_ticker_api/initialize. I'm not sure what has changed in this area - is mbed now using some hungry internal clock or has the default frequency been increased. The use of a 1MHz default doesn't seem like a terribly low-power option. |
Just checked and the older (low power) firmware also uses 1MHz. I notice the RF52 us_ticker code has been substantially reworked but I can't spot any obvious breakages. I've confirmed that nrf_timer_task_trigger(NRF_TIMER1, NRF_TIMER_TASK_STOP/START) in hal_deepsleep are actually being called. I've also rebuild with release profile just in case there's some #ifdef somewhere I haven't spotted. |
Adding @mprse since he also seems to have touched this recently! :-) |
@NeilMacMullen deepsleep is prevented by the wait API: mbed-os/platform/mbed_wait_api_rtos.cpp Lines 42 to 47 in 2a824a1
In other words, the 1MHz clock is enabled by It would be nice if [Mirrored to Jira] |
@pan Unless I'm missing something, build 5.8.x also used the 1MHz clock but didn't suffer from the excess power consumption. The code you're referencing looks like it was also present in 5.8.x. It looks like there is an attempt to force the ticker into lower power in the new code but this apparently wasn't required in 5.8.x mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/sleep.c Lines 88 to 100 in 2a824a1
[Mirrored to Jira] |
@NeilMacMullen I'm just pointing out that given how That would be interesting to run a git bisect between the two revisions you indicated to find what changed codewise. |
Ok - from my reading of the changes, d6b7367 appears to have switched the us_ticker implementation away from the 32kHz clock and onto the high resolution timer with a corresponding increase in power consumption. The previous implementation was called us_ticker but actually used the RTC. There is also an lp_ticker implementation but no apparent way of configuring the wait_api to use the low-power implementation rather than the high-power one. Perhaps @mprse can comment since he made the changes? |
It looks like the lp_ticker can be used instead of the us_ticker with the following changes. I'm not sure if this is the intended use of DEVICE_LPTICKER but it seems to do the right thing on RF52
[Mirrored to Jira] |
Unfortunately my workaround appears to do nasty things to the rtc clock tracking. Here's the output of the application as it is simply running wait_ms(1000) in a loop and printing out 'time' every 60 seconds or so.... As you can see, time is rolling backwards at certain points. I need to double check but it looks like this is happening approx. every 35 minutes which just happens to be (1<<31) microseconds.
[Mirrored to Jira] |
It seems the behaviour described above (35 minute "slippage") is not caused by my workaround since I also see it after reverting the changes. It and other issues are present on the official 5.9.4 release. See #7804 |
@NeilMacMullen I think the "slippage" you are observing is addressed with this PR: #7850. [Mirrored to Jira] |
Thanks ralph - looking at your PR I think that's entirely consistent with what I was seeing, Unfortunately I will be on vacation for the next couple of weeks but we've managed to deploy with a combination of my LP_ticker changes above and adding the RTC feature as you suggested which appear to work well in combination. Really appreciate your help on this - I should be able to check out the "proper" fixes in a couple of weeks. |
Sorry guys. I was out of office. So in the previous version both us ticker and lp ticker were implemented based on RTC on NRF boards. This has been changed and now us ticker is based on 1 MHz counter. This is probably causing the extra power consumption when Please see the following part of the documentation:
I think that this is a good idea:
[Mirrored to Jira] |
@NeilMacMullen Please note that our OS team is addressing this issue here #8189. [Mirrored to Jira] |
Internal Jira reference: https://jira.arm.com/browse/IOTDEV-1602 |
@mprse I'm not sure if you are suggesting that the 400uA can't be avoided at all now that the 1MHz ticker is being used or that it can be avoided (but currently isn't) when waiting for an integral number of milliseconds? The change that claims to address this (#8189) does not seem to result in lower power in the second case. On the off-chance this is by-design rather than a bug, I'd suggest we need a configuration flag to allow a switch back to the old behaviour (using the RTC) for those people (most I expect) who would prefer low power at the expense of true microsecond accuracy. |
Hi @NeilMacMullen , since it's now a far-away Mbed OS version from the issue reported, and it seems it's already addressed, do you still need help on this issue? Thanks. |
no - I think this one can be closed. |
Somewhere between commits 1863400 (5.8?) and 485bdee (5.9.4 RC) there has been a regression in the behaviour of wait_ms.
When tested on our nRF52 based board....
When entering a "while (true) wait_ms(1000);" loop out board consumes >400uA.
When this is replaced with "while (true) Thread::wait(1000)" idle power is reduced to ~4uA.
(In both cases, the code is called directly from main and no threads have been explicitly created.)
Compiler is GCC_ARM
My understanding was that wait_ms was the preferred alternative to Thread::wait ?
The text was updated successfully, but these errors were encountered: