I am working with 2 Arduino Due boards and trying to make them communicate using SPI. I am not able to make the Due bard work as a slave.
I'm wondering if anyone has made any progress on that matter.
I have tried the code is the following link but have had no luck in making it work.
// SPI slave for DUE, hack
// master will lower CS and manage CLK
// MISO to MISO MOSI to MOSI CLK to CLK CS to CS, common ground
// http://forum.arduino.cc/index.php/topic,157203.0.html
// core hardware/arduino/sam/system/libsam/source/spi.c
// TODO: C class, interrupt, FIFO/16-bit, DMA?
#include <SPI.h>
// assumes MSB
static BitOrder bitOrder = MSBFIRST;
void slaveBegin(uint8_t _pin) {
SPI.begin(_pin);
REG_SPI0_CR = SPI_CR_SWRST; // reset SPI
REG_SPI0_CR = SPI_CR_SPIEN; // enable SPI
REG_SPI0_MR = SPI_MR_MODFDIS; // slave and no modefault
REG_SPI0_CSR = SPI_MODE0; // DLYBCT=0, DLYBS=0, SCBR=0, 8 bit transfer
}
This file has been truncated. show original
If anyone has a working code, please help me out.
MorganS
February 18, 2016, 7:59am
2
Yes, there's a lot more tutorials on I2C slaves. It should work just fine with the UNO code posted by Nick Gammon here: Gammon Forum : Electronics : Microprocessors : SPI - Serial Peripheral Interface - for Arduino
I haven't tried it.
I am actually looking for SPI and not I2C. I want duplex communication with multiple slaves.
MorganS
February 23, 2016, 9:02am
4
Yes, that is what's in the link.