Abstract: The DS1340 Serial Access Real-Time Clock (RTC) provides a software clock calibration function that allows an application to compensate for crystal and temperature variations. This application note will describe how this feature is used to improve timekeeping accuracy.
Register Map
The DS1340's control register (address 07h) is used to control the operation of the FT/OUT pin and program the desired clock calibration. The register map of the DS1340 is detailed below.
Table 1. Register Map
Address
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Function
Range
00H
active-low EOSC
10 Seconds
Seconds
Seconds
00-59
01H
R/W
10 Minutes
Minutes
Minutes
00-59
02H
CEB
CB
10 Hours
Hours
Century/ Hours
0-1; 00-23
03H
R/W
R/W
R/W
R/W
R/W
Day
Day
01-07
04H
R/W
R/W
10 Date
Date
Date
00-31
05H
R/W
R/W
R/W
10 Month
Month
Month
01-12
06H
10 Year
Year
Year
00-99
07H
OUT
FT
S
CAL4
CAL3
CAL2
CAL1
CAL0
Control
08H
TCS3
TCS2
TCS1
TCS0
DS1
DS0
ROUT1
ROUT0
Trickle Charger
09H
OSF
0
0
0
0
0
0
0
Flag
Output Control (OUT): This bit controls the output level of the FT/OUT pin when the FT bit is set to zero. If FT = 0, the logic level on the FT/OUT pin is 1 if OUT = 1 and is 0 if OUT = 0.
Frequency Test (FT): When this bit is 1, the FT/OUT pin toggles at a 512Hz rate. When FT is zero, the OUT bit controls the state of the FT/OUT pin.
Calibration Sign Bit (S): A logic 1 in this bit indicates positive calibration for the RTC. A logic 0 indicates negative calibration for the clock. See the Crystal Calibration section for a detailed description of the operation of these bits.
Calibration Bits (CAL4 to CAL0): These bits can be set to any value between 0 and 31 in binary form. See the Crystal Calibration section on for a detailed description of the operation of these bits.
Typical Crystal Behavior
The crystal oscillator is one of the most accurate circuits for providing a fixed frequency. The accuracy of the RTC is dependent mainly on the accuracy of the crystal. Tuning fork crystals have a parabolic frequency across temperature as shown in Figure 1.
Figure 1. Typical tuning fork crystal behavior.
Crystal Calibration
The purpose of the calibration circuit is to move this curve up or down to achieve zero parts per million (ppm) accuracy at a selected temperature. This is accomplished by adding or subtracting counts from the oscillator divider chain. The number of pulses blanked (subtracted for negative calibration) or inserted (added for positive calibration) is set by the 5-bit value loaded into the calibration bits (CAL4:CAL0) in the control register. Adding counts speeds the clock up (moves the crystal curve up) and subtracting counts slows the clock down (moves the crystal curve down). The following figure shows how the clock is adjusted for positive and negative calibration.
The calibration bits can be set to any value between 0 and 31 in binary form. Bit 5 of the control register (S) is the sign bit. A value of one for the S bit indicates positive calibration, while a value of zero represents negative calibration. Each calibration step either adds 512 or subtracts 256 oscillator cycles for every 125,829,120 actual 32,768Hz oscillator cycles (64 minutes). This equates to +4.068ppm or -2.034ppm of adjustment per calibration step. If the oscillator were running at exactly 32,768Hz, each of the 31 increments of the calibration bits would represent +10.7 or -5.35 seconds per month (+5.5 or -2.75 minutes per month). Table 2 details the amount of adjustment for each value in the calibration register.
Table 2. Calibration Adjustment Values
Sign
Calibration
Adjustment
Sign
Calibration
Adjustment
Accuracy (ppm)
Time (sec/month)
Accuracy (ppm)
Time (sec/month)
0
00000
0
0
1
00000
0
0
0
00001
-2
-5
1
00001
4
11
0
00010
-4
-11
1
00010
8
21
0
00011
-6
-16
1
00011
12
32
0
00100
-8
-21
1
00100
16
43
0
00101
-10
-27
1
00101
20
54
0
00110
-12
-32
1
00110
24
64
0
00111
-14
-37
1
00111
28
75
0
01000
-16
-43
1
01000
33
86
0
01001
-18
-48
1
01001
37
96
0
01010
-20
-54
1
01010
41
107
0
01011
-22
-59
1
01011
45
118
0
01100
-24
-64
1
01100
49
128
0
01101
-26
-70
1
01101
53
139
0
01110
-28
-75
1
01110
57
150
0
01111
-31
-80
1
01111
61
161
0
10000
-33
-86
1
10000
65
171
0
10001
-35
-91
1
10001
69
182
0
10010
-37
-96
1
10010
73
193
0
10011
-39
-102
1
10011
77
203
0
10100
-41
-107
1
10100
81
214
0
10101
-43
-112
1
10101
85
225
0
10110
-45
-118
1
10110
89
235
0
10111
-47
-123
1
10111
94
246
0
11000
-49
-128
1
11000
98
257
0
11001
-51
-134
1
11001
102
268
0
11010
-53
-139
1
11010
106
278
0
11011
-55
-144
1
11011
110
289
0
11100
-57
-150
1
11100
114
300
0
11101
-59
-155
1
11101
118
310
0
11110
-61
-161
1
11110
122
321
0
11111
-63
-166
1
11111
126
332
Determining Clock Error
Before setting a calibration value, the amount of calibration required must be determined. When the FT bit (bit 6) of the control register is set, an uncalibrated 512Hz clock is provided on the FT/OUT pin (pin number 7). This frequency allows an application to determine the amount of frequency error for the crystal oscillator.
For example, if using the FT function, a reading of 512.01024Hz would indicate a +20ppm oscillator frequency error, requiring a -10 (00 1010) value to be loaded in the S bit and the five calibration bits. Writing to the control register clears the prescaler, which affects the 512Hz output momentarily (FT/OUT pin goes low). Setting or changing the calibration bits does not affect the frequency on the FT/OUT output pin.
Summary
By using the new calibration feature of the DS1340, timekeeping accuracy provided by a crystal oscillator can be improved. While not providing automatic adjustment as temperature change, it still provides an incremental improvement in accuracy.
의견을 보내주세요! 위 내용이 도움이 되셨나요? 여러분의 의견을 기다립니다 — Maxim은 보내주신 정정이나 제안사항을 반영하고 있습니다.
이 페이지를 평가하고 의견을 보내주십시오.