Loading...
Pages: [1]   Go Down
Author Topic: Software SPI library for Arduino Mega 2560  (Read 1397 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 16460
Available for Design & Build services
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Software SPI, isn't tat just shiftout() and shiftin() ?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 71
Posts: 6809
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Rob Gray aka the GRAYnomad http://www.robgray.com

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 71
Posts: 6809
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

12 bits, I was close smiley

Just grab the code form the shiftout/in lib and modify it.
______
Rob
Logged

Rob Gray aka the GRAYnomad http://www.robgray.com

Pages: [1]   Go Up
Print
 
Jump to: