Go Down

Topic: Software SPI library for Arduino Mega 2560 (Read 5755 times) previous topic - next topic

davidlg007

Hi,
does anybody have a Software SPI library to use with the digital I/O of an Arduino Mega2560?
I have an arduino Mega2560 and the Sparkfun Host Usb shield, and I donĀ“t want to rewire the shield for conecting its SPI pins to the Harware SPI pins of the Arduino.
Regards.

CrossRoads

Software SPI, isn't tat just shiftout() and shiftin() ?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

dkelley

Yes, I have a similar issue. I want to port an existing duino shield to a mega but it uses SPI. I see that the sdfat library is capable of this but was wondering if anyone has distilled the software spi part out to be its own library?

thanks,
don

sleahey

It's fairly easy to bit bash it.

See attached example of a library that bit bashes the SPI.

The biggest problem is that its speed limited by the arduino clock speed. If you have a hardware SPI you can get it to go much faster.

You will need to read the datasheet for whatever you are interfacing to so that you know how to implement the SPI mode needed.

Hope it helps.

graynomad

As CR said bit bashed SPI is just shiftIn/Out, is there a special reason to do another version? Like you need 11 bits or something.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

sleahey

Quote
As CR said bit bashed SPI is just shiftIn/Out, is there a special reason to do another version? Like you need 11 bits or something.


The lib I attached is for 12 bit data and 2 dummy bits, so yea, this is why.

graynomad

12 bits, I was close :)

Just grab the code form the shiftout/in lib and modify it.
______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Go Up