ESP32-DEVKITM-1 examples SPI connections

Cd4768gg
Posts: 18
Joined: Wed Apr 27, 2022 7:07 pm

ESP32-DEVKITM-1 examples SPI connections

Postby Cd4768gg » Wed Apr 27, 2022 7:18 pm

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

Cd4768gg
Posts: 18
Joined: Wed Apr 27, 2022 7:07 pm

Re: ESP32-DEVKITM-1 examples SPI connections

Postby Cd4768gg » Tue May 10, 2022 10:42 pm

Hello,

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

Thank you
Chris

Cd4768gg
Posts: 18
Joined: Wed Apr 27, 2022 7:07 pm

Re: ESP32-DEVKITM-1 examples SPI connections

Postby Cd4768gg » Thu May 19, 2022 6:26 pm

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

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

Re: ESP32-DEVKITM-1 examples SPI connections

Postby ESP_Sprite » Fri May 20, 2022 8:34 am

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.

Cd4768gg
Posts: 18
Joined: Wed Apr 27, 2022 7:07 pm

Re: ESP32-DEVKITM-1 examples SPI connections

Postby Cd4768gg » Fri May 20, 2022 9:08 pm

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
?

Cd4768gg
Posts: 18
Joined: Wed Apr 27, 2022 7:07 pm

Re: ESP32-DEVKITM-1 examples SPI connections

Postby Cd4768gg » Fri May 20, 2022 11:00 pm

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?

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

Re: ESP32-DEVKITM-1 examples SPI connections

Postby ESP_Sprite » Sun May 22, 2022 6:31 am

Yes. Find the spi_device_interface_config_t struct that configures the device and add SPI_DEVICE_POSITIVE_CS to the flags.

Cd4768gg
Posts: 18
Joined: Wed Apr 27, 2022 7:07 pm

Re: ESP32-DEVKITM-1 examples SPI connections

Postby Cd4768gg » Mon May 23, 2022 8:28 pm

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

Cd4768gg
Posts: 18
Joined: Wed Apr 27, 2022 7:07 pm

Re: ESP32-DEVKITM-1 examples SPI connections

Postby Cd4768gg » Mon May 23, 2022 11:16 pm

also this example is sending 10 bytes instead of 8 with no delay between bytes. Is there a more practical example?

Cd4768gg
Posts: 18
Joined: Wed Apr 27, 2022 7:07 pm

Re: ESP32-DEVKITM-1 examples SPI connections

Postby Cd4768gg » Mon May 23, 2022 11:24 pm

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.

Who is online

Users browsing this forum: No registered users and 163 guests