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