Thansk a lot, has been really usefull for me!!!!!!!!!!!1
If you post some sample code it would be cool.
- 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.
/** SPI Interfaces*/#define SPI_INTERFACES_COUNT 1#define SPI_INTERFACE SPI0#define SPI_INTERFACE_ID ID_SPI0#define SPI_CHANNELS_NUM 4#define PIN_SPI_SS0 (77u)#define PIN_SPI_SS1 (87u)#define PIN_SPI_SS2 (86u)#define PIN_SPI_SS3 (78u)#define PIN_SPI_MOSI (75u)#define PIN_SPI_MISO (74u)#define PIN_SPI_SCK (76u)#define BOARD_SPI_SS0 (10u)#define BOARD_SPI_SS1 (4u)#define BOARD_SPI_SS2 (52u)#define BOARD_SPI_SS3 PIN_SPI_SS3#define BOARD_SPI_DEFAULT_SS BOARD_SPI_SS3
To find that constant definition, in an IDE window, select File>Preferences. Click in the URL at the bottom of the opened window: C:\Users\...\AppData\Local\Arduino15\preferences.txtThen follow this path:packages/arduino/hardware/sam/1.6.x/variants/Arduino-due-x/variant (an .H file)
You can try SPI library example sketches that you will find in : File>Example>SPI.AFAIK, any digital output pin can do the job for a chip select CS with the SPI library because this library do not leverage the automatic handling of the CS pin by the SPI0 peripheral.
If you program SPI registers (as I do) without the library, you can use one of the following 3 SPI CS pins: PA28 (CS0 = pin 10), PA29 (CS1 = pin 4), PB21 (CS2 = pin 52) and SPI0 peripheral will handle automatically the CS pin state. You can find these pins page 679, SPI section of Sam3x datasheet.
IMO CS3 = 78 is an error.
As previously stated, pin 78 isn't connected, but it is the hardware SS3 (CS3). You can't easily use it on a standard Due, but if you have a custom board you might have access to the pin, so it's no bad thing they have defined it, and it does appear on the circuit diagram. It definitely isn't an error.