cancel
Showing results for 
Search instead for 
Did you mean: 

stm32L151 RTC AlarmA does not work

Raquel ciordia
Associate

We have tried to set an rtc alarm interruption but it does not work. We can see in ​debuuger in the system viewer that the alarm has been configured. But when it comes to see the alarm interruption we see that it does not occur.

See bellow the code for the alarm set up:

 RTC_TimeTypeDef sTime;

 RTC_DateTypeDef sDate;

 RTC_AlarmTypeDef sAlarm;

   /**Initialize RTC and set the Time and Date

   */

 hrtc.Instance = RTC;

 hrtc.Init.HourFormat = RTC_HOURFORMAT_24;

 hrtc.Init.AsynchPrediv = 127;

 hrtc.Init.SynchPrediv = 255;

 hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;

 hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;

 hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;

 HAL_RTC_Init(&hrtc);

 sTime.Hours = 0;

 sTime.Minutes = 1;

 sTime.Seconds = 0;

 sTime.TimeFormat = RTC_HOURFORMAT12_AM;

 sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;

 sTime.StoreOperation = RTC_STOREOPERATION_RESET;

 HAL_RTC_SetTime(&hrtc, &sTime, FORMAT_BCD);

 sDate.WeekDay = RTC_WEEKDAY_MONDAY;

 sDate.Month = RTC_MONTH_JANUARY;

 sDate.Date = 1;

 sDate.Year = 0;

 HAL_RTC_SetDate(&hrtc, &sDate, FORMAT_BCD);

   /**Enable the Alarm A

   */

 sAlarm.AlarmTime.Hours = 0;

 sAlarm.AlarmTime.Minutes = 2;

 sAlarm.AlarmTime.Seconds = 0;

 sAlarm.AlarmTime.TimeFormat = RTC_HOURFORMAT12_AM;

 sAlarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;

 sAlarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET;

 sAlarm.AlarmMask =RTC_ALARMMASK_ALL; //RTC_ALARMMASK_NONE;

 sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_WEEKDAY;

 sAlarm.AlarmDateWeekDay = 1;

 sAlarm.Alarm = RTC_ALARM_A;

 HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, FORMAT_BCD);

/*Then we have the IRQ alarm handler */

void RTC_Alarm_IRQHandler(void)

{

{

       HAL_RTC_AlarmIRQHandler(&hrtc);

}

We do not know the reason why this code is not working. This code has been generated with MXCube.

Thanks in advance for the help.

0 REPLIES 0