cancel
Showing results for 
Search instead for 
Did you mean: 

Unexpected Behavior with RTC ALARM_A in LowPoer Mode on STM32WB55

JR2963
Senior II

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. 

 

JR2963_0-1726143734638.png

 

All the relevant registers appear to be configured correctly for the RTC ALARM_A interrupt:

  • The RTC_CR register has the ALRAIE bit (Alarm A interrupt enable) set to 1, so the RTC ALARM_A interrupt is enabled.
  • The EXTI_IMR register has bit 17 set to 1, which means the interrupt for the RTC ALARM is unmasked (enabled).
  • The EXTI_RTSR bit 17 set to 1
  • The interrupt for RTC ALARM is enabled in the NVIC.

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!

 
 
 
 
 
 
 
 
 
 
 
 
 
 
13 REPLIES 13

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.

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:

  1. 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.

  2. 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.

 

@STTwo-32 

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.

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.