Sunday, January 1, 2017

Programming low frequency microcontrollers in WinAVR

Fixing clock incompatibility between microcontroller and ISP programmer

I was working on a low power project using ATtiny13 so I have decided to use the 128kHz internal oscillator as a CPU clock to save power. All went well but when I tried to modify the code and upload again an error message appeared in WinAVR saying

avrdude: initialization failed, rc=-1

After some research I found out what was going on.

Clock too slow for ISP programmer

The ISP programmer must have a speed lower than the microcontroller. 4 times lower is recommended.
The solution is to lower the ISP clock speed by using -B bitclock option. -B250 worked fine.

Example in avrdude. I use USBTinyISP programmer:

avrdude -p attiny13 -P usb -c usbtiny -B250

Append arguments in WinAVR

Open the make file and fin these lines (starting from line ~ 300)


Then append the line