2
\$\begingroup\$

Now, I know what you're thinking. I've been thinking it all night too.

Yes, I know that with the tiny fused for a 32 kHz crystal that I'll need the SPI clock to be 8 kHz or less. Even that, however, seems to not be working.

I started with a working board that had a 4 MHz crystal and divide-by-8 fusing. I first used a USBTiny to reset the fuses to the default using avrdude (62 DF FF). I then removed the crystal and its loading capacitors and tacked in a 32 kHz 12.5 pF crystal in its place. I then used the same USBTiny to set the fuses to E6 DF FF. And that's all she wrote.

With a scope, I can peek at the xtal pins and I can see 32 kHz. So I suspect the clock is running.

I knew that I'd be adding -B to the avrdude command line. Before I started all this, I experimented with various values of -B and a flash read. Sure enough, altering -B made the flash read happen faster or slower.

But I've tried adding -B values up to 250 (which I read on this page should result in a 4 kHz SPI clock). Nothing. I've tried using at least 6 different versions of the AVR-as-ISP-but-slowed-down concept with an Arduino Uno. None of them work. All of them work with an unmodified version of the device I started with (with its 4 MHz crystal and original fusing), so I'm confident the wiring is correct.

What else could it be?

\$\endgroup\$
5
  • \$\begingroup\$ I had success in the past with rickety.us/2010/03/arduino-avr-high-voltage-serial-programmer Notice that the fuses are hard coded for a specific AVR, so check the source code. \$\endgroup\$
    – jippie
    Oct 3, 2014 at 12:22
  • \$\begingroup\$ I shouldn't have to resort to HV programming, though. Why doesn't normal ISP work? \$\endgroup\$
    – nsayer
    Oct 3, 2014 at 14:04
  • \$\begingroup\$ How slow did you get the clock - down into the 100Hz range? I assume when you say you slowed down the Arduino-as-ISP sketch, you did it by inserting delays in the program code (iirc in many versions the -B flag is not honored). \$\endgroup\$ Oct 3, 2014 at 15:33
  • \$\begingroup\$ If you Google, there are at least a half dozen copies of the AVR ISP sketch that slow the SPI clock a number of ways. I don't know how slow it wound up, but to work it would have needed to be ~250 Hz, which is just silly. \$\endgroup\$
    – nsayer
    Oct 3, 2014 at 15:40
  • \$\begingroup\$ Hence a comment and not an answer. It is good to have a last resort, but in the mean time you solved it the proper way. \$\endgroup\$
    – jippie
    Oct 3, 2014 at 18:22

1 Answer 1

3
\$\begingroup\$

I figured it out.

Fuse changes don't erase the flash. The previous sketch started with setting the system clock prescaler to divide-by-8. The clock prescaler survives RESET.

The fix was to temporarily tie RESET low. That way I had a chance to attach the programmer and power up without the prescaler setting taking place. I uploaded a new sketch without the prescaling and it works now.

\$\endgroup\$
2
  • \$\begingroup\$ Congrats... was just wondering if the divider was still in, and if you were trying it slowly enough to allow for it. \$\endgroup\$ Oct 3, 2014 at 15:34
  • \$\begingroup\$ Since it wasn't working, it must not have been slow enough. But at the time I didn't think it would have to be less than 1 kHz. \$\endgroup\$
    – nsayer
    Oct 3, 2014 at 15:46

Your Answer

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

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