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 sayingavrdude: 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)
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
Then append the line
AVRDUDE_FLAGS += -B250
No comments:
Post a Comment