AnsweredAssumed Answered

STM32L152 RTC periodic wakeup

Question asked by Mat on Nov 5, 2013
Latest reply on Nov 5, 2013 by Mat
Hi all,

I'm quite new with STM32 and I'm trying to set up the RTC module to raise a periodic wake-up interrupt every second (using LSI).

The configuration seems to be working, the interrupt is effectively raised, but the firmware is blocked inside the library function "RTC_GetITStatus" and loops inside it.
The code in that moment is running with Interrupt "priviledges" and the result is that the whole firmware is "bloked".

This is the code I'm using... can anybody tell-me how to unlock the situation?

void RTC_Config()
     NVIC_InitTypeDef NVIC_InitStructure;
     EXTI_InitTypeDef EXTI_InitStructure;     
     /* Enable the PWR clock */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

  /* Allow access to RTC */
  /* Enable the LSI OSC */ 
  RCC_LSICmd(ENABLE);                    // The RTC Clock may varies due to LSI frequency dispersion

  /* Wait till LSI is ready */  
  while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET);

  /* Select the RTC Clock Source */
     /* Enable the RTC Clock */

  /* Wait for RTC APB registers synchronisation */
     /* EXTI configuration *******************************************************/
  EXTI_InitStructure.EXTI_Line = EXTI_Line20;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
     // Configuring RTC_WakeUp interrupt
  NVIC_InitStructure.NVIC_IRQChannel = RTC_WKUP_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
     // RTC Wakeup Configuration
     // RTC Set WakeUp Counter
     // Enabling RTC_WakeUp interrupt
     // Disabling Alarm Flags
     RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
     RTC_AlarmCmd(RTC_Alarm_B, DISABLE);
     // RTC Enable the Wakeup Function


void RTC_WKUP_IRQHandler(void)
     if(RTC_GetITStatus(RTC_IT_WUT) != RESET)
          GPIO_ToggleBits(LD4_GPIO_PORT, LD4_PIN);


Thanks a lot!