The other day I was writing a program for an ATtiny2313. Once it worked I decided to test it at the various clock speeds that are available and programmed through setting the LFUSE as described on page 159.
- The default clock speed is 1MHz;
- so I tried 8MHz next and all worked fine;
- Then I set the clock speed for 4MHz with the /8-prescaler resulting in 500kHz clock.
Although the controller runs the program at the expected speed, my programmer refuses to reprogram the controller since. avrdude
(5.11.1) just throws the well known: 'Yikes!':
avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.
I tried adding the -F
flag, but of course that didn't either.
Here are some code sniplets I used and changed the clock speed as expected:
// 0.5MHz
FUSES = { .low = 0x62 , .high = HFUSE_DEFAULT , .extended = EFUSE_DEFAULT , };
// 1MHz (default)
FUSES = { .low = 0x64 , .high = HFUSE_DEFAULT , .extended = EFUSE_DEFAULT , };
// 8MHz
FUSES = { .low = 0xe4 , .high = HFUSE_DEFAULT , .extended = EFUSE_DEFAULT , };
For programming, I use an Arduino with the ArduinoISP (version 04m3) sketch that came with Arduino IDE 1.0.1.
This is the command to program flash:
avrType=attiny2313
avrFreq=1000000
programmerDev=/dev/ttyUSB003
programmerType=arduino
avrdude -p$(avrType) -c$(programmerType) -P$(programmerDev) -b$(baud) -v -U flash:w:$(src).flash.hex
This is the command to program the fuses:
avrdude -p$(avrType) -c$(programmerType) -P$(programmerDev) -b$(baud) -v -U lfuse:w:$(src).lfuse.hex
My question is twofold:
- What is the reason I cannot program the controller after setting it to 500kHz clock (while the program in the controller seems to run just fine);
- What are my options for reprogramming the fuses without using a HV-programmer? Did I perhaps miss any useful flags to
avrdude
?
BTW: Had the same issue once with an ATtiny45 @ 128kHz. HV-programming solves it, but I want to prevent the HV situation.
No comments:
Post a Comment