I accidentally changed the fuse bits on my ATmega644PA chip so that it is expecting a 32.768 kHz signal in the XTAL1/XTAL2 inputs. I am using the a USBTiny programmer (the Sparkfun AVR Pocket Programmer), which I read needs to operate at a clock speed slower than whatever clock the ATmega uses. I have access to a function generator, so I was thinking of generating a 32.768 kHz 5 Vpp clock and putting the positive end on the ATmega XTAL1 pin, and the negative end to ATmega GND pin. Is this the correct way to do things?
Also, how do I configure the programmer to use a much slower clock? I understand that the
-B argument for
avrdude specifies the clock period for the programmer. For instance:
avrdude -c usbtiny -p atmega644p -B 250
would specify a 4 kHz clock. But from the avrdude help page, the
-B option seems to specify the clock period only for JTAG (and whatever STK500v2 is), but I am using SPI.
-B <bitclock> Specify JTAG/STK500v2 bit clock period (us).
How exactly can I proceed to change the fuse bits back to using the internal calibrated 1 MHz clock?
The fuse accident happened when I erroneously flashed
-U hfuse:w:0xd9:m -U lfuse:w:0x24:m
which are the settings for atmega8, not atmega644p. What this did was make the clock input be "Low Frequency Crystal Oscillator" (i.e., expects a 32.786 kHz external clock), changed the SUTs, and finally, it disabled JTAG (JTAGEN bit, but I use no JTAG ports for programming so I do not think this is a problem).
When I finally am able to talk to the chip, I would like to flash the factory default ATmega644P fuses:
-U lfuse:w:0x42:m -U hfuse:w:0x99:m -U efuse:w:0xFF:m -U lock:w:0xFF:m