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时钟晶振电路