STM32L1 RTC interrupt using EXTI20 and wake-up from sleep mode
I programmed the STM32L151RET6 to gives the RTC interrupt using line EXTI20. The system is waking-up from sleep mode at every second, it execute a small code and left the interrupt.
For example:
void RTC_IRQ_Handler(void)
{
// { my code here }
//
PWR->CR |= PWR_CR_DBP;
//
RTC->ISR &= ~RTC_ISR_WUTF;
//
PWR->CR &= ~PWR_CR_DBP;
//
EXTI_ClearPendingExti20();
}
The interrup is working but I have few seconds delay/day.
The flag RTC_ISR_WUTF can be erase only if the flag PWR_CR_DBP is set before.
The RTC clock is working well if I don't use the interrupt.
If I let always the flag PWR_CR_DBP set, the interrupt is executed but the RTC clock is stoped. THe date and time are freeze.
If the flag RTC_ISR_WUTF is not reset inside of interrupt routine the interrupt is executed only once (it's normal).
The RTC clock which I used is LSE.
I thing that when DBP bit is set the RTC clock is stopped and this is the cause of the delay.
It is possible to reset the WUTF without to set before DBP?
In the reference manual there is an information like this:
"This register is write protected (except for RTC_ISR[13:8] bits). The write access procedure is described in RTC register write protection on page 514."
- normally the WUTF have to be erase without set DBP before
but at the procedure to access RTC I found the information:
"RTC register write protection
After system reset, the RTC registers are protected against parasitic write access with the DBP bit of the PWR power control register (PWR_CR). The DBP bit must be set to enable RTC registers write access."
- so I understand that the DBP has to be set to access the RTC register, mandatory
Again, set the DBP at every interrupt interval causes a few seconds delay/day.
There is somebody with the same problem?
