I am trying to get my Atmel SAMD11 XPLAINED PRO and arduino to talk to each other using SPI. I have set up the arduino as the master, with the SAMD11 as the slave. On the ATMEL, I have the following code:


Essentially, it waits until the master sends data, compares the data with what it expects, and updates an LED accordingly. On the arduino side, I have the following:

#include <SPI.h>

#define BUF_LENGTH 20
int slave_select = 10;

void setup (void)
  // Initialize serial for DEBUG.
  pinMode (slave_select, OUTPUT);
  digitalWrite(slave_select, HIGH);  // ensure SS stays high for now
  // Put SCK, MOSI, SS pins into output mode
  // also put SCK, MOSI into LOW state, and SS into HIGH state.
  // Then put SPI hardware into Master mode and turn SPI on
  SPI.beginTransaction (SPISettings (4000000, MSBFIRST, SPI_MODE0));  // 4 MHz clock, MSB first, mode 0
  // Master initialized.
  Serial.println("Master Initialized");
}  // end of setup

void loop (void)
  static uint8_t buffer_expect[BUF_LENGTH] = {
    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
     0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13
  // enable Slave Select
  digitalWrite(slave_select, LOW);    // SS is pin 10

  //write the 20 bytes
  for (int I=0;I<20;I++)
    SPI.transfer(buffer_expect[I]); //write data byte

  // disable Slave Select
  digitalWrite(slave_select, HIGH);

  delay (1000);  // 1 seconds delay 
}  // end of loop

When I run the code, the LED on the SAMD11 isn't updated, which means that it is waiting for data to be sent, and hasn't received any, despite what the arduino code writes. On the hardware side, I have GND connected on both boards, VCC on the SAM to 5V on the arduino, and SPI_SS_A, MOSI, MISO and SCK connected to pins 10,11,12 and 13 on the arduino respectively.

  • I don't see a "pinMode" statement anywhere in your code. Where do you set SS as an output?
    – brhans
    Mar 14, 2016 at 18:27
  • @brhans I was following the given table: arduino.cc/en/Reference/SPI
    – trset test
    Mar 14, 2016 at 18:31
  • @brhans arduino.cc/en/Reference/SPIBegin States that SS is set to high, which is Pin 10
    – trset test
    Mar 14, 2016 at 18:32
  • @brhans In addition, this link states "Arduino automatically defines SS as the pin numbers for the selected board". pjrc.com/teensy/td_libs_SPI.html
    – trset test
    Mar 14, 2016 at 18:35

1 Answer 1


You haven't set your SS pin as an output anywhere in your code.

The arduino page you linked to has a note near the bottom which reads:

Note about Slave Select (SS) pin on AVR based boards

All AVR based boards have an SS pin that is useful when they act as a slave controlled by an external master. Since this library supports only master mode, this pin should be set always as OUTPUT otherwise the SPI interface could be put automatically into slave mode by hardware, rendering the library inoperative. It is, however, possible to use any pin as the Slave Select (SS) for the devices. For example, the Arduino Ethernet shield uses pin 4 to control the SPI connection to the on-board SD card, and pin 10 to control the connection to the Ethernet controller.

The Example code given for the teensy board on the other page you linked has:

pinMode (slaveSelectPin, OUTPUT); 

in its setup() function.

So that's what you're missing.
Setting the pin high or low is not going to achieve anything if its not an output.

Remember that SPI can access many diffrent devices using the same MOSI/MISO/SCK pins, but each slave device has its own Slave-Select pin which needs to be individually driven by the master.
Your master can therefore have many different SS pins, all set as outputs - and there is no single standard pin for this.

  • It doesn't seem to be this, I have updated the code and I have the same issue, where the SAMD11 doesn't have a lit LED, meaning it is waiting to receive something.
    – trset test
    Mar 15, 2016 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.