One PIN for multiple SPI Slave devices

Ususally, one SPI slave device needs a pin of chip select. In order to save pins, some devices support one chip select pin for multiple devices. For example(MCP23S17 , MCP23S08, etc.)

Most of the devices don't have this feature. I designed a simple circuit to support this feature for all devices.

In order to use this circuit, the following procedure should be followed:

  1. use SPI mode 0 to output a number while remaining CS_PIN high
  2. pull CS_PIN to low, the slave device referred to by the number in the last step will be selected
  3. Start normal communication with the device
  4. pull CS_PIN to high after finished the communication

if you have more than 8 devices, you can use up to three 74hc138 chip to support up to 24 devices. Or you can use one 4-16 decoder chip to replace the 74hc138 chip.

if you have more than 8 devices, you can use up to three 74hc138 chip to support up to 24 devices.

Just wondering how the schematic needs to look for this.

This is good, but bad.
You cannot use ready-made libraries as there is no direct selection of pin CS.
If you use one ATMega328 instead of your circuit, then it will be cheaper, fewer connections and more performance.
The exchange with external devices will be assigned to this one additional ATMega328.
You just have to give a task and get the finished result (you can use an interrupt).
Could it be easier to use ATMega32 or ATMega2560?
YOU WATCHED THIS: MCUdude (Hans) · GitHub ?

Best regards.