Go Down

Topic: Summary of mysteries about SPI and extended SPI library with Due (Read 5625 times) previous topic - next topic


I succeed to put on work an Arduino Due, an Ethernet shield, a SD card and a MP3 Shield from Sparkfun, using the following libraries:
- Ethernet library from Arduino. Use extended SPI functions with pin 10 as chip select
- SdFat library from Bill Greiman. Use former SPI functions. Chip select is 9
- SFEMP3Shield from Bill Porter and Michael Flaga. I modified it and use extended SPI functions with pin 4 as chip select

All of them used intensively the SPI bus.
Of course, it did not work at first try. So I read (all ?) the posts about SPI and Due in this forum, and I make a lot of tries.
I will summarize all the information I read and discover about SPI and Due.

- pins for Chip Select. It can be any digital pin of Arduino Due. But only pins 4, 10 and 52 gives advantages of extended SPI

- particularity of pin 52. It is the "Board Spi default chip select". BOARD_SPI_DEFAULT_SS is defined in
  as BOARD_SPI_SS2 defined in the same file as pin 52
  That is to say that calling SPI.begin() is the same as calling SPI.begin( 52 ).
  So if you have a device using former SPI functions ( like SdFat ) , whatever it use a different pin for chip select, you cannot use pin 52 as chip select for an other device.

- pinmode( CS, OUTPUT ) . Do not include this instruction in your sketch for pins 4 and 10.

- advantages of extended SPI library? With other pins than 4, 10 and 52: none. When you have 2 or more devices using SPI, you have to reprogram attributes (speed, datamode, ...) and to set chip select to low before doing a transfer. If you read from a device to write to an other (ethernet to SD card, SD card to MP3, ...), this is a big constrain. With extended SPI using pins 4, 10 or 52, no need to do this. Only call SPI.transfer

- use of additional parameter SPI_CONTINUE or SPI_LAST (the default) with SPI.transfer . I have no absolute answer.
  Sometime it works without specifying  SPI_CONTINUE, sometime it works only if you specify it, sometime it don't work if you specify it.

I hope this would help.
Any body has more information?


Thansk a lot, has been really usefull for me!!!!!!!!!!!1



Thansk a lot, has been really usefull for me!!!!!!!!!!!1

Happy to help you!
If you post some sample code it would be cool.

I now replace the Ethernet shield with a faster WIZ820io (see that post on the forum)
I explain here how to put together the parts and how to load and modify the libraries.
In my fork of SFEMP3Shield there is an example (WebRadio.ino) that use that hardware to listen to streamed radios up to 320 kb/s


hi, I was wondering how you connected the hardware since I have due and I see that due doesn't have pin 11,12 and 13 as SPI bus signals. I researched for a while and this is the best post out there on MP3 Shield + Arduino Due using SPI bus. Please help, I'd very much appreciate it.


Hi, I need some help with a project. I currently have a due running a coldtears 7' TFT with sd shield and have been trying to hook up a Ladyada pt100 shield to read an rtd as well. I can hook up both individually and get them to run, however I cannot get the pt100 to read as well when the tft is set up. The tft shield uses pin 53 as cs pin. Can anyone show me some code for using the extended spi so I can figure out how to get the rtd to read?
Any help would be greatly appreciated.

Go Up