STM32F407 RTC configuration understanding and summary

Publisher:化羽2015Latest update time:2017-09-11 Source: eefocusKeywords:STM32F407  RTC  configuration Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

RTC: Real time clock

           In comparison, the RTC of STM32F407 is easier to configure than that of STM32F1. Of course, the resources of F4 are much richer. For specific resources, please refer to the official reference manual. You can also understand its general functions through the following chart 

              



    1. I didn't understand the function of ALRAM A/B at first, but I found it very simple when I looked at it later. For example, the alarm clock can also realize the function of the alarm clock. This is just a simple example to illustrate the purpose or function of ALARM A/B.

    2. Automatic wake-up, timestamp and time tampering events are similar to 1. You will know it after careful experience.

   3. RTC_AFO and RTC_AFI are used to output and detect external time events.

  4. In general, the clock source of RTC uses LSE to generate a 1HZ clock through appropriate frequency division. There are two key points in the frequency division, namely the asynchronous frequency division factor (7bit) and the synchronous frequency division factor (15bit). The configuration of the two will affect the power consumption. The official recommendation is to configure the asynchronous frequency division factor to a higher value to reduce power consumption. The maximum value configuration is used here: SynchPrediv = 0xFF; AsynchPrediv = 0x7F; In this way, the clock is configured OK

                 

   5. Let's take a look at the initialization and configuration of RTC. I think as long as you understand it here, you will understand RTC. As for automatic wake-up, ALARM, etc., they are all very easy to configure. What's more, the ST library functions have been written, so you can directly call the relevant functions.

     1) First of all, we need to know that the RTC register has a write protection function, so before each write operation, we must first exit the write protection. Here we are told very directly that we should follow this order to write 0xCA and 0x53 to RTC_WPR respectively to release the write protection. Note that the order cannot be changed. Below it, there is another sentence, write a wrong key to reactivate the write protection, that is, write a different key from the above two to reactivate the write protection function

       

  6. I will not explain how to set specific values. The RTC_SetTime() /RTC_SetDate() and other functions in the official library can be easily implemented.

  7. Finally, let's take a look at the backup register of RTC. The backup register is used for backup as its name implies. There are 20 related registers in total. A simple example can help you understand its function. For example, if we want to initialize the relevant values ​​of RTC, I set it once for the first time. When I reset the MCU, RTC is still running normally. I don't need to reset RTC. At this time, we can add a judgment condition when setting RTC, that is, if I fill a value in the backup register I choose, if my unique value is consistent with the value I want to write, I will not reset RTC. If not, I will reset it. Of course, this value is set arbitrarily.

For example, in the official example: if (RTC_ReadBackupRegister(RTC_BKP_DR0) != 0x32F2) // Check whether the read value is consistent with the setting

                               {

                                      . . . .

                                     RTC_WriteBackupRegister(RTC_BKP_DR0, 0x32F2); //After the setting is completed, write a value to the backup register        

               }

   8. So far, the introduction is over. It is still mainly to read the reference manual. Of course, the official library has saved a lot of functions for everyone, but it is also necessary to understand how to operate from the register level.


Keywords:STM32F407  RTC  configuration Reference address:STM32F407 RTC configuration understanding and summary

Previous article:The single chip microcomputer uses the RLE algorithm to realize the LCD screen display picture
Next article:How to use stm32 to write IAP bootloader and APP

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号