-
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: Incorrect us ticker timestamp after deep sleep #8117
Comments
I might have found the cause of this issue. After waking up from deep sleep mode, the context of us ticker is restored. mbed-os/targets/TARGET_STM/sleep.c Line 215 in d6ccf46
This happens inside Calling Line 138 in d6ccf46
|
The root cause of this issue is mbed-os/targets/TARGET_STM/hal_tick_overrides.c Lines 45 to 69 in d6ccf46
One of possible fixes would be to update the value of the diff --git a/targets/TARGET_STM/sleep.c b/targets/TARGET_STM/sleep.c
index 50759eb..a6e01e6 100644
--- a/targets/TARGET_STM/sleep.c
+++ b/targets/TARGET_STM/sleep.c
@@ -158,6 +158,7 @@ void hal_sleep(void)
}
extern int serial_is_tx_ongoing(void);
+extern int mbed_sdk_inited;
void hal_deepsleep(void)
{
@@ -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;
// Verify Clock Out of Deep Sleep
ForceClockOutofDeepSleep();
@@ -213,6 +215,7 @@ void hal_deepsleep(void)
wait_loop(500);
restore_timer_ctx();
+ mbed_sdk_inited = 1;
// Enable IRQs
core_util_critical_section_exit(); With this patch added, the output from
This might not be the best solution though. @ARMmbed/team-st-mcd, @c1728p9 @0xc0170 could you take a look? |
It is OK for me, thx @fkjagodzinski Please, push the correction, I will check it with many STM32 targets. |
ARM Internal Ref: MBOTRIAGE-1652 |
@jeromecoutant I created PR with a patch I proposed above. |
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
Description
After waking up from deep sleep mode the
ticker_read_us(us_ticker)
returns incorrect value. In fact that value is2**32-1
or2*33-1
bigger than expected.Targets
NUCLEO_F746ZG
,NUCLEO_L476RG
,NUCLEO_F401RE
,NUCLEO_F429ZI
,DISCO_L475VG_IOT01A
Toolchains
GCC_ARM
I don't suspect this issue to be toolchain related. I'll update this list whenever I check other toolchain builds.
Mbed OS SHA
8d9e2e5 -- master
Code
Output
NUCLEO_F746ZG
:NUCLEO_L476RG
:NUCLEO_F429ZI
:Issue request type
[ ] Question
[ ] Enhancement
[X] Bug
The text was updated successfully, but these errors were encountered: