Datasheet

30
8024A–AVR–04/08
ATmega8HVA/16HVA
being enabled by the OSI module. Hence, the calibration algorithm may use the time between
the first and second osi_posedge as time reference for calculations.
Another usage of OSI is determining the ULP frequency accurately. The ULP frequency at T
HOT
and the ULP temperature coefficient are stored in the signature row, allowing the ULP frequency
to be calculated directly. However, the ULP frequency is less predictable over temperature than
the Slow RC oscillator frequency, therefore a more accurate result can be obtained by calculat-
ing the ratio between the Slow RC and ULP oscillators. This is done by sampling both the ULP
and Slow RC oscillators and comparing the results. When the ratio is known, the actual ULP fre-
quency can be determined with high accuracy. The ULP RC clock period as a function of the
Slow RC clock period is given by:
where n is the number of prescaled ULP RC and Slow RC periods that is used in the measure-
ment. Using more prescaled ULP RC and Slow RC periods decreases the measurement error,
but increases the time consumed for calibration. Note that the FOSCCAL register must be kept
at a constant value during this operation to ensure accurate results.
These clock period calculations should be performed again when there is a significant change in
die temperature since the previous calculation. The die temperature can be found using the Volt-
age ADC, refer to section ”Voltage ADC – 5-channel General Purpose 12-bit Sigma-Delta ADC”
on page 112 for details.
9.13 Register Description
9.13.1 FOSCCAL – Fast RC Oscillator Calibration Register
Bits 7:0 – FCAL7:0: Fast RC Oscillator Calibration Value
The Fast RC Oscillator Calibration Register is used to trim the Fast RC Oscillator to remove pro-
cess variations from the oscillator frequency. The factory-calibrated value is automatically
written to this register during chip reset, giving an oscillator frequency of 8.0 MHz at 70°C. The
application software can write this register to change the oscillator frequency. The oscillator can
be run-time calibrated to any frequency in the range 7.3-8.1 MHz. Calibration outside that range
is not guaranteed.
Note that this oscillator is used to time EEPROM and Flash write accesses, and these write
times will be affected accordingly. If the EEPROM or Flash are written, do not calibrate to more
than 8.1 MHz. Otherwise, the EEPROM or Flash write may fail.
The FCAL[7:5] bits determine the range of operation for the oscillator. Setting these bits to
0b000 gives the lowest frequency range, setting this bit to 0b111 gives the highest frequency
range. The frequency ranges are overlapping. A setting of for instance FOSCCAL = 0x1F gives
a higher frequency than FOSCCAL = 0x20.
T
ULPRC
T
SlowRC
number of CPU cycles in n prescaled ULP RC periods
number of CPU cycles in n prescaled Slow RC period
s
---------------------------------------------------------------------------------------------------------------------------------------------
--- -
=
Bit 76543210
(0x66) FCAL7 FCAL6 FCAL5 FCAL4 FCAL3 FCAL2 FCAL1 FCAL0 FOSCCAL
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value Device Specific Calibration Value