0
\$\begingroup\$

I was playing around with setting the "system clock prescalar" (CLKPR).

I'm now in a situation where I can see that the clock is 244.9KHz, using my logic analyser and the "Clock output on PORTB0" fuse. (I am also using the /8 fuse.)

My code is still running on the ATMEGA, even after powering off/on.

AVRdude will no longer let me write to it, either to the flash or the to the fuses.

$ avrdude -p atmega328p -c avrispmkII -P usb -U flash:w:main.hex -F

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 = 0x88ab81
avrdude: Expected signature for ATmega328P is 1E 95 0F
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.

avrdude done.  Thank you.

Is there a failure mode where setting the AVR's clock too slow can make it unprogrammable?

The device's signature seems to have changed, it now randomly takes values which include:

  • 0x888b02
  • 0x88ab81
  • 0x886bf8
  • 0x888b02

I have already tried powering-off the ATMEGA and the AVR ISP MK-II.

Is there any way to fix this chip?

\$\endgroup\$
2
\$\begingroup\$

Programming clock speed is limited by the MCUs clock. If the MCU runs on a clock too slow programming at default speed will fail (as you see).

You can lower the programming clock speed by using the -B switch in avrdude, provided that you programmer hardware supports it.

\$\endgroup\$
  • 3
    \$\begingroup\$ Worth noting that this works for "real" programmers (and the command line seems to indicate that is what is in use) but has not historically been honored by improvised solutions like the Arduino-as-ISP sketch. So if it doesn't work, it's worth checking to make sure the ISP signaling has actually been slowed, rather than the request ignored by the programmer. \$\endgroup\$ – Chris Stratton Oct 20 '18 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.