Arm9-hardware interface learning 2 rtc

Source: Internet
Author: User

In an embedded system, real-time clock units can provide reliable clocks, including hour, minute, second, and year, month, and day. Even if the system is shut down, it can work normally (usually powered by a backup battery), and its peripheral does not require too many auxiliary circuits, typically, you only need a high-precision crystal oscillator.

S3C2410 rtcFeatures:

1. Clock data adopts BCD Encoding

2. Automatic Processing of the year, month, and day of a leap year

3. An alarm is triggered. When the system is shut down, an alarm is triggered and interrupted;

4. Independent Power Input

5. millisecond-level clock interruption, which can be used as the kernel clock of the embedded operating system

6. Use an independent external clock crystal shock at a frequency of 32.768 kHz.

 RTC has more registers than watchdog, but here we only need to implement the RTC time read/write function through experiments, therefore, you only need to know the clock control registers rtcoon and BCD clock registers (SEC, Min, hour, etc.), and other registers related to the RTC alarm function can be ignored temporarily. In this case, the RTC InterfaceCodeIs easy to write.

The two registers are analyzed below.

1. Clock Control Register rtcoon

 

Rtcen bit can control all interfaces between the CPU
And the RTC, so it shoshould be set to 1 in an RTC control routine
Enable data read/write after a system reset.

The above sentence is taken from datasheet. You can see from this sentence that the rtcen position is 1 before reading and writing the RTC register. Note that the cntsel bit is used by default. RTC uses BCD encoding, which makes reading and writing BCD clock registers very convenient.

2. BCD clock register

Including bcdsec, bcdmin, and bcdhour. Which stores the BCD code corresponding to the clock.

The experiment sets and reads the RTC time. The code is very simple. I will not write it here. I will know it at a glance. You only need to enable the rtcen bit before reading and writing the RTC clock register.

Download Code:Http://www.cnblogs.com/heiyue/admin/Files.aspx

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.