SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By s3b
I am hoping to get two SparkFun SAMD21 Dev Breakout boards to talk to one another through SPI.

I found some information on how to do this with Arduinos here:

However I am getting stuck at setting up the slave.

The code used in the post:
Code: Select all
  // turn on SPI in slave mode
  SPCR |= _BV(SPE);
Appears to only work on boards that use other chips.

Page 481 of the SAMD21 datasheet has some information, looks like I need to write to to some registers (CTRLA) but I am not sure how to do this, nor what values to write.

Any help would be much appreciated.
By fll-freak
I would highly recommend downloading the software library from Atmel. The library support device drivers for most of their peripherals on both SAM and AVR products. There are even samples to go with each.

Based on your compiler, you may need to adjust the code, but for the most part the library uses plain vanilla C.
By ollax
I'm also trying to run the SparkFun SAMD32 Mini Breakout in SPI slave mode, but with no success.

I have tried to use the code from ... using-spi/ and your suggested link above.

I have attached a oscilliscope and confirm the following:
* I see that the SS goes from HIGH to LOW when running the script on Rpi, 3.3V->0V
* I see the the SCK goes from LOW to a 100kHz signal during transmit, and then goes back to idle (LOW)
* I see the data transmitted

But I don't get any data on the Samd21. The interrupt is called but read data register is not run:

if (interrupts & (1 << 2))
data = SERCOM1->SPI.DATA.reg; //Read data register
SERCOM1->SPI.INTFLAG.bit.RXC = 1; //clear receive complete interrupt

Any thoughts?
Best Regards
Olle Axelsson