Page 1 of 1

[ESP32-S2] Do I need to setup 2 different SPIs (SPI 2 and SPI 3) for 9 devices?

Posted: Tue Jul 06, 2021 11:16 pm
by jgalt91
Hi, reading the documentation about the ESP32-S2 it says SPI 0 and 1 are used internally for flash, and SPI 2 and 3 (often refered as HSPI and VSPI) are for user purposes and each one has 3 CS, so each one can drive only 3 slaves.

I have two questions:

1) If I wanted to drive 9 slaves, do I have to setup two separate SPIs (the SPI 2 and 3) each one with it's own MOSI, MISO and SCK lines? Example: SPI 2 = MOSI (13), SCK (14), MISO (15) and 6 CS lines any other pin
SPI 3 = MOSI (35), SCK (36), MISO (37) and 3 CS lines at any other pin


2) There is a [great video](https://www.youtube.com/watch?v=LY-1DHTxRAk&vl=es) about which pins cannot be used in the ESP32 for general purposes. In the S2, for example, the GPIO 0 cannot be used (for CS) as is an input only, 19-20 are for USB and 15-16 are for XTAL (if used). Are there any more pins I can't use for the main SPI lines (MOSI/MISO/SCK) and for Chip Select?

Thanks in advance!

Re: [ESP32-S2] Do I need to setup 2 different SPIs (SPI 2 and SPI 3) for 9 devices?

Posted: Wed Jul 07, 2021 6:19 am
by ESP_LJH
Referring to datasheet, as a master, GP-SPI2 provides six CS lines, CS0 ~ CS5; GP-SPI3 provides three CS lines, CS0 ~ CS2; in total, ESP32-S2 could drive nine slaves with SPI2 and SPI3.
All SPI lines could be mapped to any unused GPIO.
Pay attention to GPIO46, it is input only not GPIO0.
In theory, strapping pins could be used if they are available, but they should be well taken care of.

Re: [ESP32-S2] Do I need to setup 2 different SPIs (SPI 2 and SPI 3) for 9 devices?

Posted: Wed Jul 07, 2021 2:02 pm
by jgalt91
Thanks for the answer. So SPIs SPI2-3 aren't managed internally as one but instead and I need to setup two SPI: SPI2 or HSPI and SPI3 or VSPI for a total of two SPI x 3 lines (MOSI, MISO, SCK) = 6 lines, and then attatch 6 CS to SP2 and 3 CS to SP3, is that right?

Re: [ESP32-S2] Do I need to setup 2 different SPIs (SPI 2 and SPI 3) for 9 devices?

Posted: Thu Jul 08, 2021 3:21 am
by ESP_LJH
Yes, you are right.