Skip to main content
MVeen.1
Associate II
March 12, 2025
Question

HAL L4 RTC Bug Report

  • March 12, 2025
  • 2 replies
  • 1005 views

I'm currently using a STM32L433RCT3 and the L4 HAL library. My goal was to read back a configured RTC alarm, increment it, and restart the alarm. I created a:

RTC_AlarmTypeDef sAlarm;
I read back the RTC alarm using,

HAL_RTC_GetAlarm(&hrtc,&sAlarm,RTC_ALARM_A,RTC_FORMAT_BIN);

I set the RTC alarm again using,
HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BIN);

Setting the alarm fails due to,
assert_param(IS_RTC_ALARM_SUB_SECOND_MASK(sAlarm->AlarmSubSecondMask));

If I don't initialize the sAlarm to {0}, the AlarmSubSecondMask is undefined and the HAL_RTC_SetAlarm() may fail. It seems like the HAL_RTC_GetAlarm() should also be retrieving & setting the AlarmSubSecondMask as well.

This topic has been closed for replies.

2 replies

ST Employee
March 13, 2025

Hello @MVeen.1

Try first initializing the RTC_AlarmTypeDef structure to {0} and before setting the new alarm configuration, ensure the AlarmSubSecondMask is set correctly 

sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_NONE; // Adjust as needed

 

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.
MVeen.1
MVeen.1Author
Associate II
March 13, 2025

Hi @Sarra.S ,

I understand that is a workaround, but I'm wondering if HAL_RTC_GetAlarm() should be also setting AlarmSubSecondMask? Is it a bug or a feature?