cancel
Showing results for 
Search instead for 
Did you mean: 

HAL L4 RTC Bug Report

MVeen.1
Associate II

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.

2 REPLIES 2
Sarra.S
ST Employee

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.

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?