Page 1 of 1

ESP32-DEVKITM-1 examples SPI connections

Posted: Wed Apr 27, 2022 7:18 pm
by Cd4768gg
Hello,

I have the ESP32-DEVKITM-1 v1.0

https://docs.espressif.com/projects/esp ... itm-1.html
has pin descriptions

Datasheet references GPIO17 for SCLK but also states that clock, chip-select, MOSI, and MISO can be configured to any GPIO

The example peripherial SPI master HD_eeprom, readme shows:
| ESP32 | ESP32 | ESP32S2 | ESP32C3 | ESP32S3 |
| Host | SPI1 | HSPI | FSPI | SPI2 | SPI2 |
| DO | 7 | 18 | 37 | 2 | 13 |
| DI | 8 | 23 | 35 | 7 | 11 |
| SK | 6 | 19 | 36 | 6 | 12 |
| CS | 13 | 13 | 34 | 10 | 10 |

I am not familiar with SPI1 vs HSPI, FSPI, SPI2
I believe I need the ESP32 and my guess is the SPI1. Then MOSI would be DO = pin 7, MISO would be DI = pin 8, SCLK would be SK = pin 6, and chip-select would be CS = pin 13. Is that correct?

If this is not the correct location for this request please let me know where to post it.

Thank you
Chris

Re: ESP32-DEVKITM-1 examples SPI connections

Posted: Tue May 10, 2022 10:42 pm
by Cd4768gg
Hello,

I wanted to follow up on this inquiry to see if anyone had any suggestions.

Thank you
Chris

Re: ESP32-DEVKITM-1 examples SPI connections

Posted: Thu May 19, 2022 6:26 pm
by Cd4768gg
I am confused, there are SPI example code projects but no one know what the electrical connections are? Communication will not be possible without the correct connections. I need clock, chip select, MISO and MOSI

Re: ESP32-DEVKITM-1 examples SPI connections

Posted: Fri May 20, 2022 8:34 am
by ESP_Sprite
SPI stuff is indeed configurable to use any GPIO. Feel free to modify the ones in the example if it doesn't fit your devboard.

Re: ESP32-DEVKITM-1 examples SPI connections

Posted: Fri May 20, 2022 9:08 pm
by Cd4768gg
sounds good..... so in the example I specified, what pin is MOSI
what pin is MISO
what pin is chip select
what pin is clock
?

Re: ESP32-DEVKITM-1 examples SPI connections

Posted: Fri May 20, 2022 11:00 pm
by Cd4768gg
I think I have figured it out going through the code to see what was set. so by default:
# define PIN_NUM_MISO 18
# define PIN_NUM_MOSI 23
# define PIN_NUM_CLK 19
# define PIN_NUM_CS 13

is there a way to make the chip select be active low instead of active high?

Re: ESP32-DEVKITM-1 examples SPI connections

Posted: Sun May 22, 2022 6:31 am
by ESP_Sprite
Yes. Find the spi_device_interface_config_t struct that configures the device and add SPI_DEVICE_POSITIVE_CS to the flags.

Re: ESP32-DEVKITM-1 examples SPI connections

Posted: Mon May 23, 2022 8:28 pm
by Cd4768gg
I found :


spi_device_interface_config_t devcfg={
.command_bits = 10,
.clock_speed_hz = EEPROM_CLK_FREQ,
.mode = 0, //SPI mode 0
/*
* The timing requirements to read the busy signal from the EEPROM cannot be easily emulated
* by SPI transactions. We need to control CS pin by SW to check the busy signal manually.
*/
.spics_io_num = -1,
.queue_size = 1,
.flags = SPI_DEVICE_HALFDUPLEX | SPI_DEVICE_POSITIVE_CS,
.pre_cb = cs_high,
.post_cb = cs_low,
.input_delay_ns = EEPROM_INPUT_DELAY_NS, //the EEPROM output the data half a SPI clock behind.
};

in spi_eeprom.c and

#define SPI_DEVICE_POSITIVE_CS (1<<3) ///< Make CS positive during a transaction instead of negative
in spi_master.h

I tried replacing SPI_DEVICE_POSITIVE_CS with zero
.flags = SPI_DEVICE_HALFDUPLEX | 0,
but that didnt work. I tried removing it completely
.flags = SPI_DEVICE_HALFDUPLEX,
that didnt work either

Re: ESP32-DEVKITM-1 examples SPI connections

Posted: Mon May 23, 2022 11:16 pm
by Cd4768gg
also this example is sending 10 bytes instead of 8 with no delay between bytes. Is there a more practical example?

Re: ESP32-DEVKITM-1 examples SPI connections

Posted: Mon May 23, 2022 11:24 pm
by Cd4768gg
Looking at the code I see polling, address references, etc.

I just need to send FF 00 00 00 and then see what the response it which will be in the form 00 XX XX XX with the Xs replaced with hex values that I need to know what their values are.