1. 程式人生 > >6.S5PV210中RTC時鐘時鐘基礎簡介

6.S5PV210中RTC時鐘時鐘基礎簡介

REAL TIME CLOCK (RTC)---實時時鐘

4.1 OVERVIEW OF REAL TIME CLOCK
The Real Time Clock (RTC) unit can operate using the backup battery while the system power is off. Although power is off, backup battery can store the time by Second, Minute, Hour, Day of the week, Day, Month, and Year data. The RTC unit works with an external 32.768 kHz crystal and performs the function of alarm.
實時時鐘概述:
實時時鐘單元在系統斷電的時候能使用備用電池執行。儘管斷電,通過備用電池仍然能夠儲存時間日期。RTC單元通過一個外部的32.768kHz晶振工作,並能提供鬧鐘功能。



4.2 KEY FEATURES OF REAL TIME CLOCK
* Supports BCD Number, that is Second, Minute, Hour, Day of the week, Day, Month, and Year.
* Supports Leap Year Generator
* Supports Alarm Function, that is ,Alarm-Interrupt or Wake-up from power down modes (idle, deep idle, stop,deep stop, and sleep)
* Supports Tick Counter Function, that is Tick-Interrupt or Wake-up from power down modes (idle, deep idle,stop, deep stop, and sleep)
* Supports Independent Power Pin (RTCVDD)
* Supports millisecond tick time interrupt for RTOS kernel time tick .
實時時鐘的關鍵特性:
* 支援BCD碼,時鐘包括:秒、分、時、星期、日、月、年。
* 支援生成閏年
* 支援鬧鐘功能,通過鬧鐘中斷或掉電模式(空閒、深度空閒、停止、深度停止、休眠)喚醒
* 支援滴答計數功能,通過滴答中斷或掉電模式(空閒、深度空閒、停止、深度停止、休眠)喚醒
* 支援獨立的電源引腳(RTCVDD)
* 支援為RTOS核心時鐘節拍提供毫秒計時


4.2.1 REAL TIME CLOCK OPERATION DESCRIPTION
實時時鐘結構框圖


4.3 LEAP YEAR GENERATOR
The leap year generator determines the last day of each month out of 28, 29, 30, or 31. This is calculated based on the data from BCDDAY, BCDMON, and BCDYEAR. This block considers leap year while deciding on the last day of a month.
NOTE: The BCDYEAR register is 12-bit wide. It can represent maximum three BCD digits. The implicit number of thousands place is 2. Therefore, it can represent years from 400*n to 400*n + 999 (n = 0, 1, 2, 3, 4, 5, … ).
閏年發生器:
閏年發生器確定每個月的最後一天為28/29/30/31。這是以BCDDAY, BCDMON, and BCDYEAR中的資料為依據來計算的。這個模組考慮閏年來決定每月最後一天的日期。
注意:BCDYEAR暫存器是12位寬的。所以它能表示最多3個BCD碼(4個二進位制位表示一個BCD碼)。千位的位置隱式為2。所以,它能表示的年份為400*n to 400*n + 999 (n = 0, 1, 2, 3, 4, 5, … )。

4.4 READ / WRITE REGISTER
讀/寫暫存器
To write the BCD register in RTC block, set the Bit 0 of the RTCCON register. To display the second, minute,hour, day of the week, day, month, and year, the CPU should read the data in BCDSEC, BCDMIN, BCDHOUR,BCDDAYWEEK, BCDDAY, BCDMON, and BCDYEAR registers, respectively, in the RTC block. However, a onesecond deviation can exist because multiple registers are read.
在RTC模組中寫BCD暫存器時,需要置位RTCCON暫存器中的bit0(使能RTC控制)。CPU通過讀取BCDSEC, BCDMIN, BCDHOUR,BCDDAYWEEK, BCDDAY, BCDMON, and BCDYEAR暫存器來顯示具體的日期。然而,因為多個暫存器被讀所以會出現秒級的誤差。

For example, if you read the registers from BCDYEAR to BCDMIN, the result is assumed to be 2059 (Year), 12(Month), 31 (Day), 23 (Hour) and 59 (Minute). If you read the BCDSEC register and the value ranges from 1 to 59(Second), there is no problem. However, if the value is 0 sec., the year, month, day, hour, and minute can change to 2060 (Year), 1 (Month), 1 (Day), 0 (Hour) and 0 (Minute) because of the one second deviation. In this case, you must read again from BCDYEAR to BCDSEC if BCDSEC is zero.
例如,如果你從 BCDYEAR 到 BCDMIN暫存器中讀取數值,結果假設為2059年12月31日23時59分。然後你讀BCDSEC暫存器的值,如果是1到59這個範圍沒有問題出現,但是如果讀的是0秒,那麼日期很有一秒之差變為2060年1月1日0時0分。這種情況下,如果BCDSEC值為0你需要再次從BCDYEAR到BCDSEC暫存器中讀取數值。

4.4.1 BACKUP BATTERY OPERATION
The backup battery can drive the RTC logic. The backup battery supplies the power through the RTCVDD pin into the RTC block, even if the system power is off. If the system is off, the interfaces of the CPU and RTC logic should be blocked, and to minimize power dissipation the backup battery only drives the oscillation circuit and the BCD counters.
備用電池操作:
備用電池能夠驅動RTC邏輯。即使系統斷電,備用電池也可以通過RTCVDD引腳為RTC模組供電。如果系統斷電,CPU和RTC邏輯塊的介面將會被阻斷,備用電池僅僅驅動振盪電路和BCD計數器以最小化的耗電。


4.5 ALARM FUNCTION
The RTC generates ALARM_INT (alarm interrupt) and ALARM_WK (alarm wake-up) at a specific time in the
power-off mode or normal operation mode. In normal operation mode, ALARM_INT is activated. In the power-off mode, ALARM_WK signal is activated as well as the ALARM_INT. The RTC alarm register (RTCALM) determines the alarm enable/disable status and the condition of the alarm time setting.
鬧鐘功能:
在斷電模式或者正常執行模式,RTC在特定的時間產生鬧鐘中斷或者鬧鐘喚醒。在正常執行模式下,鬧鐘中斷被啟用,在斷電模式下鬧鐘喚醒訊號被啟用也和鬧鐘中斷一樣。RTC鬧鐘暫存器(RTCALM)確定鬧鐘使能/禁止和設定鬧鐘時間的條件。


4.6 TICK TIME INTERRUPT
The RTC tick time is used for interrupt request. The TICNT register contains an interrupt enable bit and count value for the interrupt. If the count value reaches ‘0’ if the tick time interrupt occurs. Then the period of interrupt is as follows:
* Period = (n+1) / (Tick clock source frequency) second (n= tick counter value)
TICK TIME 中斷:
RTC滴答時間被作用於中斷請求。TICNT暫存器包含一箇中斷使能位和中斷計數值。如果中斷計數值到0產生一個滴答時鐘中斷。中斷週期計算如下:
* Period = (n+1) / (Tick clock source frequency) second (n= tick counter value)