2020-08-20 05:49 AM
I'm using a Nucleo L152RE.
I've read the 900 pages manual multiple times but I still miss a clear view of what needs to be done to create a RTC Wakeup event.
I read in the manual:
"""
To enable the RTC Wakeup interrupt, the following sequence is required:
1. Configure and enable the EXTI Line 20 in interrupt mode and select the rising edge
sensitivity.
2. Configure and enable the RTC_WKUP IRQ channel in the NVIC.
3. Configure the RTC to generate the RTC wakeup timer event.
"""
But I don't understand what all that means.
Could you translate it for me in terms of operations that need to be done?
All of the three tasks I quoted start with "configure", this is way too vague for me. What does that mean, "configure" ? What needs to be done? I guess some registers, or bits somewhere must be modified. Which ones? How exactly do you "configure" those things?
Maybe all the 3 steps is too much, so, let's start with step 1:
"Configure and enable the EXTI Line 20 in interrupt mode"
What does that mean? What do I do?
"and select the rising edge sensitivity"
What is that? How do I select it?
Just step 1 will do for now.
Please help.
The whole manual is like that.
2020-08-20 06:10 AM
Replying to my own question. Trying to "Configure and enable the EXTI Line 20 in interrupt mode".
In the chapter about EXTI I read:
"""
Hardware interrupt selection
To configure the 24 (or 23 for Cat.1 and Cat.2 devices) lines as interrupt sources, use the following procedure:
• Configure the mask bits of the Interrupt lines (EXTI_IMR)
• Configure the Trigger Selection bits of the Interrupt lines (EXTI_RTSR and EXTI_FTSR)
• Configure the enable and mask bits that control the NVIC IRQ channel mapped to the external interrupt controller (EXTI) so that an interrupt coming from any one of the lines can be correctly acknowledged.
Hardware event selection To configure the 24 (or 23 for Cat.1 and Cat.2 devices) lines as event sources, use the following procedure:
• Configure the mask bits of the Event lines (EXTI_EMR)
• Configure the Trigger Selection bits of the Event lines (EXTI_RTSR and EXTI_FTSR)
Software interrupt/event selection The 24 (or 23 for Cat.1 and Cat.2 devices) lines can be configured as software interrupt/event lines. The following is the procedure to generate a software interrupt.
• Configure the mask bits of the Interrupt/Event lines (EXTI_IMR, EXTI_EMR)
• Set the required bit in the software interrupt register (EXTI_SWIER)
"""
For a RTC Wakeup event, is it hardware or software? I'm gonna guess it's hardware, the RTC clock is a material device, right?
2020-08-20 06:11 AM
Hardware interrupt or hardware event? What is the difference?
2020-08-20 06:12 AM
I'm gonna guess I have to deal with events, since it's called a Wakeup event, right? Still no clue what the difference is but I'm gonna go with that.
2020-08-20 06:19 AM
"Configure the mask bits of the Event lines (EXTI_EMR)"
Difficult to find where that EXTI_EMR register is. It's offset 0x04, but from what, I guess I'm gonna have to skim through a few hundreds pages to find out.
But I seem to understand that, maybe if I set the 20th bit of that thing to 1 that should activate the EXTI Line 20 and maybe that's what they meant by "configuring it".
I wonder if I'm not completely deluding myself here.
2020-08-20 06:22 AM
The following step would be to "Configure the Trigger Selection bits of the Event lines (EXTI_RTSR and EXTI_FTSR)".
Clearly the word "configure" should be banned from these manuals. It doesn't tell what needs to be done at all.
I've read about EXTI_RTSR and EXTI_FTSR but it's all about "rising edges" and I don't know what that is.
2020-08-20 06:29 AM
EXTI_RTSR is offset 0X08, EXTI_FTSR is offset 0x0C, I still don't know from what. Maybe I will manage to find out later.
Now, should I enable the "Rising edge trigger" or not? What about the "Falling edge trigger"?
Still assuming the RTC Wakeup event I'm trying to generate counts as a "Hardware event".
2020-08-20 06:37 AM
Oh, in the manual I found that for the RTC, it's rising edge! Gonna set the 20th bit of EXTI_RTSR (rising edge) to 1 and the 20th bit of EXTI_FTSR (falling edge) to 0.
I hope what I plan to do is making sense.
2020-08-20 06:40 AM
Actually, I think that should settle step 1. I just noticed that this rising edge thing what the second part of step 1.
I just have to figure out where are the registers. They are expressed as an offset from something. But from what? If I manage to find where the registers really are, I should be done with step 1.
2020-08-20 06:50 AM
There's a sub chapter called "10.3 EXTI registers". They start immediately by listing registers and expressing their location as offsets. I hoped that at the beginning of the subsection they would tell the base address you need to add the offsets to, but no.