You are here

Connecting Multiple Slave Devices

In SPI, a master can communicate with a single or multiple slaves. For applications using multiple slaves, the following configurations are possible:

  1. Independent slaves. This is a most common configuration of the SPI bus. The MOSI, MISO and SCK lines of all slaves are interconnected. The SS line of every slave device is connected to a separate pin of SPI master device. Since the MISO pins of the slaves are connected together, they are required to be tristate pins (high, low or high-impedance).

    SPI Independent multiple slaves

    To select the slave, the master pulls the corresponding SS line low. Only one slave can be selected.

    For DLN-1 or DLN-2 adapters, you can use the following functions:


    to select the SS line. The SS line value can include only one bit set to 0;


    to transmit data to/from the slave device;


    to release the SS line after transmission if the master does not need to transmit more data to the same slave.

    For a DLN-4M adapter, use the DlnSpiMasterReadWriteSS() function – it selects the specified SS line, transmits data and releases the SS line.In a half-duplex read mode, you can also select only one slave. The following functions can be used:


    to select the SS line. The SS line value can include only one bit set to 0;


    to read data from the slave device and to release the SS line after transmission if required.

  2. Independent slave configuration with decoder/demultiplexer. The SS lines are used to send an n-bit value, which is the number of the selected slave. Here, the master can communicate with m=2n slaves.

    SPI with Decoder

    If you use this configuration, in the DlnSpiMasterSetSS() function the value of the SS lines can include more than one zeros. The demultiplexer converts this value and activates only one SS line.

  3. Half-duplex write configuration. The master transmits data on the MOSI line and the slave receives it. The MISO line remains inactive.

    SPI Multi Slave Half-duplex Write

    If your slave devices only receive data, you can address multi slaves simultaneously. The following functions can be used:


    to select the SS line; the SS line value can include more than one bits set to 0 (several SS lines can be selected – the master can send data to several slave devices simultaneously);


    to write data from the slave device(s) and to release the SS line(s) after transmission (optionally).

    If the master always sends equal data to some group of slaves in a half-duplex write configuration, all the slaves from the group can be connected to one SS line:

    SPI Half-duplex write multi slave on one SS

  4. Daisy-chain slaves: the first slave output is connected to the second slave input, etc. The SPI port of each slave is designed to send out during the second group of clock pulses an exact copy of the data it received during the first group of clock pulses.

    SPI Daisy-chain

In DLN-series adapters, you can use unengaged GPIO pins as slave select (SS) lines. In this case, you can control such pins with the GPIO module.

To check the number of available SS lines in the SPI port, use the DlnSpiMasterGetSSCount() function.

To select the slave, use the DlnSpiMasterSetSS() function. By default, the first SS line (SS0) is selected.

Only one slave can be activated (the signal level on the SS line is low). However, if you use a demultiplexer, you do not select the line, but set the value of the line. The demultiplexer converts this value and selects only one SS line.

The DlnSpiMasterEnable() function enables the selected SS line. Use this function after you configure communication settings.

If you do not need to use all SS lines available in a SPI port, you can disable some of them to use them in other modules. On the contrary, you can enable SS lines that were used for other modules. To disable one SS line, use the DlnSpiMasterSSDisable() function. To disable several SS lines, use the DlnSpiMasterSSMultiDisable() function. To enable one or more SS lines, use the DlnSpiMasterSSEnable() or DlnSpiMasterSSMultiEnable() function accordingly.

Average: 4.7 (3 votes)

User login