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:
- use SPI mode 0 to output a number while remaining CS_PIN high
- pull CS_PIN to low, the slave device referred to by the number in the last step will be selected
- Start normal communication with the device
- 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.