AnsweredAssumed Answered

STM32 RTC Alarm Not configuring

Question asked by Manjunatha S on Jun 26, 2014
Latest reply on Nov 24, 2014 by Manjunatha S
Hi,
I am using STM32l151vbt6 MCU and I am trying to configure RTC Alarm for ever 15th minute that is 0, 15, 30 and 45th minute of the every hour. I can configure the Alarm and it will work for the first time, If  I try to set it again after the alarm occurs, it would set to previous alarm state. If i reset the MCU i can set the alarm and it will wake the controller from the stop mode when the alarm occurs, Please let me know how can i set the next alarm without resetting the MCU.

Alarm Configure Code:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
     /* 8(hour) and 19(day) are masked and there is no effect on the alarm */
     RTC_AlarmTypeDef     RTC_AlarmStructure =
     {
          0,
          0,
          0,
          RTC_H12_AM,
          (RTC_AlarmMask_DateWeekDay | RTC_AlarmMask_Hours),
          RTC_AlarmDateWeekDaySel_Date,
          19
     };
     const uint32_t          alarm_interval[4] = { 15, 30, 45, 0 };
     /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/


     RTC_Read();
     RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes = alarm_interval[RTC_current_time.minute / 15];
     RTC_Alarm_Config(&RTC_AlarmStructure);

void RTC_Alarm_Config(RTC_AlarmTypeDef *RTC_AlarmStructure)
{
     /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
     EXTI_InitTypeDef     EXTI_InitStructure;
     NVIC_InitTypeDef     NVIC_InitStructure;
     /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/


     RTC_AlarmCmd(RTC_Alarm_A, DISABLE);


     /* EXTI configuration */
     EXTI_ClearITPendingBit(EXTI_Line17);
     EXTI_InitStructure.EXTI_Line = EXTI_Line17;
     EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
     EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
     EXTI_InitStructure.EXTI_LineCmd = ENABLE;
     EXTI_Init(&EXTI_InitStructure);


     /* Enable the RTC Alarm Interrupt */
     NVIC_InitStructure.NVIC_IRQChannel = RTC_Alarm_IRQn;
     NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
     NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
     NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
     NVIC_Init(&NVIC_InitStructure);
     RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, RTC_AlarmStructure);


     /* Clear RTC AlarmA Flags */
     RTC_ClearITPendingBit(RTC_IT_ALRA);
     
     /* Enable AlarmA interrupt */
     RTC_ITConfig(RTC_IT_ALRA, ENABLE);


     /* Enable the alarmA */
     RTC_AlarmCmd(RTC_Alarm_A, ENABLE);
}


Alarm ISR:

 EXTI_ClearITPendingBit(EXTI_Line17);
     
      if(RTC_GetITStatus(RTC_IT_ALRA) != RESET)
       {
         /* Clear RTC AlarmA Flags */
            RTC_ClearITPendingBit(RTC_IT_ALRA);
         
       }

Outcomes