AnsweredAssumed Answered

STM32F4Discovery RTC WakeUp Interrupt

Question asked by william.ben on Aug 17, 2014
Latest reply on Aug 18, 2014 by william.ben
Hello,I'm currently quiet frustratedI'm trying to set up with the RTC wakeUp register an interrupt of 128Hz. For the RTC the LSI is used (I know not very precisely but for current testing propuse its enough)here is my code I use:
void init()
{
    RTC_InitTypeDef RTC_InitStructure;
    EXTI_InitTypeDef  EXTI_InitStructure;
    NVIC_InitTypeDef  NVIC_InitStructure;
 
    /* Enable the PWR clock */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
 
    /* Allow access to RTC */
    PWR_BackupAccessCmd(ENABLE);
 
    /* Enable the LSI OSC */
    RCC_LSICmd(ENABLE);
 
    /* Wait till LSI is ready */
    while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
    {
    }
 
    /* Select the RTC Clock Source */
    RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
 
 
    /* Configure the RTC data register and RTC prescaler */
    RTC_InitStructure.RTC_AsynchPrediv = 0x7F; // prescaler set to optain a 1 Hz signal of the 32kHz LSI
    RTC_InitStructure.RTC_SynchPrediv = 0xFF; // prescaler set to optain a 1 Hz signal of the 32kHz LSI
    RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
 
    /* Check on RTC init */
    if (RTC_Init(&RTC_InitStructure) == ERROR)
    {
        return;
    }
 
    /* Enable the RTC Clock */
    RCC_RTCCLKCmd(ENABLE);
 
    /* Wait for RTC APB registers synchronisation */
    RTC_WaitForSynchro();
 
    RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16);
    RTC_SetWakeUpCounter(0x10);
 
    /* Enable the Wakeup Interrupt */
    RTC_ITConfig(RTC_IT_WUT, ENABLE);
 
    /* Connect EXTI_Line22 to the RTC Wakeup event */
    EXTI_ClearITPendingBit(EXTI_Line22);
    EXTI_InitStructure.EXTI_Line = EXTI_Line22;
    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 Wakeup Interrupt */
    NVIC_InitStructure.NVIC_IRQChannel = RTC_WKUP_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
 
    /* Enable Wakeup Counter */
    RTC_WakeUpCmd(ENABLE);
}
 
void RTC_WKUP_IRQHandler(void)
{
       doSomething();
        // Interrupt Flags loeschen
        RTC_ClearITPendingBit(RTC_IT_WUT);
        EXTI_ClearITPendingBit(EXTI_Line22);
    }
}
I'm using GCC 4.7.3 with the code above the RTC_WKUP_IRQHandler is never calledwhen I put a "RTC_ClearITPendingBit(RTC_IT_WUT);" at the end of
init() my RTC_WKUP_IRQHandler is still never called but the whole programms hangs in "def_irq_handler    RTC_WKUP_IRQHandler" defined in the file startup_stm32f4xx.S I think because the RTC_IT_WUT flag is never cleared

Outcomes