2021-01-27 11:33 PM
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."
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."
Again, set the DBP at every interrupt interval causes a few seconds delay/day.
There is somebody with the same problem?
Solved! Go to Solution.
2021-01-29 08:01 AM
OK so instead of
RTC->ISR &= ~RTC_ISR_WUTF;
try
RTC->ISR = ~(RTC_ISR_WUTF | RTC_ISR_INIT);
Does it make any difference?
JW
2021-01-29 02:40 AM
any idea ?
2021-01-29 06:59 AM
It sounds like you set RTC->ISR.INIT inadvertently, maybe in some other code you don't show here.
Do you use Cube/HAL?
JW
2021-01-29 07:21 AM
Standard Library register definition I used.
2021-01-29 07:29 AM
I set RTC->ISR Init flag only at the RTC initialization and when I set the calendar, otherwise not.
Thanks for answer.
2021-01-29 08:01 AM
OK so instead of
RTC->ISR &= ~RTC_ISR_WUTF;
try
RTC->ISR = ~(RTC_ISR_WUTF | RTC_ISR_INIT);
Does it make any difference?
JW
2021-01-29 08:52 AM
You are right. I made a mistake at the RTC initilization. I reset the RTC INIT flag after that I locked the RTC registers and the INIT flag was always true.
Starting with your suggestion I could solve my problem (my mistake)
Thank you for your support.
2021-01-30 11:17 PM
I'm sure that your suggestion would have solved my problem because the issue was happened because I left set calendar function with INIT flag set.
And with your suggestion the INIT flag would have been reset.
Thanks.
2021-01-31 04:33 AM
Thanks for coming back with the solution. Glad you got it working.
JW