Pages: [1]   Go Down
Author Topic: Summary of mysteries about SPI and extended SPI library with Due  (Read 1895 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 3
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
    arduino-1.5.1r2\hardware\arduino\sam\variants\arduino_due_x\variant.h
  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?

Logged

Brazil
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

US
Offline Offline
Full Member
***
Karma: 4
Posts: 183
Electronics are the new Legos
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you post some sample code it would be cool.
Logged

Offline Offline
Jr. Member
**
Karma: 3
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Thansk a lot, has been really usefull for me!!!!!!!!!!!1
Happy to help you!
Quote
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


Logged

Pages: [1]   Go Up
Jump to: