Use of the 7.RTC class "Allwinner ClassA20 class Library Analysis"

Source: Internet
Author: User

This sectionto is about the use of the RTC class, please download the ClassA20 Class library in https://github.com/tjCFeng/ClassA20 first.

RTC, real-time clock control, if there is a backup battery exists, then the system shutdown after the power outage time is not lost, and still walking. After power-on can read the current value directly, and set to the system time, which is often used in embedded development of things. However, due to the involvement of the network, in order to save costs, generally also use the network time synchronization function and ignore the RTC. However, it may be used in some situations.

RTC is generally divided into two parts: one is the date and time of the set and read, the second is the alarm set and interrupt response. However, there is no interruption, so the alarm function is not added.

RTC Self-contained, no longer need to connect to other external devices to show, so this section is fully implemented by the program to use the process. However, due to the power management of banana pie may have some small problems, resulting in a power outage backup battery quickly, so I am currently trying to achieve the result of only the backup battery charging, and set the time value again after the shutdown is still unable to read the correct time, so this is only as a reference, if you really need to use the power off, Or add a chip to it.

or first open Rtc.pas to see the class:


There is only one RTC unit in the system, so it is a singleton class, and it is now only used to set and read the time value, only the DateTime attribute in the last public is sufficient.

This datetime is a TYMDHNSW type, TYMDHNSW is a struct, for convenience, I did not use Pascal's own Tdatetime class, nor did I use the type provided by the operating system to reduce system dependencies.

Interface settings:

Two button, one to read a setting, and other components to display and enter the date time, simple and straightforward. However, there is a point to explain, Lazarus incredibly no DateTimePicker, only date, no time, this is not as good as Delphi.


Code writing:

Because it's a singleton, just write it in a two button click event, and don't forget to refer to the DATEUITLS unit at the top of the uses.


Because it is too simple to explain, look at the effect of the operation. The direct fetch time after running will show 0 because the RTC has not yet been set to a value. After setting the continuous click Get, will find the number of seconds in the change, the call succeeds


It is important to note that changing the value of RTC does not change the system time because it is directly operating on the underlying hardware and not through the operating system. such as setting a different date and setting




To associate RTC with the system time, call the system's API directly to complete it, and here is not much to say.

Please download the ClassA20 class library at https://github.com/tjCFeng/ClassA20.


Allwinner ClassA20 Class Library analysis use of the 7.RTC class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.