The programming tool writes the
calibration firmware into the device and possibly enables the MISO pull-up, and releases
the reset line. If the JTAG interface is used, the JTAG disable bit in MCUCSR is set by
the calibration firmware in the device. The calibration clock (approximately 32kHz) is
applied on the MOSI line by the programming tool.
The device enables the internal pull-up on the MOSI line, sets the MISO line high, and
starts listening for the calibration clock on MOSI.
When the device detects the calibration
clock a binary search is performed to find an OSCCAL value that meets the criteria of 1%
accuracy. If the binary search does not reveal a value that meets this requirement, the
neighboring values of the outcome of the binary search are tested to identify one that
does. If calibration fails the MISO line is set low and program flow goes to step
6.
The calibration value is stored in EEPROM (skipped if calibration fails).
The MISO line is toggled 8 times/4
cycles by the device. The toggling of the MISO line is performed on the falling edge of
the clock on the MOSI line (C-clock), but 5 to 10 CPU cycles delayed. In the case of
failing calibration the MISO line is not toggled.
If necessary, the JTAG interface is re-enabled and the device goes into an infinite
loop.
If the device does not have an EESAVE
fuse, the programmer must read back the calibration byte from EEPROM, for later
restoring when the calibration firmware has been erased from the flash memory. If the
device has an EESAVE fuse, this fuse can be set so that erasing the Flash does not also
erase the EEPROM. It is necessary to copy the calibration byte from EEPROM or FLASH to
the OSCCAL register at run-time. A routine for this must therefore be implemented in the
final firmware.
The online versions of the documents are provided as a courtesy. Verify all content and data in the device’s PDF documentation found on the device product page.