STM32L1 RTC interrupt using EXTI20 and wake-up from sleep mode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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."
- 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?
Solved! Go to Solution.
- Labels:
-
Power
-
RTC
-
STM32L1 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-29 8: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-29 2:40 AM
any idea ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-29 6: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-29 7:21 AM
Standard Library register definition I used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-29 7:29 AM
I set RTC->ISR Init flag only at the RTC initialization and when I set the calendar, otherwise not.
Thanks for answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-29 8: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-29 8: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-31 4:33 AM
Thanks for coming back with the solution. Glad you got it working.
JW
