When using the ESP32 as SPI master, you can use any pins for the SCLK
, MISO
, MOSI
and CS
signals, but using the following set of pins has minor advantages:
SPI pin name | ESP32 pin (SPI2) | ESP32 pin (SPI3) |
---|---|---|
CS | 15 | 5 |
SCLK | 14 | 18 |
MISO | 12 | 19 |
MOSI | 13 | 23 |
If you use all of the pins for SPI2 or all of the pins for SPI3, using those pins is slightly faster, since the signals do not have to be routed through the GPIO matrix. This has the advantage of having a lower input delay (which is important at high speeds to avoid issues with MISO setup time) and that you can operate the SPI bus at 80 MHz (as opposed to 40 MHz with the GPIO matrix).
If you use ANY pin beside those listed above, ALL pins will be routed through the GPIO matrix – so use either all of these pins or ignore it altogether. Note that some pins are input-only or reserved for special functions, so they may not be used for some or all of the SPI signals.
Source & further reading: ESP32 SPI master driver documentation