Key points of the S3C2410 real-time clock Module

Source: Internet
Author: User

Author: Yang Shuo,Hua Qing vision embedded college lecturer.

1. Overview

RTC functions: Generally, RTC is used to provide reliable system time, including information such as year, month, day, hour, minute, and second.
RTC works properly when the system is shut down, because it is powered by a backup battery.
The peripheral of RTC does not require too many auxiliary circuits. Typically, you only need a high-precision 32.768khz crystal oscillator and capacitor, as shown in:

In the past, the RTC module was an independent chip. Now, with the maturity of SOC Technology, more RTC is integrated into the chip, and an RTC module is integrated into the S3C2410 module.

Many embedded products have RTC functions, such as mobile phones, electronic calendars, digital products, and set-top boxes.

The RTC of S3C2410 has the following features:

● Clock data is encoded with BCD (four binary digits are used to represent a decimal number)
● Clock data includes: year, month, day, hour, minute, second, and week
● Automatically process the year, month, and day of a leap year
● Alarm function (Interrupt: int_rtc)
● Independent Power Input
● Millisecond-level clock interruption (kernel clock for embedded real-time operating systems)

2. Structure

RTC 2410 consists of five parts:

● Clock generator
● Beat Generator
● Time and date counters
● Alarm Generator
● Control logic

As shown in:

3. Registers

Control Register: rtccon
Alarm Control Register: rtcalm
Real-time clock Counter: ticnt
Alarm time registers: almsec, almmin, almhour, almdate, almmon, almyear

4. Real-time clock programming steps

1) initialize the real-time clock
Void inittime ()
{
Rrtccon = 0x0;
}

2) write the current time to the real-time clock register
Void settime (struct time * t)
{
Rrtccon | = 0x01;
Rbcdyear = T-> year;
Rbcdmon = T-> mon;
Rbcdday = T-> weekday;
Rbcddate = T-> day;
Rbcdhour = T-> hour;
Rbcdmin = T-> min;
Rbcdsec = T-> sec;
Rrtccon & = 0xfe;
}

3) read time and display
Void gettime (struct time * t)
{
Rrtccon | = 0x01;
While (1)
{
T-> year = rbcdyear;
T-> MON = rbcdmon;
T-> weekday = rbcdday;
T-> day = rbcddate;
T-> hour = rbcdhour;
T-> min = rbcdmin;
T-> sec = rbcdsec;
If (t-> sec! = 0)
Break;
}
Rrtccon & = 0xfe;
}

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.