Bricked processor? -- Too slow a clock for USBTinyASP

I set the clock on my Atmega328 to 62.5kHz by altering the prescale register at the beginning of setup(). Now I can't load a new sketch. I was imagining that the avrdude would reset the prescaler before trying to a download. I don't why I thought that.

So should I just throw this $3 IC into the garbage can or is there a way to fix it?

Is it running from the internal oscillator?

Are you trying to program it via serial port - standard Arduino? If yes, then there is problem with the bootloader probably. The bootloader works correctly for specific clock frequency which has to be defined during its build process. You have to replace it with an apprpriate version of bootloader.
In the second case if you are using ISP for programming without Arduino, there is possibility of incorrect clock settings, e.g. if the MCU has an external clock presets and crystal or external clock signal is missing, the MCU won’t start.There is simple help in this case - just connect clock signal to XTAL1 pin. You can use another Arduino with modified Arduino ISP sketch for clock output.
The third case could be another reason of bricked MCU. It could be reprogrammable with parallel programming. Search this forum. It was already discussed.
And finally, the last case is possibility of destroyed MCU.

Thanks for the quick responses!

I was able to figure it out. I used the -B250 option on avrdude.

In case you're curious, it was running with a 16MHz resonator. I am programming the chip (on a breadboard) with a USBtinyISP device. I added these two lines to setup();

CLKPR = 0x80; CLKPR = 0x08;

I knew it would slow the clock way down but I didn't think it would persist after a reset by the ICSP programmer. Live and learn.

I believe those sorts of changes persist until the processor is released from reset. A fast double reset should also have gotten you what you want (but would very likely have required you modifying ArduinoISP).

Yes, I couldn't double click the reset button that fast. But I thought of another way that might work.

What if I cycled the power while keeping the reset button depressed and then tried to download? Do you think it would work?


In addition...

28.7.1 Enter Programming Mode The following algorithm puts the device in Parallel (High-voltage) Programming mode: 1. Set Prog_enable pins listed in Table 28-14 on page 292 to “0000”, RESET pin to 0V and VCC to 0V. 2. Apply 4.5 - 5.5V between VCC and GND. Ensure that VCC reaches at least 1.8V within the next 20 μs.

28.8.2 Serial Programming Algorithm 1. Power-up sequence: Apply power between VCC and GND while RESET and SCK are set to “0”. In some systems, the programmer can not guarantee that SCK is held low during power-up. In this case, RESET must be given a positive pulse of at least two CPU clock cycles duration after SCK has been set to “0”.

When programming a target, Atmel recommends applying power while RESET is asserted.

Thanks. I've spent a fair amount of time looking at that datasheet but there's so much there. And it's just one processor.

I am curious to see your reaction to the SAM datasheets.

Ha! I have looked at one of them. And the processor that the Teensy uses as well.