How to use more than 3 slaves on Due spi?

More specifically I have 4 slaves I want to control with the Arduino Due. From what I understand I only have 3 SS pins to choose from. 4, 10 and 52. This seems somewhat limited, so how would I go about getting a 4th SS?

Thank you.

Hello Aue11,

Due supports three Chip Select (SS) pins (10, 4 and 52). If you need more than that the best solution IMO is to use a decoder/demultiplexer. Regards,


I tried making a "manual" SS port that was not from those three, and it worked as long as I brought it low and high manually. Is this a bad way to do it?

Is this a bad way to do it?

No that is the normal way of doing things.

I'm using pins other than these, without any problems, on Due. I have 4 SPI connected devices.

Even though the use of common digital gpio pins as CS is the quickest way to solve the ‘more than 3 SPI slaves’ issue, by removing the control of CS from the SPI and letting it handle only the serial communication, I want to bring up the fact that SAM3X8E can be programmed to operate with up to 15 peripherals by using the PCSDEC bit and decoding the four CS lines NPCS0 to NPCS3, but given that Due only has 3 NPCS lines broken out (4,10,52) the maximum amount of SPI slaves that can be operated is 7 using an external multiplexer like 74HC138 (3-to-8) and a couple of SPI functions. In that regard, I started to implement some coding last year but I did set aside for reasons of time. I just did post a message on Atmel web to see whether is possible to complete my implementation. I will keep you posted.


It is possible using different pins, but settings like word size, speed, etc will not be automatically changed when chip select is changed. this only works on pins 4,10,52. like others say, if you'd like to have more of this, you can hook up a demux like Palliser says.

Hello Aue11,

Did you came up with a solution for your 4 SPI slaves need?

After a question to Atmel tech. support, here they answer:

The following are two pseudo code options to control more than three SPI port using a multiplexer with Arduino Due:

Option 1:

  1. Call spi_enable_peripheral_select_decode
  2. Set the chip select using spi_set_peripheral_chip_select_value
  3. Use spi_write and spi_read
  4. Set uc_last to end the transfer and to deassert the chip select.

Option 2:

  1. Call spi_enable_peripheral_select_decode

  2. Call spi_set_variable_peripheral_select to enable variable chip select

  3. Use spi_write and spi_read with the required uc_pcs value for a slave.

  4. End the transfer with uc_last in spi_write.

  5. Group the set of slaves which would be operating with the similar modes.

  6. For read only operations, a dummy spi_write is always needed to generate the SPI clock for a spi_read operation.

Note: The control registers for 0-3 is a single register SPI_CSR0 and similarily for 4-7, 8-11, 12-15.

I've been busy (as usual) but trying to write a code to this alternative way to the GPIO one.