the PWREN and BKPEN bits in register RCC_APB1ENR to enable the power supply and backup interface clock ● Set the DBP bit of register PWR_CR to enable access to the backup registers and RTC .
Its block diagram is as follows:
1. Prescaler module ( programmable to generate RTC time base TR_CLK up to 1 second )
If the corresponding enable bit is set in RTC_CR, a second interrupt is generated in each TR_CLK cycle
2. Programmable counter
RTC_CNT is accumulated according to the TR_CLK cycle and can be compared with RTC-ALR. If the corresponding enable bit is set in the RTC_CR control register, an alarm clock interrupt will be generated when the comparison is matched .
RTC configuration steps:
1. Enable power clock and backup area clock
2. Cancel the write protection of the backup area
3. Reset the backup area and turn on the external low-speed oscillator
4. Select RTC clock and enable (select external LSE as RTC clock)
5. Set the frequency division of the RTC and configure the RTC clock
6. Update the configuration and set the RTC interrupt grouping
7 Write an interrupt service function