I'm using an atmega168 device which I have programmed to control an ultrasonic range finder and show the distance it returns on a 7-segment LED display. It was running with the internal 8Mhz clock and these fuses:
- low: 0xe2
- high: 0xdf
In an effort to run it at lower power, I updated the fuse settings to use the internal 125kHz clock, these settings:
- low: 0xe3
- high: 0xdf
After this change I was no longer able to program the device (I'm using the Atmel AVR ISP mkII programmer), getting the error:
$ avrdude -F -p atmega168 -P usb -c avrisp2 -U flash:w:main.hex avrdude: stk500v2_command(): command failed avrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Unknown status 0x00 avrdude: initialization failed, rc=-1 avrdude: AVR device initialized and ready to accept instructions avrdude: Device signature = 0x000000 (retrying) avrdude: Device signature = 0x000000 (retrying) avrdude: Device signature = 0x000000 avrdude: Yikes! Invalid device signature. avrdude: Expected signature for ATmega168 is 1E 94 06 avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed To disable this feature, specify the -D option.
I remembered that there was a '-B' flag for setting the clock period, with '1' representing 1 microsecond. With 1/125,000, that's 8us, so I tried adding '-B 8' to the avrdude command and I still get the same error. I'm not sure if I need to update the default baud value with '-b', so I tried using a pretty low value '-b 300', but that also had no effect.
As a final note, the code that is already loaded on the device still works. On startup, it counts from 0 to 9 on the 7-segment display. I did not update the F_CPU value in code, so I see it counting up 64 times more slowly than before. So, the device itself is still operational.
Is there something I'm missing here? How does one program an AVR running at a low clock frequency? I've searched every way I can think of on this forum and the general internet for answers and nothing really seems to come up that helps.