A GitHub user called Wagiminator has posted details about ATtiny84-TinyCalibrator, which is an OSC Calibrator and High Voltage Fuse Resetter for 8-Pin ATtinys. The ATtiny84 was chosen as the microcontroller for the TinyCalibrator because it has exactly the necessary number of GPIO pins. 8-pin ATtinys usually feature few GPIO pins available, so they are usually operated without an external clock. However, its internal oscillator performs well in most applications, but when it comes to precise timing, its +/-10% accuracy is often insufficient. This problem can be solved, the oscillator can be calibrated, therefore increasing its accuracy to +/-2% or more. You can perform this calibration in various ways, and the TinyCalibrator can do this fully automatically by a push of a button.
For the project hardware, Wagiminator made use of a micro USB connector to supply the TinyCalibrator with 5V. He also integrated an HT7333 voltage regulator to power the oscillator. Then he added a switch which he used to to choose whether the oscillator should be powered for 3.3V or 5V. To give out accurate frequency measurements, he operated the ATtiny84 with an external 12 MHz crystal. Since the current software version only requires about 3.7 kByte, an ATtiny44 can also be used. He chose an ST6624 charge pump IC to generate the 12V for the High Voltage Serial Programmer, which was specially designed for such applications and needs only a few external components. The 12V was controlled by a MOSFET and applied to the RESET pin of the target ATtiny if need be, then he protected the remaining programming lines to the target against a short circuit with resistors. For the user interface, He utilizes three buttons and a 128×64 pixels OLED display.
In order for him to carry out the calibration, he uploaded a program to the target ATtiny using the integrated High Voltage Serial Programmer. Also, the factory oscillator calibration value (OSCCAL) is written to the EEPROM. The software programming on the target ATtiny reads the EEPROM and writes the value to the OSCCAL register. It then applies an oscillating signal with half the clock frequency to pin PB0. He notes that “Since the fuses were previously set so that the target ATtiny runs with a prescaler of 8, a signal with 1/16 of the oscillator frequency is applied to PB0.” The code for the High Voltage Serial Programmer (HVSP) has a spectacular approach. The way it is designed is that for each action, a series of instructions are sent over the data lines to the target ATtiny and the corresponding response is read. The process and the instructions are well described in the data sheet above. For the frequency measurement, the timer/counters of the ATtiny84 carry out the measurement. The oscillator frequency of the target ATtiny can be calculated easily. He connected the PB0 of the target ATtiny, which outputs a signal with 1/16 of its oscillator frequency to the T0 input of the ATtiny84, the Timer0 then counts the pulses at T0 and timer1 stops the measurement after a time of 32 milliseconds.
Read more: ATTINY84 OSC CALIBRATOR AND HIGH VOLTAGE FUSE RESETTER