Electronic – How to recover locked ATTiny 85

attiny85avrcrystal

I was following this tutorial: http://highlowtech.org/?p=1695 and by mistake I uploaded code with 8 MHz External clock settings.
The tutorial says

Warning: make sure you select “internal” not “external” or your microcontroller will stop working (until you connect an external clock to it)

Is it possible to unlock it without external crystal clock? If not, what crystal do I need to unlock it?

Thank you 🙂

Best Answer

You have two choices. Either use a high-voltage programmer to correct the fuses, or feed a clock signal into the CLKI (PB3) pin of the ATTiny.

In order to use ISP, the processor must have a clock signal. This can either be the internal oscillator, or an external oscillator. Once the processor is set to external clock, ISP will no longer work if there is no external clock signal.

The HV programmer can get around this by using a different programming mode to change the fuses and set them back to internal oscillator, allowing ISP to be re-enabled.

Alternatively, as you are using an Arduino as an ISP device, it is fairly easy to have the Arduino produce a clock signal that you can then feed into the ATTiny (even if the fuses are set to external oscillator as opposed to external clock, this will still work). You can add the following lines to the setup() function of the ArduinoISP sketch:

pinMode(3,OUTPUT);
TIMSK2=0;
OCR2A=0;
TCCR2A=(1<<COM2B0)+(1<<WGM21);
TCCR2B=(1<<CS20);

That will make use of Timer 2, and the OC2B pin (digital pin 3) to generate an 8MHz clock signal without affecting the operation of the ArduinoISP sketch.


It's been a while since I've tried this and wrote the above code based on looking at the datasheet registers, so there may be bugs/mistakes in it.