Today I did a big mistake. I programmed wrong fuses on ATmega328P. Of course it was the fuse that sets external oscillator value instead of internal one.

I tried to fix it with STK500 programmer and Atmel Studio but without any luck. Then I started searching for solutions and I found one that worked in the end.

If you overload external oscillator with high frequency, you will be able to erase chip, and erase fuse settings. First I tried this with STK500 and Atmel Studio but without any success.

Then I tried small USBASP programmer and eXtreme Burner – AVR software and it could detect chip but not erase it. Because I supplied oscillator clock from signal generator I was able to change frequencies and to try to find which one would work. I have tested first clock simulation on 3-10KHz, but the one that worked for me was 4MHz with 5V amplitude, square wave. I was able to erase chip and then program it the right away. Just connect signal from signal generator to XTAL1 pin and you are good to go.

Of course, this took some time to do because of the following:

  • USBASP that I had was China copy, that Windows couldn’t recognize so I had to reprogram it with STK500
  • Then Windows wouldn’t recognize it or allow me to install driver because it wasn’t signed
    • To solve this press shift and restart Windows
    • On boot menu chose that you want advanced options
    • Then select startup settings and restart
    • When Windows restarts it will ask you which option do you want to enable or disable
    • Select “7. Disable driver signature enforcement”
    • Windows will boot and you can install driver that is not signed
  • You need to provide external power supply to the ATmega chip