Skip to content
A C implementation of the OSCCAL algorithm in Atmel's App Note AVR053
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
Makefile Update documentation Jan 14, 2016


A C implementation of the OSCCAL algorithm in Atmel's App Note AVR053


Atmel's AVR MCUs have internal oscillators that come factory-calibrated with a 10% tolerance. Applications using the internal oscillator and requiring an accurate clock should calculate a new calibration value given in-circuit voltage and temperature conditions.

App Note AVR053 describes a protocol for doing this automatically with the ISP interface. This is an implementation in C, for convenience and portability. It may be used in conjunction with either avrdude or atprogram (part of Atmel Studio) for the actual calibration.

For maximum portability, this implementation follows the recommendations of AVR053 in avoiding interrupts and using the 8-bit timer, which should allow it to run on any AVR device.


This code is under the BSD-2-Clause license.


Edit the constants at the top of the makefile. Then run:

make install
make calibrate

The calculated OSCCAL value will be stored in EEPROM at address 0x00. Note that the EESAVE fuse must be set, or it will be erased as soon as you flash your final code.

Your final code should then read EEPROM address 0x00 during startup and write it to OSCCAL.

You can’t perform that action at this time.