3
\$\begingroup\$

While experimenting with the power consumption of different clock rates by setting fuse bits, I seem to have irreversibly programmed an ATTiny84 chip to the 128kHz internal oscillator, and now avrdude can no longer establish SPI communication with the chip.

I've been using an Arduino Duemilanove to program the chip, with the "ArduinoISP" sketch.

Some avrdude command lines I've been using, if they help - my vain attempts to get it back to 1MHz:

avrdude -p t84 -C "C:\Program Files (x86)\arduino-1.0.4\hardware\tools\avr\etc\avrdude.conf" 
    -c stk500v1 -P COM7 -b 19200 -U lfuse:w:0x62:m -u

avrdude -p t84 -C "C:\Program Files (x86)\arduino-1.0.4\hardware\tools\avr\etc\avrdude.conf" 
    -c stk500v1 -P COM7 -b 19200 -U lfuse:w:0x62:m -u -B833 -i833

I've tried a lot of different delays in the -B and -i settings, ranging from 1 us to 10000 us. Output is:

avrdude: please define PAGEL and BS2 signals in the configuration file for part
ATtiny84
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.07s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
     Double check connections and try again, or use -F to override
     this check.


avrdude done.  Thank you.

Adding the -F option doesn't help - it tries to program, but the fuse setting doesn't take.

Have I lost this $2.50 chip forever? :)

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Did you take a look at this question from just a few hours ago? I believe that ArduinoISP is trying to program the chip too fast and that lower SPI clock for the programmer could help. \$\endgroup\$
    – AndrejaKo
    Apr 9, 2013 at 10:48
  • \$\begingroup\$ Interesting - sounds like precisely the same problem. Those -B and -i options are supposed to control SPI clock rate, but I don't think they're taking effect with the ArduinoISP programmer sketch. Maybe I'll try hacking that code tomorrow, see if I can slow down the SPI rate. \$\endgroup\$
    – QuadrupleA
    Apr 9, 2013 at 11:00
  • \$\begingroup\$ That looks like the solution to me. \$\endgroup\$
    – AndrejaKo
    Apr 9, 2013 at 11:01

3 Answers 3

4
\$\begingroup\$

OK - I found a version of the ArduinoISP sketch that supports a slow-speed option for the SPI programming:

https://github.com/adafruit/ArduinoISP/blob/master/ArduinoISP.ino

By defining the LOW_SPEED macro I was able to reprogram the fuse bits to the default 1 MHz. So problem solved.

\$\endgroup\$
1
  • \$\begingroup\$ Wow. I've been having issues with an ATTiny44A, getting random device signatures and sporadically being able to get a proper reading of the signature and fuse settings. This sketch fixed that right away. Didn't even need to set LOW_SPEED. Thanks! \$\endgroup\$
    – techrah
    Sep 13, 2022 at 10:57
2
\$\begingroup\$

https://github.com/lmpipaon/ArduinoISP_slow_SCK.git

ArduinoISP slow SCK

It is a modification of the sketch Arduino ISP allowing lower frequency of SCK to program microcontrollers with slow clocks, eg using the watchdog clock divided by 8.

When the programming mode begins ArduinoISP low frequency using the System Clock Prescaler.

When the programing mode finish the System Clock Prescaler is again set to 1

\$\endgroup\$
0
\$\begingroup\$

I sometimes get into this situation when I'm programming a part's Flash and fusebits separately (AVR Studio 4 claims that the part signature is wrong, so it won't let me use the .elf format).

I've tried lowering the programming clock rate as low as possible and like you, it doesn't work. What does work is desoldering the crystal and replacing it with a pulse generator set to 1MHz or so just long enough to reprogram the fuses. If you don't have a benchtop function generator, it should be quick to build a simple R/C or crystal pulse generator. Lots of schematics online and it's a useful tool to have around.

\$\endgroup\$
3
  • \$\begingroup\$ One approach I’m currently experimenting with (when using an Arduino as a programmer) is to simply use one of the PWM pins as a 1MHz pulse generator. \$\endgroup\$ Apr 9, 2013 at 15:35
  • \$\begingroup\$ Interesting - thanks - in my case the chip is using an internal 128kHz clock, so don't think I could influence it with any external clock changes. \$\endgroup\$
    – QuadrupleA
    Apr 9, 2013 at 18:19
  • \$\begingroup\$ Yes, I’m afraid @lyndon and I were going off on a tangent — if your MCU is set to an internal clock source, no external clock source could possibly make a difference. However, lowering the SPI clock rate does help — it’s just a matter of going to a software implementation, as paradoxically, the hardware implementation cannot be configured to be SLOW enough for your purposes. \$\endgroup\$ Apr 9, 2013 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.