AnsweredAssumed Answered

RTC WakeUp Timer interrupt STM32L100

Question asked by Petus on Apr 15, 2015
Latest reply on Apr 18, 2015 by Petus
Hi, I have a problem with interrupt of WakeUp Timer.
Never set flag for WakeUp interrupt. WakeUp timer is on EXTI 20. EXTI of interrupt is set for rising edge and and line 20.  
Can you help me?

Thanks a lot :-)

P.S.: and blinking of LED without interrupt is working.

#include <stddef.h>
#include <stdio.h>
#include "stm32l1xx.h"
#include "stm32l1xx_conf.h"
 
int main (void){
    int i;
 
    //----LED----//
    RCC->AHBENR |= RCC_AHBENR_GPIOCEN; //Povoleni clocku pro port C
    RCC->AHBRSTR |= RCC_AHBRSTR_GPIOCRST;   //reset GPIOC
    RCC->AHBRSTR &= ~RCC_AHBRSTR_GPIOCRST;
    GPIOC->MODER |= GPIO_MODER_MODER9_0 | GPIO_MODER_MODER8_0;
    GPIOC->OSPEEDR |= GPIO_OSPEEDER_OSPEEDR9 | GPIO_OSPEEDER_OSPEEDR8;
    GPIOC->ODR &= ~GPIO_ODR_ODR_9 | GPIO_ODR_ODR_8;
 
    //---EXTI-for WakeUp timer-20--//  
    EXTI->IMR |= EXTI_IMR_MR20; //Line 20 - WakeUp timer
    EXTI->EMR &= ~EXTI_EMR_MR20;
    EXTI->RTSR |= EXTI_RTSR_TR20;   //Rising edge
    EXTI->FTSR &= ~EXTI_FTSR_TR20;
    NVIC->ISER[0] |= (1 << (RTC_WKUP_IRQn & 0x1F));
     
    //---RTC---//
    RCC->APB1ENR |= RCC_APB1ENR_PWREN;  //enable PWR
    RCC->APB1RSTR |= RCC_APB1RSTR_PWRRST;
    RCC->APB1RSTR &= ~RCC_APB1RSTR_PWRRST;
 
    PWR->CR |= PWR_CR_DBP;
 
    //---LSE----//
    RCC->CSR |= RCC_CSR_LSEON;  //LSE on
    while(!(RCC->CSR & RCC_CSR_LSERDY));    //wait for LSERDY  
 
    RCC->CSR |= RCC_CSR_RTCSEL_0;   //LSE clock source
    RCC->CSR |= RCC_CSR_RTCEN;  //enable
 
    //---RTC---//
    RTC->WPR = 0xCA;    //key
    RTC->WPR = 0x53;    //key
    RTC->CR &=~ RTC_CR_WUTE;    //disable WakeUp Timer
    while(!(RTC->ISR & RTC_ISR_WUTWF)); //wait for WUTWF
    RTC->WUTR = 0x1FF;
    RTC->CR |= RTC_CR_WUCKSEL_0;    //RTCCLK/8
    RTC->CR |= RTC_CR_WUTIE;     //enable interrupt
    RTC->CR |= RTC_CR_WUTE; //enable WakeUp Timer
    RTC->WPR = 0xFF;    //key
    while(1){
     
        for(i=0;i<0xAFFF0; i++);
        GPIOC->ODR ^= GPIO_ODR_ODR_8;
         
    }
}
 
/*---Interrupt by WakeUp Timer---*/
void RTC_WKUP_IRQHandler(void)
{
  if(RTC-> ISR & RTC_ISR_WUTF){
        GPIOC->ODR ^= GPIO_ODR_ODR_9;
        RTC->ISR &=(~ RTC_ISR_WUTF);
    }
    EXTI->PR |= EXTI_PR_PR20;  
  return;
}

Outcomes