Skip to main content
Explorer
March 12, 2025
Question

HAL L4 RTC Bug Report

  • March 12, 2025
  • 1 reply
  • 982 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.

    1 reply

    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

     

    MVeen.1Author
    Explorer
    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?