I was playing with my ATtiny13 timer #0 fast PWM settings to test the range of frequencies I could achieve. I started with the fastest setting using the internal oscillator. 9.6MHz, no prescaler, no timer divider and using a TCNT0 count of 256 (ORC0A sets the duty cycle). This generated a PWM output of 37.6 kHz.
I slowly progressed to slower frequencies, setting the internal oscillator to 4.8MHz and a 256 prescaler and a 1024 clock divider. This resulted in a PWM output of 0.07Hz.
However, I could no longer program the ATtiny13. I couldn’t even change the fuse bits. It became completely unresponsive. I thought I bricked it.
However, this is when I discovered the –B argument to AVRDUDE. The AVRDUDE Manual states the –B option is for:
Specify the bit clock period for the JTAG interface or the ISP clock (JTAG ICE only). The value is a floating-point number in microseconds. The default value of the JTAG ICE results in about 1 microsecond bit clock period, suitable for target MCUs running at 4 MHz clock and above. Unlike certain parameters in the STK500, the JTAG ICE resets all its parameters to default values when the programming software signs off from the ICE, so for MCUs running at lower clock speeds, this parameter must be specified on the command-line. It can also be set in the configuration file by using the ’default_bitclock’ keyword.
The following AVRDUDE commandline resurrected my ATtiny13:
<br /><br /> avrdude –p attiny13 –c usbtiny –F –B 250 –U flash:w:attiny13.hex<br /><br />
See the ATMEL ATtiny13 datasheet for further information on the ATtiny13 Timer #0 PWM settings.