TINYICOC – AVR IN-CIRCUIT OSCILLATOR CALIBRATOR

Summary of TINYICOC – AVR IN-CIRCUIT OSCILLATOR CALIBRATOR


Stefan Wagner's TinyICOC automates AVR internal oscillator calibration. Connected via ICSP, it programs the target MCU to output a test signal on MOSI at half the clock; with a clock prescaler of 8 this yields 1/16 of oscillator frequency. The ATtiny84 measures this via timers, compares to a target, adjusts OSCCAL, stores it in EEPROM, and the target MCU applies it. The cycle repeats until the optimal OSCCAL minimizing frequency deviation is found.

Parts used in the TinyICOC – AVR In-Circuit Oscillator Calibrator:

  • TinyICOC device (project board)
  • Target AVR MCU (e.g., ATtiny84)
  • ICSP header for connection
  • Push button on TinyICOC
  • Integrated In-Circuit Serial Programmer (ICSP) firmware
  • EEPROM on target MCU
  • MOSI pin connection between programmer and target
  • Timers inside the ATtiny84 (used for frequency measurement)

Stefan Wagner published another great project on Github. He writes:

Sometimes AVRs are operated without an external clock. The internal oscillator does a good job in most applications, but when it comes to precise timing, it is too inaccurate.

TINYICOC – AVR IN-CIRCUIT OSCILLATOR CALIBRATOR

The accuracy of the oscillator of an AVR is only +/-10%. Fortunately, the oscillator can be calibrated, increasing its accuracy to +/-2% or better. There are a few ways to perform this manual calibration, but several steps are required. The TinyICOC does this fully automatically. Simply connect the device to the target MCU via the ICSP header and press the button.

To carry out the calibration, a program is first uploaded to the target MCU using the integrated In-Circuit Serial Programmer (ICSP). This program applies an oscillating signal with half the clock frequency to the MOSI pin of the target MCU. Since the fuses were previously set so that the target MCU clock runs with a prescaler of 8, a signal with 1/16 of the oscillator frequency is applied to that pin. This frequency is measured by the timers of the ATtiny84 and compared with the target value. The oscillator calibration value (OSCCAL) is then adjusted accordingly and written into the EEPROM of the target MCU. This value is in turn read by the target MCU and written to its OSCCAL register. This process is repeated until the OSCCAL value, which leads to the lowest frequency deviation, has been found.

Read more: TINYICOC – AVR IN-CIRCUIT OSCILLATOR CALIBRATOR

Quick Solutions to Questions related to TinyICOC – AVR In-Circuit Oscillator Calibrator:

  • What problem does the TinyICOC solve?
    It automates calibration of an AVR internal oscillator to improve accuracy from about +/-10% to around +/-2% or better.
  • How is the TinyICOC connected to the target MCU?
    Via the ICSP header.
  • What does the TinyICOC do first to carry out calibration?
    It uploads a program to the target MCU using the integrated ICSP programmer.
  • Which pin outputs the oscillating test signal on the target MCU?
    The MOSI pin outputs the oscillating signal.
  • Why is the test signal frequency 1/16 of the oscillator frequency?
    Because the program outputs half the clock frequency and the target MCU clock runs with a prescaler of 8, resulting in 1/16 of the oscillator frequency on the MOSI pin.
  • How does the TinyICOC determine the correct OSCCAL value?
    The ATtiny84 measures the test frequency with its timers, compares it to a target, adjusts OSCCAL, writes it to EEPROM, and the MCU applies it; the process repeats until the best value is found.
  • Where is the calibration value stored on the target MCU?
    The OSCCAL value is written into the target MCU's EEPROM.
  • Does the TinyICOC require manual multi-step calibration?
    No, it performs the calibration fully automatically when connected and the button is pressed.

About The Author

Muhammad Bilal

I am a highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.