Tunable RC Oscillator

An RC oscillator whose frequency can be trimmed by software is called a tunable RC oscillator. In AVR devices, the Oscillator Calibration Register (OSCCAL) is used for this purpose. It can be used to trim the calibrated internal RC oscillator to remove process variations from the oscillator frequency, as shown in the figure below. The OSCCAL register is one byte wide.

Figure 1. Calibrated 8MHz RC Oscillator Frequency vs. OSCCAL Value (ATmega8)

When an RC oscillator in a device is factory calibrated, the calibration byte is stored in the Signature Row of the device. The calibration byte can vary from one device to the other, as the RC oscillator frequency is process dependent. If a device has more than one oscillator, a calibration byte for each of the RC oscillators is stored in the Signature Row.

In most devices, the default RC oscillator calibration byte is automatically loaded from the Signature Row and copied into the OSCCAL register at start-up. For example, the default ATmega8 clock setting is the internal 1MHz RC oscillator; for this device the calibration byte corresponding to the 1MHz RC oscillator is automatically loaded at start-up. If the fuses are altered so that the 4MHz oscillator is used instead of the default setting, the calibration byte must be loaded into the OSCCAL register manually. A programming tool can be used to read the 4MHz calibration byte from the Signature Row and hence store it in a Flash or EEPROM location, which is read by the main program and copied into OSCCAL at run-time.