SPI 20 clock pulses when 16 were expected

Jorgen
Posts: 50
Joined: Fri Dec 09, 2022 11:39 am

SPI 20 clock pulses when 16 were expected

Postby Jorgen » Wed Sep 11, 2024 12:49 pm

Dear,

I am not sure whether it is a bug or me (most likely me though).

I use VS code and ESP-IDF 5.3.1. The board has an ESP32-S3 WROOM-1 on a DevKitC.

I use the SPI element in master mode. I want to send an 8-bit address and in response receive 8 bit data. I have used my 4-channel oscilloscope to debug my code. Thus, I know the ESP32-S3 sends 20 clock pulses while I had expected 16 only (and so has the slave). I have tried with SPI2_HOST and SPI3_HOST, but it makes no difference.
The clock rate is 1.0 MHz

The settings of the SPI are in the file attached. I have specifically specified no dummy bits and clock pulses.

Why does the ESP32-S3 send 20 clock pulses?

Which of my settings is wrong?

Is it a bug or is it me?

Regards,
Jorgen
Attachments
SPI.txt
(1.44 KiB) Downloaded 75 times

Jorgen
Posts: 50
Joined: Fri Dec 09, 2022 11:39 am

Re: SPI 20 clock pulses when 16 were expected

Postby Jorgen » Wed Sep 11, 2024 1:19 pm

Using an oscilloscope reveals the 20 clock pulses are 4 + 16 i.e. there are 4 clock pulses send before the content of the 8-bit address.

I have modified my code to use full duplex. In that case only 16 clock pulses are sent. That is a solution for me, but I would still appreciate receiving instructions on how to use half duplex and 16 pulses only (8 pulses for the 8-bit address and 8 for the 8-bit data.

Regards,
Jorgen

Jorgen
Posts: 50
Joined: Fri Dec 09, 2022 11:39 am

Re: SPI 20 clock pulses when 16 were expected

Postby Jorgen » Wed Sep 11, 2024 1:45 pm

I have found the error.

I have used as flag SPI_DEVICE_NO_DUMMY within the transaction_t structure. That is wrong. That flag belongs in the spi_device_interface_config_t structure. I have moved it there and now 16 clock pulses are sent only.

The subject is closed.

Sorry for any inconvenience.

Regards,
Jorgen

ESP_Sprite
Posts: 9708
Joined: Thu Nov 26, 2015 4:08 am

Re: SPI 20 clock pulses when 16 were expected

Postby ESP_Sprite » Thu Sep 12, 2024 1:27 am

Glad you managed to find the issue!

Who is online

Users browsing this forum: No registered users and 38 guests