AN2678 Application note

Similar documents
AN2971 Application note

STEVAL-ISQ010V1. High-side current-sense amplifier demonstration board based on the TSC102. Features. Description

STEVAL-ISA005V1. 1.8W buck topology power supply evaluation board with VIPer12AS. Features. Description. ST Components

EVAL-RHF310V1. EVAL-RHF310V1 evaluation board. Features. Description

2STA1695. High power PNP epitaxial planar bipolar transistor. Features. Applications. Description

Obsolete Product(s) - Obsolete Product(s)

AN3332 Application note

ST619LBDR. DC-DC converter regulated 5 V charge pump. Features. Description

LM723CN. High precision voltage regulator. Features. Description

BD241A BD241C. NPN power transistors. Features. Applications. Description. NPN transistors. Audio, general purpose switching and amplifier transistors

BD243C BD244C. Complementary power transistors. Features. Applications. Description. Complementary NPN-PNP devices. Power linear and switching TO-220

LM323. Three-terminal 3 A adjustable voltage regulators. Features. Description

AN2333 Application note

Obsolete Product(s) - Obsolete Product(s) Obsolete Product(s) - Obsolete Product(s)

2STC4468. High power NPN epitaxial planar bipolar transistor. Features. Application. Description

2STC4468. High power NPN epitaxial planar bipolar transistor. Features. Application. Description

BD533 BD535 BD537 BD534 BD536

Obsolete Product(s) - Obsolete Product(s)

D44H8 - D44H11 D45H8 - D45H11

R 1 typ. = 15 kω. Order codes Marking Polarity Package Packaging. 2N6036 2N6036 NPN SOT-32 Tube 2N6039 2N6039 PNP SOT-32 Tube

AN1756 Application note

2STA1943. High power PNP epitaxial planar bipolar transistor. Features. Application. Description

BD235 BD237. Low voltage NPN power transistors. Features. Applications. Description. Low saturation voltage NPN transistors

Obsolete Product(s) - Obsolete Product(s)

Obsolete Product(s) - Obsolete Product(s)

KF25B, KF33B KF50B, KF80B

STB High voltage fast-switching NPN power transistor. Features. Applications. Description

BUX87. High voltage NPN power transistor. Features. Applications. Description

AN279 Application note

AN2837 Application note

ST26025A. PNP power Darlington transistor. Features. Applications. Description

Obsolete Product(s) - Obsolete Product(s)

AN1441 Application note

Part numbers Order codes Packages Temperature range. LM137 LM137K TO-3-55 C to 150 C LM337 LM337K TO-3 0 C to 125 C LM337 LM337SP TO C to 125 C

2STC5242. High power NPN epitaxial planar bipolar transistor. Features. Application. Description

STEVAL-CCA040V1. 4X10 Watt dual/quad power amplifier demonstration board based on the STA540SAN. Features. Description

3STL2540. Low voltage high performance PNP power transistor. Features. Applications. Description

2ST2121. High power PNP epitaxial planar bipolar transistor. Features. Applications. Description 1 2 TO-3

MD2310FX. High voltage NPN power transistor for standard definition CRT display. Features. Application. Description

Order codes Marking Polarity Package Packaging. MJD44H11T4 MJD44H11 NPN DPAK Tape and reel MJD45H11T4 MJD45H11 PNP DPAK Tape and reel

MJE182 Low voltage high speed switching NPN transistor Features Applications Description High speed switching NPN device

LD1085CXX. 3 A low-drop, adjustable positive voltage regulator. Features. Description

SPV1001T40. Cool bypass switch for photovoltaic application. Features. Application. Description TO-220

STN9260. High voltage fast-switching PNP power transistor. Features. Applications. Description. High voltage capability Fast switching speed

STD1802T4-A. Low voltage fast-switching NPN power transistor. Features. Description. Applications

AN4014 Application Note Adjustable LED blinking frequency using a potentiometer and STM8SVLDISCOVERY Application overview

Order codes Marking Package Packaging 2STF SOT-89 2STN2550 N2550 SOT-223. November 2008 Rev 1 1/8

STPSC V power Schottky silicon carbide diode. Features. Description

AN2167 Application note

2STN2540. Low voltage fast-switching PNP power bipolar transistor. Features. Applications. Description

Obsolete Product(s) - Obsolete Product(s)

2STR2215. Low voltage fast-switching PNP power transistor. Features. Applications. Description

Obsolete Product(s) - Obsolete Product(s)

TS V micropower shunt voltage reference. Features. Applications. Description

TIP2955 TIP3055. Complementary power transistors. Features. Applications. Description

ESDALCL6-4P6A. Multi-line low capacitance and low leakage current ESD protection. Features. Applications. Description

R 1 typ. = 15 kω. Order codes Marking Polarity Package Packaging. STX112-AP X112 NPN TO92-AP Ammopack STX117-AP X117 PNP TO92-AP Ammopack

Obsolete Product(s) - Obsolete Product(s)

AN440 Application note

LS1240. Electronic two-tone ringer. Features. Description. Pin connection (top view)

BUL39D. High voltage fast-switching NPN power transistor. Features. Application. Description

L78S00 series. 2A Positive voltage regulators. Feature summary. Description. Schematic diagram

Obsolete Product(s) - Obsolete Product(s)

2STX2220. High Gain Low Voltage PNP Power Transistor. General features. Description. Internal schematic diagram. Applications.

STD840DN40. Dual NPN high voltage transistors in a single package. Features. Applications. Description

2STD1360 2STF1360-2STN1360

2STD1665. Low voltage fast-switching NPN power transistor. Features. Applications. Description

AN3134 Application note

SD1728 (TH430) RF & Microwave transistors HF SSB application. Features. Description. Pin connection

AN3218 Application note

Order codes Marking Package Packaging. STX0560 X0560 TO-92 Bag STX0560-AP X0560 TO-92AP Ammopack. December 2010 Doc ID Rev 1 1/9

Obsolete Product(s) - Obsolete Product(s)

AN1229 Application note

2N2219AHR. Hi-Rel NPN bipolar transistor 40 V A. Features. Description

TDA7233D 1W AUDIO AMPLIFIER WITH MUTE

AN2385 Application note

2STR SOT-23 Tape and reel 2STR1230G 130G SOT-23 Tape and reel

STPS140Z-Y. Automotive power Schottky rectifier. Features. Description

TR136. High voltage fast-switching NPN power transistor. Features. Applications. Description

AN3359 Application note 1 Introduction Low cost PCB antenna for 2.4GHz radio: Meander design

Obsolete Product(s) - Obsolete Product(s)

LET9060C. RF power transistor from the LdmoST family of n-channel enhancement-mode lateral MOSFETs. Features. Description

MD1802FX. High voltage NPN power transistor for standard definition CRT display. Features. Applications. Description

LK115XX30 LK115XX33 - LK115XX50

STN9360. High voltage fast-switching PNP power transistor. Features. Applications. Description. High voltage capability Fast switching speed

AN4112 Application note

BDX53B - BDX53C BDX54B - BDX54C

ST1510FX. High voltage fast-switching NPN Power transistor. General features. Applications. Internal schematic diagram. Description.

Order codes Marking Package Packaging. STD2805T4 D2805 DPAK Tape & reel STD D2805 IPAK Tube. June 2007 Rev 1 1/9

STN High voltage fast-switching PNP power transistor. Features. Application. Description. High voltage capability Very high switching speed

MD2009DFX. High voltage NPN power transistor for CRT TV. Features. Application. Description

STEVAL-CCA011V1. Filter-free stereo 2x2.5 W Class-D audio power amplifier demonstration board based on the TS2012FC. Features.

LM323. Three-terminal 3 A adjustable voltage regulators. Description. Features

BUL38D. High voltage fast-switching NPN power transistor. Features. Applications. Description

L4940xx5 L4940V5 L4940D2T5-TR 5 V L4940xx85 L4940V85 L4940P85 L4940D2T85-TR 8.5 V L4940xx10 L4940D2T10-TR 10 V L4940xx12 L4940D2T12-TR 12 V

BUL743. High voltage fast-switching NPN power transistor. Features. Applications. Description

TS2431. Programmable shunt voltage reference. Features. Applications. Description

STTH200W06TV1. Turbo 2 ultrafast high voltage rectifier. Features. Description

AN2581 Application note

TO-220 D²PAK TO-220FP

Transcription:

Application note Extremely accurate timekeeping over temperature using adaptive calibration Introduction Typical real-time clocks use common 32,768 Hz watch crystals. These are readily available and relatively inexpensive, but they suffer a loss of accuracy when operated over wide temperature ranges. However, the ultra-low power characteristics of 32 KHz oscillators make them ideal, and necessary, for battery backed applications. Conversely, the higher speed, AT-cut crystals used with microprocessors have low drift over a wide temperature range, and can thus provide high accuracy, but their oscillators are not suitable for backup since they will draw much more current at the frequencies common with AT-cut crystals. The purpose of this application note is to show how, using a combination of these crystal characteristics, users can get high accuracy over a wide temperature range using ST's M41T82-83-93 series of RTCs. This is accomplished by first measuring the frequency and then using both the analog and digital calibration features of these devices. Figure 1. AT versus watch crystal - typical characteristics PPM 20 0-50 -40-30 -20-10 0 10 20 30 40 50 60 70 80 90 100-20 -40-60 -80-100 -120-140 -160 Watch crystal AT cut crystal -180 TEMP ( C) ai13944 November 2008 Rev 2 1/16 www.st.com

M41T82-83-93 series RTCs AN2678 1 M41T82-83-93 series RTCs ST has long offered RTCs with digital calibration, and the new M41T82-83-93 series follows suit. In addition to digital calibration utilizing periodic counter correction, this new series features analog calibration wherein the oscillator frequency can be adjusted by adding or removing load capacitance via a programmable capacitance array. Analog calibration has the added benefit of instantaneous feedback for the user; adjustments to the oscillator speed are immediately visible in the 512 Hz test output signal built into the devices. 1.1 Oscillator temperature characteristics As shown in Figure 1, the frequency error of typical 32 KHz oscillators is around 25 parts per million (ppm) at both 0 C and 50 C. That is, at 25 above and below room temperature, the device exhibits a frequency deviation of 25 ppm, and it only gets worse as the temperature deviates farther from +/ 25 C. Conversely, for an AT cut crystal, as is commonly used with microprocessors, the frequency deviation is much less pronounced over a wide range of temperatures. The trade-off is that AT cut crystals usually operate at frequencies much, much higher than watch crystals and thus require much more power - too much for battery backup as is typically employed with real-time clocks (RTCs). But it is possible to get the low power performance of watch crystals along with the wide temperature accuracy of AT cut crystals if the RTC can be periodically calibrated by the microprocessor, almost all of which nowadays include timers that can be employed to measure the frequency test (FT) pin of the RTC and correct any error in the timing utilizing the calibration features of the RTC. The approach discussed herein utilizes both of the calibration circuits in ST's M41T82, M41T83 and M41T93 serial RTCs. This application note describes how to perform an initial calibration, using the analog circuit, followed by occasional calibration updates using the digital calibration circuit. Initially, the analog calibration circuit is adjusted at room temperature, in a closed loop fashion wherein successively smaller and smaller adjustments are made until the error is minimized. After that, during normal operation, the microprocessor will periodically measure the error as before, then use a look-up table, and write adjustments to the digital calibration circuit. 1.2 Frequency test output In the case of ST's M41T82, M41T83 and M41T93 serial RTCs, the frequency test signal is output on the IRQ/FT/OUT pin. It is enabled by setting the FT bit (bit 6, register 0x08) to 1 in the M41T82 and M41T83. (Refer to the datasheets for more information and for the M41T93 details.) The FT signal is measured by test equipment and/or the microprocessor. The calibration circuits are then adjusted accordingly. The frequency test signal is nominally 512 Hz and is derived from the 32,768 Hz oscillator. During the analog calibration sequence, changes in the oscillator will appear in real-time in the FT signal. Thus, analog calibration changes can be measured and errors can be minimized on-the-fly by the system microprocessor. 2/16

M41T82-83-93 series RTCs 1.3 Measuring FT and the timing error For the analog calibration, a frequency counter is recommended. This will provide the highest accuracy. The next consideration is using the microprocessor s timer. This can be used to adjust the analog calibration and will be used for the digital portion. Microprocessor timers can come in a variety of configurations with many different speeds and input options, so this document can only address them in a general sense. Figure 1 shows the basic setup between the RTC and the microprocessor. The processor's timer is used to measure the frequency of the RTC's frequency test signal (FT) and then adjust the RTC's calibration registers as necessary via the I 2 C bus. Figure 1. Basic setup of microprocessor and RTC AT cut crystal OSC up Watch crystal OSC RTC DCAL ACAL FT = 512Hz I 2 C 2 TIMER ai13995 Fundamentally, the processor needs to measure the period of the timer and calculate the error or frequency deviation of the FT signal, but the measurement process is itself prone to error. However, it should be possible to minimize that error to an acceptable level. The key concept is that the microprocessor's timer runs off a clock signal derived from the microprocessor's oscillator with AT cut crystal. Since this oscillator has low drift over temperature, the timer s clock signal will be low drift, too. Thus, using this timer, the RTC can be calibrated to approach the accuracy of this timing chain, thus reducing the timekeeping errors associated with watch crystals due to temperature drift. In Figure 2, the microprocessor's clock is called TCLK, and is used to sample the 512 Hz frequency test signal, FT. Each sample includes some uncertainty. But the uncertainty does not change as more samples are added. Thus, with many samples, the uncertainty will be very small in comparison to the measured period. For example, in Figure 2, the timer can detect that a transition occurred on the FT signal between two successive samples, but it cannot determine exactly where between those samples that it occurred. That uncertainty is labeled T ε1, T ε2 and T ε3 in the figure. 3/16

M41T82-83-93 series RTCs AN2678 Figure 2. Timing uncertainty TCLK T FT FT = 512Hz FT after sampling T FTS1 T FTS2 ai13996 The first cycle of the sampled (bottom) waveform has the period Τ FTS1 = Τ FT + Τ ε Τ 2 ε 1 Similarly, the second cycle has the period Τ FTS2 = Τ FT + Τ ε Τ 3 ε 2 For both cycles together, the total period is Τ + Τ = 2 Τ + Τ Τ + Τ Τ = 2 Τ Τ + Τ FTS1 FTS2 FT ε 2 ε 1 ε 3 ε 2 FT ε 1 ε 3 This shows that the uncertainty between all the samples (except the first and last) subtracts out of the total with the result that only the uncertainty of the first and last cycles remains. Thus, the net uncertainty will be small compared to the overall measured period, T N, of multiple samples of the 512 Hz signal, as shown in Figure 3. So, by measuring several consecutive samples of the 512 Hz signal, the uncertainty can be minimized to an acceptable level. 4/16

M41T82-83-93 series RTCs Figure 3. Example timing T i T N N T N = T i i=1 FT = 512Hz N cycles ai13997 1.4 Calculating the period As shown in Figure 3, the microprocessor will measure multiple cycles of the FT signal to get a total period, T N. The calculated period of the 512 Hz is then Τ 512 Τ N = N = N i= 1 N Τ i If N is sufficiently large, the uncertainty error, T εn T ε1, can be ignored. The microprocessor's timer will measure the T i, the period of each sample. Either software or some other timer function, such as a pulse accumulator, available on many microprocessor timers, will count the number of samples, N. Likewise T N is the sum of the T i, and can be accumulated in a timer function or in software. Once these are determined, software will then calculate T 512 by dividing T N by N. 5/16

M41T82-83-93 series RTCs AN2678 1.5 Determining the error The error formula, in ppm, where f m is the measured frequency, is below. When using a frequency counter, this can be used to determine the error. fm 512 ppm = 10 512 6 The formula below can be used to determine the error when using the microprocessor timer to determine the period, T 512, of the frequency test signal. Equation 1 1 Τ512 ppm = 512 10 Τ 512 6 A negative ppm means the frequency is too low and the clock is slow. Conversely, a positive ppm means the clock is fast and thus needs to be slowed down. 6/16

Calibrating the M41T83 using analog calibration 2 Calibrating the M41T83 using analog calibration The analog calibration procedure is performed only once, at room temperature (25 C). It begins with determining the frequency test signal's period, T 512. Then, the software adjusts the RTC oscillator via the analog calibration feature, and another measurement of T 512 is made. This cycle is repeated until the error is minimized, that is, until the oscillator can be fine tuned no further. At that point, the RTC's accuracy will be approximately equal to the microprocessor's oscillator accuracy, which, depending on the quality of its crystal, may not vary more than +/ 5 ppm over a wide temperature range. 2.1 Analog calibration circuit The analog calibration circuit utilizes an array of load capacitors internal to the RTC as shown in the inset of Figure 4. Values written to the analog calibration register add or remove load capacitance to slow down or speed up the oscillator, respectively. The 32 KHz crystals are designed to see a specific load capacitance. ST builds this into their real-time clocks; users do not need to add any external capacitance to the crystals. Values programmed into the analog calibration register adjust the amount of this built-in load capacitance seen by the crystal. As shown in Figure 4, two load capacitors are identified as C XI and C XO. Nominally, these are 25 pf each. The adjustment range of the RTC is such that up to 18 pf can be subtracted from each, or up to 9.75 pf can be added making the full range of each load capacitor 7 to 34.75 pf. The equivalent load capacitance is the series combination of the two, and is hence nominally 12.5 pf with a range of 3.5 pf to 17.4 pf. (In other words, for identical capacitors, the series equivalent value is ½ the individual values.) The asymmetry in the adjustment range is due to the fact that the crystals tend to need speeding up much more often than they need slowing down. This is evident upon examining the watch crystal curve in Figure 1. Thus, much more capacitance can be subtracted from nominal than can be added. 7/16

Calibrating the M41T83 using analog calibration AN2678 Figure 4. Typical analog calibration characteristics - oscillator frequency versus load capacitance 1 0 0. 0 P P M A D J U S T M E N T 80. 0 60. 0 40. 0 20. 0 0. 0 FASTER SLOWER XI C XI On-Chip DECREASING LOAD CAP. Crystal Oscillator C XO XO C XI C LOAD = * C XO C XI + C XO INCREASING LOAD CAP. - 2 0. 0 OFFSET TO C XI, C XO (pf) NET EQUIV. LOAD CAP., C LOAD, (pf) A n a l o g C a l i b r a t i o n V a l u e, AC, register 0x12-18.0-15. 0-10. 0-5. 0 0. 0 5. 0 9.75 3.5 5.0 7.5 10 12.5 15 17.4 0xC8 0xBC 0xA8 0x94 0x00 0x14 0x27 ai13998 Associated with this range of capacitance values, the range of frequency shift of the oscillator is approximately 14.8 ppm up to +96.7 ppm. Several examples are shown in Table 1. This shift range corresponds to an approximate frequency range of 32767.514 Hz to 32771.168 Hz. Table 1. Analog calibration value Analog calibration examples Hex 00 0C 14 27 9C C8 Bin 0000000 0 0000110 0 0001010 0 0010011 1 1001110 0 1100100 0 Additional load capacitance 0 +3 pf +5 pf +9.75 pf 7 pf 18 pf Total load capacitance C XI, C XO 25 pf 28 pf 30 pf 34.75 pf 18 pf 7 pf Total equivalent load capacitance C XI in series with C XO 12.5 14 pf 15 pf 17.4 pf 9 pf 3.5 pf Approximate frequency shift 0 ppm 4.3 ppm 7.8 ppm 14.8 ppm +21.9 ppm +96.7 ppm Nominal < Slowing down > < Speeding up > Thus, in summary, the nominal equivalent load capacitance is 12.5 pf, and can be adjusted up to 17.4 pf or down to 3.5 pf. This corresponds to slowing the oscillator by approximately 14.8 ppm or speeding it up by +96.7 ppm, respectively. 8/16

Calibrating the M41T83 using analog calibration These are typical values. The curve in Figure 4 may be shifted up or down, left or right for a given crystal. Because the curve is non-linear, an increment of capacitance at one operating point will not have the same effect as an equal increment at another operating point. Thus, table-lookup methods cannot be used with analog calibration. Instead, an iterative procedure is required to ensure accuracy. 2.2 Analog calibration algorithm The analog calibration algorithm described herein uses a binary tree approach for adjustment. It utilizes repeated measurements as described in the scheme above. With each adjustment /measurement sequence, the RTC's oscillator is fine tuned with progressively smaller changes of the internal load capacitance array via the analog calibration register. As shown in Figure 5, the procedure starts with zeroing out the analog calibration register, then waiting a few milliseconds for the oscillator to stabilize. Next, the frequency measurement is made of the FT signal. If it is faster than 512 Hz, load capacitance is added to the RTC's oscillator. If it is slower than 512 Hz, capacitance is removed. And if the FT signal is exactly 512 Hz, no further adjustment is required. Figure 5. Analog calibration algorithm Set ACAL (012h) to 0 Wait for OSC to stabilize SLOW FAST FT? =512 Set ACAL (012h) to 8pF DONE Set ACAL (012h) to +4pF Sub 4pF SLOW FAST FT? =512 DONE Add 4pF Sub 2pF SLOW FAST FT? =512 DONE Add 2pF Sub 1pF SLOW FAST FT? =512 DONE Add 1pF SLOW FAST Sub 0.5pF FT? =512 DONE Add 0.5pF SLOW FAST Sub 0.25pF FT? Add 0.25pF DONE =512 DONE DONE ai13999 9/16

Calibrating the M41T83 using analog calibration AN2678 As the watch crystal curve of Figure 1 predicts, the RTC oscillator will tend to be slow more often than fast, so the adjustment range of the part is asymmetric; there is more range for increasing the RTC oscillator speed than for slowing it down. For the M41T82, M41T83 and M41T93 RTCs, the smallest incremental adjustments are step sizes of approximately 0.25 pf. One step of 0.25 pf is roughly 0.5 ppm. Since this algorithm uses a binary tree approach, each increment of capacitance must be a power of 2 times 0.25 pf. That is, capacitance will be added and/or subtracted in increments of 8 pf, 4 pf, 2 pf, 1 pf, 0.5 pf or 0.25 pf. Thus, although up to 18.0 pf can be subtracted or up to 9.75 pf can be added, the power of 2 restriction constrains these limits to 16 pf and +8 pf, respectively. As a result, this algorithm does not use the total available adjustment range, but that will not be a problem in most applications. For example, with this approach, when capacitance is to be added, instead of starting at half the maximum available, ½ x 9.75 pf (= 4.875 pf), the power of 2 nearest that is used, which is 4 pf. Similarly, for removing capacitance, the most that can be subtracted is 18 pf, so the algorithm starts at the power of 2 nearest ½ x 18, or 8 pf. Returning to Figure 5, after making the first measurement of FT, if capacitance is added, as shown on the right, the ACAL value is adjusted to 4 pf. Then, progressively smaller increments of capacitance are added or removed, until the frequency error measured on the FT pin is minimized. If, in Figure 5, the first test of the FT signal indicates that capacitance must be removed (that the RTC is slow), the analog calibration register is set to 8 pf and then progressively smaller increments of capacitance are added or removed. Each time the analog calibration register is adjusted, the oscillator must be allowed time to settle before taking another measurement. This is shown at the top of Figure 5, but not shown in successive steps for the sake of brevity. However, it is still required each time the register is written. Using this binary approach, each of the 25 pf capacitors can be increased by up to 7.75 pf or decreased by up to 15.75 pf. While these adjustment limits are slightly less than the absolute limits available - up to a 9.75 pf increase or 18 pf decrease - they should cover all except the most extreme cases of RTC oscillator error. It may be possible to use the wider, available adjustment limits in an adaptive calibration scheme like this one, but when increments other than powers of 2 are used, the algorithm becomes much, much more complex and thus may not be as easy for users to implement. Once the final calibration bit has been determined, the user should record the value in nonvolatile memory so that it can be retrieved by the microprocessor when necessary. If a frequency counter was used to perform the measurements during the analog calibration procedure, the user should immediately follow that with the additional step of using the microprocessor and its timer to measure the period of the FT signal out of the real-time clock as described in Section 1.3 and 1.4. This is done to establish the initial error, if any, in the microprocessor s timing chain at room temperature. This value should also be stored in non-volatile memory. 10/16

Digital calibration 3 Digital calibration The digital calibration feature of the M41T82, M41T83 and M41T93 uses periodic counter correction. The clock counters are adjusted by adding or subtracting pulses at the 512 Hz divider stage. This approach provides compensation over an approximate range of 63 ppm to +126 ppm. This method employs the use of periodic counter correction by adjusting the ratio of the 100 Hz divider stage to the 512 Hz divider stage. Under normal operation, the 100 Hz divider stage outputs precisely 100 pulses for every 512 pulses of the 512 Hz stage. This 100 Hz signal is the input to the counter for the 10ths/100ths of seconds register in the RTC. By adjusting the number of 512 Hz input pulses used to generate 100 output pulses, the clock can be sped up or slowed down. To provide digital correction, the device will, depending on the digital calibration value, periodically produce one or more long or short seconds. When a non-zero value is loaded into the five Calibration Bits (DC4 - DC0) of the Digital Calibration Register (0x08) and the sign bit is 1, (indicating positive calibration), the 100 Hz stage will output 100 pulses for every 511 input pulses instead of the normal 512. Since the 100 pulses are now being output in a shorter window, this has the effect of speeding up the clock by 1/512 seconds for each second the circuit is active. Table 2. Digital calibration values Calibration value, DC4-DC0 Calibration effect, in ppm, rounded to the nearest integer Decimal Binary Slowing Sign DCS = 0 negative calibration Speeding Sign DCS = 1 positive calibration 0 00000 0 ppm + 0 ppm 1 00001 2 ppm + 4 ppm 2 00010 4 ppm + 8 ppm 3 00011 6 ppm + 12 ppm 4 00100 8 ppm + 16 ppm 5 00101 10 ppm + 20 ppm 6 00110 12 ppm + 24 ppm 7 00111 14 ppm + 28 ppm 8 01000 16 ppm + 33 ppm 9 01001 18 ppm + 37 ppm 10 01010 20 ppm + 41 ppm 11 01011 22 ppm + 45 ppm 12 01100 24 ppm + 49 ppm 13 01101 26 ppm + 53 ppm 14 01110 28 ppm + 57 ppm 15 01111 31 ppm + 61 ppm 11/16

Digital calibration AN2678 Table 2. Digital calibration values (continued) Calibration value, DC4-DC0 Calibration effect, in ppm, rounded to the nearest integer Decimal Binary Slowing Sign DCS = 0 negative calibration Speeding Sign DCS = 1 positive calibration 16 10000 33 ppm + 65 ppm 17 10001 35 ppm + 69 ppm 18 10010 37 ppm + 73 ppm 19 10011 39 ppm + 77 ppm 20 10100 41 ppm + 81 ppm 21 10101 43 ppm + 85 ppm 22 10110 45 ppm + 90 ppm 23 10111 47 ppm + 94 ppm 24 11000 49 ppm + 98 ppm 25 11001 51 ppm + 102 ppm 26 11010 53 ppm + 106 ppm 27 11011 55 ppm + 110 ppm 28 11100 57 ppm + 114 ppm 29 11101 59 ppm + 118 ppm 30 11110 61 ppm + 122 ppm 31 11111 63 ppm + 126 ppm N N/491520 (per minute) +N/245760 (per minute) Similarly, when the sign bit is 0, indicating negative calibration, the block will output 100 pulses for every 513 input pulses. Since the 100 pulses are then being output in a longer window, this has the effect of slowing down the clock by 1/512 seconds for each second the circuit is active. The overall amount of calibration is controlled using the value (N) in the digital calibration register to generate the adjustments in one second increments. N is the number of affected seconds in the correction period. For positive calibration (speeding up), corrections are made to each of the first N seconds of every eight minute interval. For negative calibration (slowing down), corrections are made to each of the first N seconds of every 16-minute interval. Thus, when speeding up, the first N seconds of every 480 second span (ie, every 8-minute span) are each slightly shorter. And when slowing down, the first N seconds of each 960 second span (ie, 16 minutes) are slightly longer. To use the digital calibration feature, the measurement technique described in Section 1 is used - the 512 Hz frequency test signal is measured by the microprocessor's timer. 12/16

Digital calibration Depending on whether this timer was also used to perform the initial analog calibration, an adjustment may need to made to this number. Once the adjusted number is determined, the error in ppm is calculated and the appropriate offset from Table 2 is selected and programmed into the digital calibration register. Example 1: A frequency counter was used during analog calibration, and the subsequent period measured and calculated using the microprocessor s timer was 0.0019531441 seconds. Ideally, this number would be 0.0019531250 (= 1/512). Thus, the microprocessor s timer is about 10 ppm fast, and the earlier number, 0.0019531441, will be used in place of 1/512 in Equation 1. Given a current calculated period of 0.0019531536, this is inserted into Equation 1 for T 512, and the resultant error is 4.88 ppm. So the RTC should be adjusted by the opposite amount. In Table 2, the positive value nearest this is +4 ppm, so the digital calibration register would get would get DCS = 1 and DC4:DC0 = 00001. Example 2: The microprocessor s timer was used during analog calibration. As in example 1, let the calculated period be 0.0019531536 seconds. Inserting this into Equation 1 (and retaining the 1/512), we get 14.65 ppm. The nearest opposite value is +16 ppm. For this, DCS = 1 and DC4:DC0 = 00100. With digital calibration, the adjustments are made open-loop. In the case of the analog calibration adjustments, the frequency shift of the oscillator can be seen in the 512 Hz test signal, but with the digital calibration, the effects are spread out over time and are not immediately observable upon making changes. Furthermore, with digital calibration, no iteration is required. Once the frequency error is known, an appropriate value is programmed into the part and no further adjustments are made for while. The key idea is that adjusting the digital calibration requires one measurement followed by one adjustment; no looping is required. This digital calibration procedure is repeated often enough to prevent the RTC from drifting too far, but no more often than every 16 minutes, the interval at which the RTC digital calibration algorithm updates. This can be reduced to 8 minutes when positive calibration values are being used. As the ambient temperature changes, the oscillator will drift, and the RTC oscillator will need adjustment. This can be done periodically by scheduling calibrations, or, if a temperature sensor is available to the microprocessor, by monitoring for changes in the temperature and adjusting the RTC when they occur. Or, a combination of both might be utilized. For example, scheduled RTC calibrations might occur every hour, and unscheduled ones might be run whenever a 2 degree temperature shift is detected. As long as the microprocessor periodically adjusts the RTC, its timekeeping accuracy will be optimized, and timekeeping errors minimized. 13/16

Conclusion AN2678 4 Conclusion By taking advantage of the analog calibration feature built into the new M41T82/83/93 family of serial RTCs, a low cost clock with high accuracy across temperature can be achieved. This approach requires only the use of the microprocessor timer to periodically measure the RTC's true frequency. Initially, the analog calibration is adjusted at room temperature. Then, periodic updates to the digital calibration register are made to compensate for any RTC oscillator drift due to temperature changes which may occur. During the analog calibration, a simple binary decision tree is employed which allows the user to fine tune the clock's oscillator and zero out any frequency shift. Subsequent digital calibration adjustments use a look-up-table. Using this combination of analog and digital calibration enables the user to have a simple periodic update scheme which requires low overhead while providing accurate timekeeping and minimal cost. 14/16

Revision history 5 Revision history Table 3. Document revision history Date Revision Changes 20-Dec-2007 1 Initial release. 26-Nov-2008 2 Updated Figure 1. 15/16

Please Read Carefully: Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries ( ST ) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice. All ST products are sold pursuant to ST s terms and conditions of sale. Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no liability whatsoever relating to the choice, selection or use of the ST products and services described herein. No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein. UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY, DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK. Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any liability of ST. ST and the ST logo are trademarks or registered trademarks of ST in various countries. Information in this document supersedes and replaces all information previously supplied. The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners. 2008 STMicroelectronics - All rights reserved STMicroelectronics group of companies Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan - Malaysia - Malta - Morocco - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America www.st.com 16/16