cancel
Showing results for 
Search instead for 
Did you mean: 

RTC Periodic Wakeup only ocurs once

Barber.Mark
Associate III

I am using the STM32L433 RTC in periodic wakeup. i have initialised the rtc and it does interrupt once, but never interrupts again. i suspect the ISR rouitne is not clearing a flag some where. i have seen many comments relating to this but no definitive information on the reason or a solution.

The ISR clears the EXTI pending interrupt and the RTC wake up flag.

   // clear wake up time flag

   RTC->ISR&=~(RTC_ISR_WUTF);

   // clear int flag and exit

   EXTI->PR1|=EXTI_PR1_PIF20;

Any suggestions appreciated.

6 REPLIES 6
Selim Sagir
Associate III

I came up with same problem and reason was an interrupt have calling another interrupt.

Barber.Mark
Associate III

Yes i have multiple interruprts servicing many different peripherals. will explore this option. thanks.

mckenney
Senior

>   RTC->ISR&=~(RTC_ISR_WUTF);

That looks like a minus sign, not a tilde. I don't think that's clearing what you want.

Selim Sagir
Associate III

You can check flags on IDE.

turboscrew
Senior III

Don't confuse between interrupt and wakeup. Check the PWR flags too. Note that in most STM devices one register contains the flag and it's cleared using another register.

Barber.Mark
Associate III

Hi,

Thanks to all for the help i managed to solve the problem, as it generally is once discovered was simple.

in order to write to the ISR register the register needs to be write enabled.

the DBP bit in the PWR->CR1 register need to be set.

this code in the ISR works

   // set up DBP bit in PWR_CR1 to allow write to RTC registers

   PWR->CR1|=PWR_CR1_DBP;

   // clear int flag and exit

   EXTI->PR1|=EXTI_PR1_PIF20;

   // clear wake up time flag

   RTC->ISR&=~RTC_ISR_WUTF;

   // disable write to RTC registers

   PWR->CR1&=~PWR_CR1_DBP;         // disable write to RTC registers