-
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
STM: Fix us_ticker timestamp after deep sleep #8136
STM: Fix us_ticker timestamp after deep sleep #8136
Conversation
@bcostm FYI CI tests started |
targets/TARGET_STM/sleep.c
Outdated
@@ -199,6 +200,7 @@ void hal_deepsleep(void) | |||
#else /* TARGET_STM32L4 */ | |||
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); | |||
#endif /* TARGET_STM32L4 */ | |||
mbed_sdk_inited = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind to add a comment explaining why we do this here (copy your PR description for example) ? For future reference... Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that. 😉 Comments added as requested.
Use the `mbed_sdk_inited` flag to correct the `HAL_GetTick()` behavior after waking up from deep sleep mode. `ticker_read_us()` must not be used to read us_ticker timestamp after waking up until the us_ticker context is restored. More detailed description in issue ARMmbed#8117. Fixes ARMmbed#8117
09c365c
to
6821556
Compare
@@ -200,6 +201,10 @@ void hal_deepsleep(void) | |||
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); | |||
#endif /* TARGET_STM32L4 */ | |||
|
|||
/* Prevent HAL_GetTick() from using ticker_read_us() to read the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about moving restore_timer_ctx(); at this stage so that HAL_GetTick can be called in the next functions ?
Have you tried this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following functions:
ForceClockOutofDeepSleep()
,SetSysClock()
,restore_timer_ctx()
,
have to be called in that order. If the timer context was restored earlier, it would have been reset anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok good point indeed. will approve as it is
Starting the build as oldest needs: CI PR depends on this fix /morph build |
Build : SUCCESSBuild number : 3086 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2696 |
Pausing Test CI (it was still in queue, not running) for now. Will restart later today. |
/morph test |
Test : SUCCESSBuild number : 2889 |
Description
Use the
mbed_sdk_inited
flag to correct theHAL_GetTick()
behaviorafter waking up from deep sleep mode.
ticker_read_us()
must not beused to read us_ticker timestamp after waking up until the us_ticker
context is restored. More detailed description in issue #8117.
Fixes #8117
CC @jeromecoutant @c1728p9 @jamesbeyond @maciejbocianski
Pull request type