Skip to main content
JR2963
Senior II
September 12, 2024
Solved

Unexpected Behavior with RTC ALARM_A in LowPoer Mode on STM32WB55

  • September 12, 2024
  • 2 replies
  • 2553 views

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!

 
 
 
 
 
 
 
 
 
 
 
 
 
 
Best answer by JR2963

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.

2 replies

STTwo-32
Technical Moderator
September 12, 2024

Hello @JR2963 

I think that one of the RTC errata on the ES0394 can be the reason behind that (specially the number 2.12.1).

Best Regards.

STTwo-32

JR2963
JR2963Author
Senior II
September 13, 2024

 @STTwo-32  @waclawek.jan  @Piranha I studied ES0394, and I think this is not my problem. The situation described there warns about shared EXTI lines. However, I have only activated ALARM_A, and even then, the hazard would occur very rarely. In my case, however, it happens in the vast majority of the set alarms.

From the data I wrote, it's clear that ALARM A should have already occurred, but no IRQ was triggered. It's as if the alarm wasn't activated. When stopped in debug, ALRAF is not set either!

STTwo-32
Technical Moderator
September 13, 2024

Hello @JR2963 

Are you facing the same issue will the BLE stack is not activated?

Best Regards.

STTwo-32

JR2963
JR2963Author
Senior II
September 13, 2024

I tried disabling all initialization related to the BLE stack and radio, and the behavior is the same.

STTwo-32
Technical Moderator
September 13, 2024

Could you share a firmware that reproduce the issue (with and without BLE stack if possible).

Best Regards.

STTwo-32