Un-Bricking an ATtiny13

Smashing Bricks

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:

-B bitclock

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.

About Jim Eli

µC experimenter
This entry was posted in Uncategorized and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s