ESP32 SPI Chip Select Not working.

Posts: 7
Joined: Thu Mar 05, 2020 1:24 pm

ESP32 SPI Chip Select Not working.

Postby agatrost1620 » Tue Nov 21, 2023 4:01 am

I am trying to use the spi, and the chip select is not being held low while transmission in progress. It is bouncining, and not very predictable on how many times or when.
Is there a way to drive the cs low, send and receive all the data and then drive the cs high?
I have tried many different code setups with the spi_master.h and c

currently it is something like:

spi_bus_config_t spiConfig =
.miso_io_num = SPI_MISO,
.mosi_io_num = SPI_MOSI,
.sclk_io_num = SPI_CLK,
.quadhd_io_num = -1,
.quadwp_io_num = -1,
.max_transfer_sz = 0, // 0 means that max transfer size is 4k bytes

spi_device_interface_config_t deviceConfig =
.mode = 0,
.spics_io_num = SPI_ADC_CS, // using cs 0 and 5 and both operate the same
.clock_speed_hz = SPI_MASTER_FREQ_10M,
.queue_size = 1,
.address_bits = 0,

ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(SPI_BUS, &spiConfig, SPI_DMA_CH_AUTO));
ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_add_device(SPI_BUS, &deviceConfig, &;

ESP_ERROR_CHECK_WITHOUT_ABORT(spi_device_transmit(device->id, &device->rxtx));
And I am assigning the pointers to an allocated array.

I have tried using -1 for the cs and driving it with the call backs and it operates the same. Is there any suggestion on how to set up the spi to operate as I am intending other than driving the cs independently and around the spi_device_transmit() function call.

Let me know if there is anything else that would help to solve this issue.
Thank you in advance.

Who is online

Users browsing this forum: No registered users and 48 guests