Skip to main content
DavePfz
Associate III
August 20, 2026
Question

Problem with RTC_ALARM_C on STM32WB5MM

  • August 20, 2026
  • 1 reply
  • 9 views

I’m trying to set an alarm occurring on the 5 minute marks. However, after I set the alarm and try to read it back I always get 0 minutes and no interrupts. My code without the error handling is as follows.

	Status = HAL_RTC_GetTime(&hrtc, &sTime, RTC_FORMAT_BIN);

Status = HAL_RTC_DeactivateAlarm(&hrtc, RTC_ALARM_A); // Deactivate before setting

/** Enable the Alarm A
*/
sAlarm.AlarmTime.Minutes = 5 * (((sTime.Minutes + 5) % 60) / 5);
sAlarm.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY | RTC_ALARMMASK_HOURS | RTC_ALARMMASK_SECONDS;
sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_ALL;

sAlarm.Alarm = RTC_ALARM_A;
Status = HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BIN);

What am I missing?

Thanks

1 reply

DavePfz
DavePfzAuthor
Associate III
August 20, 2026

For any who may be looking, this may be of help.

If I follow the SetAlarm routine by an immediate HAL_RTCC_Get_Alarm, I always get a time value of all zeros. It’s as though the write is not allowed. I have traced this through the SetAlarm routine and it doesn’t make sense to me. The values look right but they don’t register. (?)