Skip to content

TimedWakeup not working #79

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

Closed
tshcherban opened this issue Sep 2, 2022 · 5 comments · Fixed by #81
Closed

TimedWakeup not working #79

tshcherban opened this issue Sep 2, 2022 · 5 comments · Fixed by #81
Assignees
Labels
bug 🐛 Something isn't working

Comments

@tshcherban
Copy link
Contributor

tshcherban commented Sep 2, 2022

I've tried a very basic example of timed wakeup:

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  LowPower.begin();
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  LowPower.sleep(1000);
  digitalWrite(LED_BUILTIN, LOW);
  LowPower.sleep(1000);
}

And its working wrong. Works as expected on first board power-on, but on subsequent resets via rst button - LED stays on forewer. Also tried deepSleep, shutdown, idle - behavior is the same.
And if i put before LowPower.begin(); call the following snippet:

STM32RTC &rtc = STM32RTC::getInstance();
rtc.begin(true); // note a parameter here - tells RTC library to do a time reset

all works as expected both on first power-on and subsequent resets. (of course shutdown reboots board so LED blinks shortly instead of cycling 1 sec, that im aware of). Not sure, maybe there is some bug in RTC library? or LowPower should care about some additional stuff?
Verified on:
STM32L051C8T6 custom board, basically bare chip with minimum required R/C
STM32L053R8 nucleo-64
STM32F446RE nucleo-64

@tshcherban
Copy link
Contributor Author

tshcherban commented Sep 4, 2022

Update:
TimedWakeup example (idle, sleep and deepSleep functions) works good with Stm32RTC v.1.2.0 (internally marked as 1.1.1 for mistake) from releases page. Will try finding exact commit which brakes functionality.
Update2:
commit cfd98df1d316cff8cb46158e9654acde87b3dc9c from 31.05.2022 PR) breaks idle, sleep and deepSleep functions.
Update3:
shutdown works only with workaround from first comment.

@ABOSTM
Copy link
Contributor

ABOSTM commented Sep 7, 2022

Hi @tshcherban,
I tested example TimedWakeup (deepSleep) on my Nucleo STM32F446RE, and it is working fine, even after reset button is pressed.

Please note that I used latest commit from both libraries:

Can you please test the same ?

@tshcherban
Copy link
Contributor Author

Okay, tested (using latest changes).
That example is ok:

digitalWrite(LED_BUILTIN, HIGH);
LowPower.deepSleep(1000);
digitalWrite(LED_BUILTIN, LOW);
LowPower.deepSleep(1000);

but that - not:

digitalWrite(LED_BUILTIN, HIGH);
LowPower.deepSleep(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
LowPower.shutdown(1000);

LED should be 1s ON 2s OFF, but instead it is 1s ON 1s OFF, so LowPower.shutdown doesnt respect passed time value and reboots CPU immediately.

ABOSTM added a commit to ABOSTM/STM32LowPower that referenced this issue Sep 14, 2022
Fixes stm32duino#79

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
@ABOSTM
Copy link
Contributor

ABOSTM commented Sep 14, 2022

Hi @tshcherban ,
You are right, when LowPower.shutdown() is invoked after LowPower.deepSleep(),
MCU wakes up immediately.
This was due to WakeUp flag that remained set.

I pushed a fix to clear this flag, and it is now working fine on my side:
#81
Feel free to test it on your side.

fpistm pushed a commit that referenced this issue Sep 27, 2022
Fixes #79

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
@tshcherban
Copy link
Contributor Author

Yep, works great. Verified on both STM32F446RE and STM32L053R8. Maybe its time to release a new version of the lib? There's a few bugfixes after 1.2.0

@fpistm fpistm added the bug 🐛 Something isn't working label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants