Hey guys
I would like to connect a 74HC595 shift register to my ESP32 Thing.
Has anyone of you had any experience with ESP32 and a shift register? Is it possible to connect it via HSPI or VSPI?
Thanks for your help.
ESP32 & Shift register
Re: ESP32 & Shift register
74HC595 is not an SPI device, so no you cannot. You could however simply use any four pins to control it. If you are not tight on pins, you could get the same logic directly on the pins of the ESP32 by holding the output value in memory and setting the outputs accordingly, just beware of the voltage levels.
Re: ESP32 & Shift register
It is pretty common to use spi to generate the bit stream for a shift register. There are a few examples for esp8266 and esp32.permal wrote:74HC595 is not an SPI device, so no you cannot. You could however simply use any four pins to control it. If you are not tight on pins, you could get the same logic directly on the pins of the ESP32 by holding the output value in memory and setting the outputs accordingly, just beware of the voltage levels.
Re: ESP32 & Shift register
Well, ofc you can use SPI to generate bitstreams. If that is what OP is asking about, sure. It's not the same as actual SPI communication though, which is what I read the question as.WiFive wrote: It is pretty common to use spi to generate the bit stream for a shift register. There are a few examples for esp8266 and esp32.
Re: ESP32 & Shift register
Short answer is no. But yes.
(1) No. Since 74HC595 is not an SPI device, as @permal described, you can't use 74HC595 as SPI device.
(2) But yes. You can use ESP32's SPI as bit stream output device for 74HC595 as @WiFive wrote.
If you choose (2), I recommend you to refer "7. SPI" in the ESP32 technical reference manual. You should mainly set the following registers/bits:
Also esp-idf's SPI driver code may help you.
(1) No. Since 74HC595 is not an SPI device, as @permal described, you can't use 74HC595 as SPI device.
(2) But yes. You can use ESP32's SPI as bit stream output device for 74HC595 as @WiFive wrote.
If you choose (2), I recommend you to refer "7. SPI" in the ESP32 technical reference manual. You should mainly set the following registers/bits:
Code: Select all
spi_dev_t.ctrl.wr_bit_order (MSB/LSB first)
spi_dev_t.user2.usr_command_bitlen (Command phase)
spi_dev_t.user1.usr_addr_bitlen (Address phase)
spi_dev_t.user.usr_dummy (Dummy phase)
spi_dev_t.user1.usr_dummy (Dummy phase)
Re: ESP32 & Shift register
Mr Kumart,
If I may ask, what is your use case, design? How will you be using the shift register?
If I may ask, what is your use case, design? How will you be using the shift register?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: ESP32 & Shift register
Hey guys
Thanks for your answers! Yes, i know that 74HC595 is not an SPI-device, but i heard that SPI can be used to create a bitstream for the shift register.
@kolban: I would like to trigger a sound module with buttons and via Webserver-option. To select the sound which I want to play I must trigger ten optocouplers. I am planning to use a shift register because i have too few GPIOs to control the button-LEDs and the optocoupler.
@ta-mat: Thank you, i will try this.
Is it correct if I use
-HSPI_CLK for SRCLK of 54HC595,
-HSPI_D for SER (Data)
-any GPIO for OE and another GPIO for RCLK?
Thanks for your help!
Thanks for your answers! Yes, i know that 74HC595 is not an SPI-device, but i heard that SPI can be used to create a bitstream for the shift register.
@kolban: I would like to trigger a sound module with buttons and via Webserver-option. To select the sound which I want to play I must trigger ten optocouplers. I am planning to use a shift register because i have too few GPIOs to control the button-LEDs and the optocoupler.
@ta-mat: Thank you, i will try this.
Is it correct if I use
-HSPI_CLK for SRCLK of 54HC595,
-HSPI_D for SER (Data)
-any GPIO for OE and another GPIO for RCLK?
Thanks for your help!
Who is online
Users browsing this forum: ESP_Roland and 52 guests