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
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
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.
/FT/OUT pin. It is enabled by setting the FT bit (bit 6, register 0x08) to 1 in
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
AN2678M41T82-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
Figure 1.Basic setup of microprocessor and RTC
2
C bus.
uP
OSC
TIMER
ai13995
Watch
crystal
OSC
RTC
DCAL
ACAL
AT cut
crystal
FT = 512Hz
2
I2C
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
3/16
, Tε2 and Tε3 in the figure.
ε1
M41T82-83-93 series RTCsAN2678
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
ΤΤΤΤ−+=
12FTFTS1εε
Similarly, the second cycle has the period
ΤΤΤΤ−+=
23FTFTS2εε
For both cycles together, the total period is
ΤΤΤ2ΤΤΤΤΤ2ΤΤ+−×=−+−+×=+
31FT2312FTFTS2FTS1εεεεεε
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
AN2678M41T82-83-93 series RTCs
Figure 3.Example timing
T
N
N
TN= T
i=1
i
ai13997
FT = 512Hz
T
i
N cycles
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
. The calculated period of the 512 Hz is then
N
N
Τ
∑
Τ
Τ
512
N
N
==
i
1i
=
N
If N is sufficiently large, the uncertainty error, TεN – Tε1, can be ignored.
The microprocessor's timer will measure the T
, the period of each sample. Either software
i
or some other timer function, such as a pulse accumulator, available on many
microprocessor timers, will count the number of samples, N. Likewise T
T
, and can be accumulated in a timer function or in software. Once these are determined,
i
software will then calculate T
by dividing TN by N.
512
is the sum of the
N
5/16
Loading...
+ 11 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.