Shift register to expand SPI bus

Hi friends. You know I'm a code guy but I need a little help sometimes with circuitry. I think I have this one right, but I would like to get a nod of approval before I go building it.

I need more chip select pins for an SPI bus. I don't have many pins to give. Fortunately they are all active low CS pins. My idea is to add a 595 shift register. All 8 output pins get pullup resistors and serve as CS lines for different devices.

SRCLR is tied to 5V so it never clears the register.

I've used the SPI bus on the Arduino to drive shift registers a lot. So I'll just add the data pins and clock pin to my existing bus.

The shifter doesn't need a CS line, but it does need the RCLK line that moves the shift register out to the outputs on a rising edge. So I'll need that from Arduino.

A second line from Arduino goes to the OE line on the shifter. I hold it high when I'm not using the bus and it tri-states the shifter and the pull-ups keep my CS pins high.

When I want to send to the bus, I'll first send a byte on the SPI bus that has all pins high except the one I want to select. All of the other devices will ignore that byte because their CS pins are still HIGH but it does end up in the shift register. Then I'll strobe the RCLK to put it to the outputs.

Now I can hand the OE pin over to whatever code wants the SPI bus and it uses it as if it is the CS pin connected to whatever device. If it's HIGH then all outputs are HIGH (pull-ups) and when it drops it LOW it only drops the pin(s) with the LOW bit. Data goes out the SPI bus as normal and the contents of the shifter will change but as long as I don't strobe the RCLK pin again I should be able to control that one bit with the OE pin.

I just have to make sure that any time I change from talking to one device to another, I have to take OE HIGH (which it should be already if it's being treated as a CS pin) load up a new byte to the shifter and strobe the RCLK.

OK, I think I've explained it to you rubber ducks well enough to convince myself it will work. But since it's typed out I'm posting it in case one of you has a better idea. The way I see it since I can use the existing SPI bus to drive the data and clock pins, I'm really using 2 pins to get 8. If I move two existing SPI devices over there that will free the pins I need.

1 Like

If you are using TI's 74LS595 chip (Fig-1), then I have the following observations:


Figure-1:

There are no pull-up resistors at the output pins unless these are installed by the user.

The signal is active low and it is: SRCLR/ (active low).

The signal name is actually: RCK.

The signal attached with the chip is G/ (active low) to enable the tri-state output buffers.

There are 4 pins (of Arduino UNO) are being used -- MOSI, SCK, 1-DPin for RCK, and 1-DPin for G/. However, 1-DPin to G/ can be avoided by connecting G/-pin at GND potential.

Thanks for the nice textual description about the operation of the 74LS595 shift register. So, at least 3 pins of UNO (MOSI, SCK, 1-DPin for RCK) would be required.

Would a 3 line to 8 line decoder (74LS138) or 4 line to 16 line decoder (74LS154) not be easier ?

1 Like

If using 74LS138, one would need 5 lines (3 for the decoder and 2 for SPI).

It all looks plausible and some good comments.

I post only to mention that the wokwi simulator has the '595 part, so with some srsly minor trouble you could lash up your circuit and get a very good confirmation of the idea.

The other SPI devices could be any SPI part on offer in the simulator.

a7

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.