Use of the 8.GP class "Allwinner ClassA20 class Library Analysis"

Source: Internet
Author: User

When it comes to RTC, it's important to say backup registers. In general, after the RTC has been set, a flag is made in the backup register indicating that the current time has been set and no need to be reset, and when this flag is not detected, it proves that the RTC has been disconnected and the time is incorrect. For today, it is said that the use of the Backup register class. Before using, please download the ClassA20 Class library in https://github.com/tjCFeng/ClassA20 first.

The backup register, called the General Purpose in Allwinner. It has the same characteristics as the RTC, that is, the contents of the register do not disappear after the power outage, can rely on the RTC battery to maintain, but it does not automatically accumulate the function.

The backup register is probably the simplest of all functions, simple to assign, read, no other function, but it can be used as a global variable, a global variable that can cross the process and not disappear.

as before, let's take a look at the encapsulation of it.


The Allwinner A20 has 16 backup registers, each of which can record 32-bit integer values. In order to be easy to use, it is encapsulated as a singleton, directly specifying the index number to write and read.

How to write a program this time change, no longer use the form, directly compile a program without any interactive interface to test it. Create a method first select project in the menu, then click Create, and select "Programs". Of course, you can also choose "Console Program", similar to the



The simplest program framework is automatically generated after a successful creation, and the begin and end are the portals, equivalent to the main function of C



or add the path to the ClassA20 folder in the project, and then refer to the GP unit in uses to begin writing code.

Because the register is only a pointer in the program, it does not display its value directly during debugging, so a variable of long integer is defined so that it is easy to view when debugging.



Set breakpoints and run when the program is written. Breakpoints can stop when the program runs to that line of code and perform some debugging operations. When you run to the code that assigns the value of the backup register to this variable, you can display the current value by placing the mouse over the variable. First run, the value of the backup register defaults to 0, write a 0xFF to the backup register and then read out, this variable is 255



This time, you can shut down the power, any time to start and then read this register, its value is still 255, unless the half-way RTC battery is broken off.

TGP. INSTANCE.GETGP and SETGP are encapsulated methods, and parameters directly specify the index number of the backup register. In addition to this, the register pointers can be manipulated directly, as well as simple



the pointer to the register is an array, which is the same as the normal variable .



Note that there may be some minor problems with the power management portion of the banana pie, causing the battery to power down quickly, so I have not been able to successfully read the value of the backup register after the power outage on the banana pie, but try the program on the other board.

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


Use of the 8.GP class "Allwinner ClassA20 class Library Analysis"

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.