×
单片机 > 单片机程序设计 > 详情

s3c6410硬件RTC实时时钟

发布时间:2020-06-16 发布时间:
|
1、OVERVIEW综述
The Real Time Clock (RTC) unit can be operated by the backup battery when the system power is off. The data
include the time by second, minute, hour, date, day, month, and year. The RTC unit works with an external 32.768

KHz crystal and can perform the alarm function.

当系统电源关闭时,通过备用电源可以运行实时时钟(RTC)单元。数据包含的时间,即秒,分钟,小时,日期,日,月和年。RTC 工作由一个外部32.768kHz 的晶体驱动,并可以执行报警功能。

2、FEATURES特性

The Real Time Clock includes the following features:
• BCD number: second, minute, hour, date, day, month, and year. BCD编码。
• Leap year generator 闰年发生器。
• Alarm function: alarm-interrupt or wake-up from power-off mode.报警功能:报警中断或从断电模式中唤醒。
• Tick counter function: tick-interrupt or wake-up from power-off mode.时钟计数功能:时钟节拍中断或从断电模式中唤醒。
• Year 2000 problem is removed.这个在下面说,千年虫问题。
• Independent power pin (RTCVDD).
• Supports millisecond tick time interrupt for RTOS kernel time tick.可以用于实时操作系统的系统时钟

3、REAL TIME CLOCK OPERATION DESCRIPTION实时时钟的结构框图

3.1、 LEAP YEAR GENERATOR闰年发生器

The leap year generator can determine the last date of each month out of 28, 29, 30, or 31, based on data from
BCDDAY, BCDMON, and BCDYEAR. This block considers leap year in deciding on the last date. An 8-bit counter
can only represent 2 BCD digits, therefore it cannot decide whether “00” year (the year with its last two digitszeros) is a leap year or not.To solve this problem,the RTC block in 6410 has hard-wired logic to support the leap year in 2000. Note 1900 is not leap year while2000 is leap year. Therefore, two digits of 00 in 6410 denote 2000, not 1900.So, RTC in 6410 supports from 1901 to 2099.

闰年发生器通过BCDDAY, BCDMON 和BCDYEAR 的数据来决定每个月的最后一天是28,29,30 还是31。
这个模块是通过决定最后的日期来判断闰年的。一个8 位的计数器只能代表两个BCD 数字,因此它不能决
定‘00’年(年的最后两个数字为‘00’)是不是闰年. 举例来说,它不能区分1900 年和2000 年。要解决这个问题,S3C6410 中的实时时钟模块,在2000 年中,硬连接逻辑支持闰年。注意1900 年不是闰年,
而2000 年是闰年。因此在S3C6410 中的‘00’的两个数字表示2000 而不是1900。所以6410支持1901年到2099年。

3.2、READ/WRITE REGISTER读写寄存器

Bit 0 of the RTCCON register must be set high in order to write the BCD register in RTC block. To display the
second, minute, hour, day, date, month, and year, the CPU must read the data in BCDSEC, BCDMIN, BCDHOUR,
BCDDATE, BCDDAY, BCDMON, and BCDYEAR registers respectively in the RTC block. However, a one second
deviation may exist because multiple registers are read. For example, when the user reads the registers from
BCDYEAR to BCDMIN, the result is assumed to be 2059 (Year), 12 (Month), 31 (Date), 23 (Hour) and 59 (Minute).
When the user read the BCDSEC register and the value ranges from 1 to 59 (Second), there is no problem, but, if
the value is 0 sec., the year, month, date, hour, and minute may be changed to 2060 (Year), 1 (Month), 1 (Date), 0
(Hour) and 0 (Minute) because of the one second deviation that was mentioned. In this case, the user must reread
from BCDYEAR to BCDSEC if BCDSEC is zero.

RTCCON 寄存器的位0 必须被设置为高位,为了是可以写入实时时钟模块中的BCD 寄存器,以显示秒,分钟,小时,日期,日,月和年。CPU 必须分别在RTC 模块的BCDSEC, BCDMIN, BCDHOUR, BCDDATE, BCDDAY,
BCDMON 和 BCDYEAR 寄存器中读取数据。但是,因为多个寄存器被读取,所以可能有一秒的偏差存在。例
如,当用户从BCDYEAR 到BCDMIN 读取寄存器时,结果假设为2059(年),12(月),31(日期),23(小时)
和59(分钟)。当用户读取BCDSEC 寄存器及值范围从1 到59(秒)时,没有问题,但值为0 秒,年,月,日,小时和分钟将被改变为2060(年),1(月),1(日期),0(小时)和0(分钟),就是因为这一秒的变差。在这种情况下,如果BCDSEC 置0,用户必须从BCDYEAR 到BCDSEC 重新读取。

3.4 、ALARM FUNCTION报警功能,可以对照看上面的那个结构框图
The RTC generates ALARM_INT(alarm interrupt) and ALARM_WK(alarm wake-up) at a specified time in the
power-down mode, power off mode or normal operation mode. 

实时时钟在断电模式或正常操作模式的某一特定时间内产生一个报警信号

In normal operation mode, If ALARM register value is a same to BCD register, ALARM_INT is activated as well as the ALARM_WK. 正常模式下, ALARM_INT和ALARM_WK都被激活

In the power-off and powerdown, If ALARM register value is a same to BCD register,ALARM_WK is activated. 在断电模式下或省电模式下,ALARM_WK被激活

The RTC alarm register (RTCALM) determines the alarm enable/disable status and the condition of the alarm time setting.实时时钟报警寄存器(RTCALM),决定了报警启用/禁用的状态和报警时间设置的条件

3.5、 TICK TIME INTERRUPT   中断

The RTC tick time is used for interrupt request. TheRTCCON[8] register has an interrupt enable bit. The count
value reaches ‘0’ when the tick time interrupt occurs. 实时时钟标记时间被用于中断请求。TICNT寄存器有一个中断使能位和一个相关的计数器值。每个时钟脉冲,计数值减一。当TICK TIME中断发生计数器的值达到‘0’,TICK TIME中断发生。中断周期

Then the period of interrupt is as follows:
Period = (n+1)/32768 second (n= tick counter value)

看下图,那个32768是可选的。


 

这个和下面这个寄存器有关:


 


 

公式中的n= tick counter value和下面这个寄存器有关:


 

 

3.6、 32.768 KHZ X-TAL CONNECTION EXAMPLE时钟晶振电路

                                       

 

4、寄存器:

 

 

s3c6410的RTC在linux中的驱动(1)的链接地址

关键字:s3c6410  硬件RTC  实时时钟 

『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
浅谈msp430f5529入门(2)----时钟配置.例程分析