beautypg.com

1 recalibrating the r, 1 recalibrating the rc oscillator -10, Maxq7667 user’s guide – Maxim Integrated MAXQ7667 User Manual

Page 262

background image

15.3.1.1 Recalibrating the RC Oscillator

The MAXQ7667 has an internal RC oscillator that is factory calibrated to approximately 13.5MHz. Although the oscillator is factory cali-

brated, its frequency drifts with temperature and supply voltage. If precision timing is required, the MAXQ7667’s precision crystal-con-

trolled oscillator must be used, or the RC oscillator must be recalibrated to account for any frequency drift.

The frequency of the RC oscillator is controlled by the 9-bit, two’s complement value stored in the RCTRM register. This register allows

the oscillator frequency to be changed by approximately ±25%, with a resolution of 0.2% (1/512 = 0.2%). The large adjustment range is

needed to accommodate process variations that affect the oscillator frequency. As part of the manufacturing process, the trim value

needed to set the RC oscillator to 16MHz is determined and stored in nonvolatile memory. During the power-on-reset process, this value

is read from nonvolatile memory and written to the RCTRM register. If an accurate external time reference is available, it is possible for

the application code to recalibrate the RC oscillator by changing the value of the RCTRM register and storing it in the flash somewhere.

During power-up, the factory default is loaded in the RCTRM register; therefore, it is up to the user application to load the new value dur-

ing power-up in the RCTRM register. A precisely tuned RC oscillator can eliminate the need for a precision resonator or crystal.

The first step in recalibration is to determine the amount of frequency error in the RC oscillator. This is done by using the MAXQ7667

to measure the duration of an external event that has an accurately know duration. The external event with a known time duration can

take several forms. It can be a single pulse applied to a timer control pin, or it can be two commands on an I/O port with a fixed inter-

val between them. It could even come from timestamped commands on an I/O port, which allows a time interval to be accurately cal-

culated. Regardless of the method used, the goal is the same: to determine the amount of error in the RC clock.

When measuring the reference time, there is a nominal number of system clock cycles that would occur during the reference time if

the system clock were operating at exactly 16MHz. Let C

N

equal this nominal number of system clock cycles, and let C

A

equal the

number of system clock cycles that are actually measured during the reference time. The percent error in the oscillator frequency O

E

can then be calculated by using Equation 1.

Equation 1:

O

E

= [(C

A

/C

N

) - 1] x 100

Since the adjustment resolution is 0.2%, the value of RCTRM needs to change by five counts for every percent error in the oscillator

frequency.

∆RCTRM = -5 x O

E

Because the initial RCTRM value varies significantly from part to part, it is important that new RCTRM values are always based on the

existing RCTRM value and the calculated change. All these concepts and equations are brought together in Equation 2.

Equation 2:

newRCTRM = oldRCTRM – [(C

A

/C

N

) - 1] x 500

The new value of RCTRM remains in effect until there is a power-on reset. At that time the original factory calibration value will be loaded

into RCTRM. RCTRM is not changed by a software reset.

Recalibration is needed whenever the voltage and temperature conditions change enough to cause a “significant” frequency error or

timing error. What is considered “significant” must be decided by the individual user, as this varies depending on the application.

RC Oscillator Recalibration Example:

Assume that a reference pulse of exactly 25ms is measured using a timer with the prescaler set to 16. If the RC oscillator were running

at exactly 16MHz, then each clock cycle would be 0.0625µs long. Because the prescaler on the timer is set to 16, each count of the

timer will be equal to 16 system clocks or exactly 1µs. Over the time of the 25ms reference pulse, the timer should nominally accumu-

late 25,000 of the 1µs clocks, so C

N

= 25,000.

Now assume that the actual number of clock cycles (C

A

) counted by the timer is 25,355 and that the value read from RCTRM is -125.

By plugging this data into Equation 2, the correct value for RCTRM can be found:

-125 - (25,355/25,000 - 1) x 500 = -132

The correct new value for RCTRM is -132 (or 0xFF7C in two’s complement).

It is recommended that a reference pulse be measured again after calibration to verify the calibration.

_________________________________________________________________________________________________________

15-10

MAXQ7667 User’s Guide