title: STM32L151 RTC Alarm interrupt
body: <p>I am having problem with RTC alarm interrupt of STM32L151. I want my program to go to RTC alarm interrupt every second but it does not work.
  My main funtion:</p>
  
  <pre><code>int main(void)
  {
    HAL_Init();
    SystemClock_Config();
    MX_GPIO_Init();
    MX_IWDG_Init();
    MX_RTC_Init();
    MX_SPI1_Init();
    MX_USART1_UART_Init();
  
    __HAL_RTC_ALARM_ENABLE_IT(&amp;hrtc, RTC_IT_ALRA);
  
    while (1)
    {
  
    }
  }
  </code></pre>
  
  <p>Function configures RTC: MX_RTC_Init():</p>
  
  <pre><code>void MX_RTC_Init(void)
  {
    RTC_TimeTypeDef sTime;
    RTC_DateTypeDef sDate;
    RTC_AlarmTypeDef sAlarm;
  
    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(&amp;hrtc);
  
    sTime.Hours = 0x14;
    sTime.Minutes = 0;
    sTime.Seconds = 0;
    sTime.TimeFormat = RTC_HOURFORMAT12_AM;
    sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
    sTime.StoreOperation = RTC_STOREOPERATION_RESET;
    HAL_RTC_SetTime(&amp;hrtc, &amp;sTime, FORMAT_BCD);
  
    sDate.WeekDay = RTC_WEEKDAY_WEDNESDAY;
    sDate.Month = RTC_MONTH_AUGUST;
    sDate.Date = 0x24;
    sDate.Year = 0x16;
  
    HAL_RTC_SetDate(&amp;hrtc, &amp;sDate, FORMAT_BCD);
  
      /**Enable the Alarm A 
      */
    sAlarm.AlarmTime.Hours = 0;
    sAlarm.AlarmTime.Minutes = 0;
    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_SECONDS;
    sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;
    sAlarm.AlarmDateWeekDay = 1;
    sAlarm.Alarm = RTC_ALARM_A;
    HAL_RTC_SetAlarm_IT(&amp;hrtc, &amp;sAlarm, FORMAT_BCD);
  
  }
  </code></pre>
  
  <p>I created project using CubeMX. Do you have any idea or advice for me? Thank you</p>