SPI CS expander

Annex for ESP32
Post Reply
Posts: 6
Joined: Wed Mar 10, 2021 5:45 am
Has thanked: 1 time
Been thanked: 3 times

SPI CS expander

Post by PPANTHER256 »

If you run out of Pins for CS here is a convenient solution based on the 74HC595 Module.
connect the module as shown in help with one minor change:
do not connect the /OE pin of the module to GND, but to a pin of your choice, let it name CS_help.
now you have used 2 pins of your ESP32, and you get 8 CS Pins!
here the story goes:
the first step: set CS_help as an output and to 1. the outputs of the 74HC595 are now tri-state.
the second step: clock in a byte in the 74HC595 Module in the usual way as described in help,
which contains the desired pattern. as the outputs of the 74HC595 are tri-stated there is no effect to the connected SPI devices.
the third step: SPI.CSPIN CS_help, 0
when you write something to the SPI, the CS_help now drives the outputs of the 74HC595 active, and the
desired SPI device is listening.
now you can write or read to your selected SPI device in the usual way.

if you want to change the addressed SPI device repeat from step two.
do not forget to wire pull up/down resistors to the outputs A..H of the 74HC595 , they must not float
when they are tri-stated! a value of 3K3 is a good choice (for active 0 wire the resistor to 3V3, for active 1 to GND).

of course you can chain more of the 74HC595 Modules together, so you have 16/24... CS outputs
Last edited by PPANTHER256 on Wed Sep 15, 2021 2:48 am, edited 1 time in total.
Post Reply