30 September 2011

Calibrating AVR RC clock using a frequency counter (idea)

Not that I want to calibrate all my AVRs' internal RC clocks, but I want to test this non-automated procedure. These microcontrollers can be programmed to output a buffered version of the master clock (+ prescaler, if enabled) to the CKOUT pin. So, why not measure the output with a frequency counter?

Also, section 8.12.1 of ATmega168 manual describes the OSCCAL register, which should allow to change RC frequency during program execution.

So, why not build a simple firmware that sweeps through the OSCCAL value? Then with a big red button the operator interrupts the sweep when the frequency counter reads the desired value. Last but not least, either use an LCD to display the result or store the value in the onboard EEPROM for future reading.