stm32duino / STM32LowPower

Arduino Low Power library for STM32
183 stars 52 forks source link

deepSleep() wakes up before alarm timeouts #63

Closed niag-IDSI closed 2 years ago

niag-IDSI commented 2 years ago

I'm trying to put the STM32 into deep sleep for an hour by using deepSleep(60x60x1000) but I see that the MCU wakes up much earlier (perhaps after 20 or 30 seconds).

All I'm doing in my code is to use the basic functionality shown in the TimedWakeup example, so I call begin() in setup() and then call deepSleep() in the loop().

I must also say that I use three serial interfaces in total, one for debuging, one hardware serial and one software serial. My suspicion is that one of those is causing the MCU to go out of sleep.

Is there a way to only enable waking up from RTC?

I have also seen the example AlarmTimedWakeup, which seems to do something similar but in a different way. There is no explanation why this is different. Is that the best way to use in my case?

niag-IDSI commented 2 years ago

I understand that this might be related to #25

But then this is very confusing. If I don't attach the UART in the interrupt sources (with the library's API), why does it wake up from it?

niag-IDSI commented 2 years ago

I must apologize, this is not a real issue. The real problem was my carelessness (used variable with less bits than necessary)....