AnsweredAssumed Answered

Can not make two alarms work in STM32F429i_Disco

Question asked by li.linda.001 on Mar 5, 2015
Latest reply on Mar 6, 2015 by Clive One
Dear Sir/Miss,

I need 2 alarms, I only can get one alarm work thought Canlandar module, but if make code for alarm A and B, none of them works. Here is my code:
**********
RTC_TimeTypeDef   RTC_TimeStructure;
RTC_AlarmTypeDef  RTC_AlarmStructure;
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
sec    =  RTC_TimeStructure.RTC_Seconds;
min    =  RTC_TimeStructure.RTC_Minutes;
hour   =  RTC_TimeStructure.RTC_Hours;
    
            Alarm_Init();
            /*  Alarm A */
            RTC_GetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);
            RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
            /* Disable the RTC Alarm A Interrupt */
            RTC_ITConfig(RTC_IT_ALRA, DISABLE);

            RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds = (sec+0X01);
            RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes = (min+0X01);
            RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours = (hour+0X00);
            RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;
            RTC_AlarmStructure.RTC_AlarmDateWeekDay = day;
            RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);

            /* Enable the RTC Alarm A Interrupt */
            RTC_ITConfig(RTC_IT_ALRA, ENABLE);

            /* Enable the alarm  A */
            RTC_AlarmCmd(RTC_Alarm_A, ENABLE);

            /*  Alarm B */
            RTC_GetAlarm(RTC_Format_BIN, RTC_Alarm_B, &RTC_AlarmStructure);
            RTC_AlarmCmd(RTC_Alarm_B, DISABLE);
            /* Disable the RTC Alarm B Interrupt */
            RTC_ITConfig(RTC_IT_ALRB, DISABLE);
            RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds = (sec+0X01);
            RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes = (min+0X00);
            RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours = (hour+0X00);
            RTC_AlarmStructure.RTC_AlarmDateWeekDaySel =    RTC_AlarmDateWeekDaySel_Date;
            RTC_AlarmStructure.RTC_AlarmDateWeekDay = day;
            RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_B, &RTC_AlarmStructure);

            /* Enable the RTC Alarm B Interrupt */
            RTC_ITConfig(RTC_IT_ALRB, ENABLE);
            /* Enable the alarm  B */
            RTC_AlarmCmd(RTC_Alarm_B, ENABLE);
*****************
void RTC_Alarm_IRQHandler(void)
{
  /* Clear the EXTIL line 17 */
  EXTI_ClearITPendingBit(EXTI_Line17);

  /* Check on the AlarmA falg and on the number of interrupts per Second (60*8) */
  if (RTC_GetITStatus(RTC_IT_ALRA) != RESET)
  {
//    STM_EVAL_LEDOn(LED4);
    alarm_now2 = 0;
    /* Clear RTC AlarmA Flags */
    RTC_ClearITPendingBit(RTC_IT_ALRA);
    RTC_HandlerFlag = ENABLE;
  }
    if (RTC_GetITStatus(RTC_IT_ALRB) != RESET)
  {
//    STM_EVAL_LEDOn(LED4);
     alarm_now = 0;
    /* Clear RTC AlarmA Flags */
    RTC_ClearITPendingBit(RTC_IT_ALRB);
    RTC_HandlerFlag = ENABLE;
  }
}
~~~~~~~~~~~~~~~~~~~~~~
Please help
Thanks

Outcomes