2024-09-12 05:42 AM - edited 2024-09-12 11:19 PM
Hello everyone,
I’m working with an STM32WB55 microcontroller with BLE stack. I use also low-power modes in my app. Before entering a low-power mode, I set an RTC ALARM_A to wake the system up at a specific time. The device then enters either Sleep or STOP2 mode with the RTC enabled.
However, I’m noticing an issue where, when in these low-power modes, the RTC ALARM_A does not seem to wake the device as expected. The timing appears to freeze or behave unpredictably, and the alarm sometimes triggers late or not at all.
Here is the output just before entering sleep mode with the configured alarm:
Current time vs Alarm RTC Settings:
(PREDIV_S = maximal SubSec = 32000)
| Field | Current (Cur) | Alarm (Alm) |
|------------|------------|--------|
| SubSec | 7234 | 6594|
| Sec | 21 | 21 |
| Min | 0 | 0 |
| Hr | 0 | 0 |
| Day | 1 | 1 |
| Mon | 1 | 1 |
| Yr | 0 | 0 |
When I pause the execution, I see that the program is halted right after the WFI() instruction. I also see that the current time is much further ahead (by the duration I was stuck), the seconds were already at 25.
All the relevant registers appear to be configured correctly for the RTC ALARM_A interrupt:
Has anyone else encountered similar issues with RTC alarms in these low-power modes? Could there be any configuration or known issue that might cause this behavior?
Any insights or suggestions would be greatly appreciated!
Solved! Go to Solution.
2024-09-16 01:04 AM
Hello @JR2963
on the BLE context, we always recommend using the Timer server based on the RTC for timers that need to run with BLE stack. Also, for the Low Power modes implementations that I've already recommended to you previously. More details on the chapters 4.5 and 4.6 of the AN5289.
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-09-16 03:08 AM
I am aware of the application note AN5289 and I'm using it as a reference. For sleep management, I have used your stm32_lpm_if.c files. The TimerServer with RTC and BLE is used, for example, to stop advertisements, but I haven't seen it used in a way where the entire MCU, along with the BLE stack, would sleep, and only the RTC would wake up the whole system. (However, I haven't explored this in great detail).
What I have been able to find out so far:
The operation of my RTC ALARM_A implementation works for waking up from sleep mode and STOP mode in an empty project where no other peripherals or the BLE stack are active.
The same RTC implementation in a more complex project, where other peripherals are also active, behaves very strangely when waking up from low power mode with the RTC alarm — the alarm is often missed, and the MCU remains in sleep mode.
Given that the problem occurs with or without the BLE stack active, I suspect that some peripherals may be disrupting the alarm's operation in low power modes.
2024-09-16 03:29 AM
For Now, there is not any known issue that may have such effect.
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-09-16 07:22 AM
Finally, I managed to get the code working as I wanted. I can't exactly say what the problem was, but the RTC is now behaving correctly even in low power modes. Thank you.