ArduinoISP icon indicating copy to clipboard operation
ArduinoISP copied to clipboard

fix/workaround for SPI too fast

Open sylvandb opened this issue 13 years ago • 3 comments

I needed to program a slow clocked ATtiny2313.

Couldn't do it. Errors at various places -- reading signature, reading fuses, sync errors, etc. SPI clock was just too fast for my slow t2313.

I added USE_SPI macro wrapping the built-in SPI support, and added some #else cases with bitbanged SPI support and SUCCESS! Programed my t2313. (critical)

I also did some cleanup of the initialization of the SPI pins. This way the level is set before they become outputs instead of possibly driving one direction then immediately being changed. (possibly important)

And I played a bit with baud rate, SPI config, etc. as you can see. (might be nice to have the #defines)

Thoughts?

(I was using AVRDude 5.10, ubuntu 11.04, arduino 022 with latest arduinoISP sketch, 16mhz ATmega328.)

sylvandb avatar Jan 27 '12 09:01 sylvandb

I intended to make a pull request for an implementation with bit banged SPI too. Since yours predates mine by one year, I think it is only fair to start from your work.

My goal is to run ArduinoISP on the Due whose SPI is faster than the AVR based arduinos so bit banging is certainly needed. See: http://forum.arduino.cc/index.php?topic=156764.msg1249822#msg1249822

B.t.w. are you sure you need bit banging on a AVR based arduino? With the SPI clock divider set to 128, like in rsbohn's master, I can program an attiny @1MHz (maybe yours is clocked lower?)

Why is this not yet merged? Maybe because your implemenation still uses the AVR specific SPI registers instead of the SPI lib, like in rs_bohn's master?

I need the SPI lib based implementation too, because the implementation with AVR SPI registers does not work on the Due of coarse.

My plan is to pull from your master, and rework it to use the SPI lib (minor change), put the bitbang stuff in a mini class with the same interface as SPI.

PS: I am also interested in the changes related to not driving the SPI signals when not in programming mode.

PeterVH avatar May 31 '13 12:05 PeterVH

Has this project been abandoned? It looks like this pull request has been open for over three years now... Any chance for a resolution?

wahajenius avatar May 15 '15 18:05 wahajenius

I would like to pick things up again. I started again from rsbohn's last work and try to fix only things that make ArduinoISP more reliable or more portable to Due, Leonardo... This effort is in my master branch. There is no bit bang spi yet: I think this would better be handled by a SPI.setSpeed() method in the SPI lib (if the selected speed is too slow, the implementation could automatically switch to bit banged SPI).

PeterVH avatar May 17 '15 18:05 PeterVH