The SPI is a four wire serial interface even though sometimes only two of the wires are used. This is the case if there is only one slave device connected and if it never sends data back to the master. Unlike the I2C (Wire) bus the SPI bus can work in full duplex. The bus consists of the following signals that are self-explanatory

  • Master Out Slave In (MOSI)
  • Master In Slave Out (MISO)
  • Serial ClocK (SCK)
  • Slave Select (SS)

Therefore each slave has to be selected to listen on the bus. This means that the pins can also be used for something else if the SS pin is not active. Often  the SS is not connected between the master and the slave if there is only one slave connected. If so the SS on the slave will have to be activated whether it is high or low. The datasheet for the slave device will tell. If the SS is needed the programmer has manually to code this in the software.

Many slave devices can only listen to a master, i.e. they can’t send anything themselves. When this is the case the MISO doesn’t have to be connected.

The SPI bus speed depends on the capabilities of the master and the slaves devices. But speeds in the MHz range is not unusual.

The default SPI bus on the RFzero is  bus available on D16 (MISO), D17 (SS), D18 (MOSI) and D19 (SCK) on the JP8 connector. The program below shows how to activate and use the RFzero SPI bus connected to a Microchip MCP23S17 port expander device. The principle is the same for the default SPI bus on the Arduino Zero and Arduino M0 boards.

If you want to use the above example on your Arduino Zero or Arduino M0 default SPI pins please note that the pins don’t match directly with the RFzero as the below table shows.

SPI signalPin/PortArduino Zero/M0 pinout
MISOD164 (SPI connector)
SSD17Not assigned
MOSID181 (SPI connector)
SCKD193 (SPI connector)

Please note that if your SPI device(s) uses 5 V you will need a 3,3 V to/from 5 V level converter that can be made either by discrete components, ready made board or an IC. Please see the Third party accessories section on the Shop page.