AnsweredAssumed Answered

RTC alarm handler does not want to work

Question asked by kovaliov.nikolaj on Feb 13, 2014
Latest reply on Feb 13, 2014 by sung.chen_chung
Good day,

Like topic said, the alarm handler does not to work, but if I do like this:
while (!RTC_GetITStatus(RTC_IT_ALRA));printf("\nALARM"); //it works

Here is my code: 

int main(void)
{
  NVIC_InitTypeDef  NVIC_InitStructure;
  
  STM_EVAL_PBInit(BUTTON_USER , BUTTON_MODE_EXTI);
  
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);
  STM_EVAL_LEDInit(LED5);
  STM_EVAL_LEDInit(LED6);
    
  /* Turn LED2 ON */
  STM_EVAL_LEDOn(LED3);
  
     DBGU_Init();
         
  RTC_Config();
  
  RTC_TimeShow();
  RTC_AlarmShow();
  
  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);


  while (!RTC_GetITStatus(RTC_IT_ALRA));printf("\nALARM"); //works
  
while(1);
}

and handler:

void RTC_Alarm_IRQHandler(void)
{
  if(RTC_GetITStatus(RTC_IT_ALRA) != RESET)
  {
    STM_EVAL_LEDToggle(LED6);
    RTC_ClearITPendingBit(RTC_IT_ALRA);
    EXTI_ClearITPendingBit(USER_BUTTON_EXTI_LINE);
  } 
}

Outcomes