Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/workaround for SPI too fast #2

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Conversation

sylvandb
Copy link

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.)

PeterVH pushed a commit to PeterVH/ArduinoISP that referenced this pull request Jul 23, 2012
String examples corrections from Federico Vanzati merged.
@PeterVH
Copy link

PeterVH commented May 31, 2013

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.

@@ -340,41 +465,39 @@ uint8_t write_flash_pages(int length) {
}

#define EECHUNK (32)
uint8_t write_eeprom(int length) {
uint8_t write_eeprom(unsigned length) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is missing here. I guess you wanted to write unsigned int.

@wahajenius
Copy link

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

@PeterVH
Copy link

PeterVH commented May 17, 2015

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants