New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP32-S3 “SPIClass spi(HSPI)” but with pin definitions? #9588
Comments
HSPI is the default, and there is already an object (SPI) defined on that bus.
If you want to use VSPI, you can do so like:
|
In arduino-esp32 context, SPI names are just names- HSPI evaluates to bus 2, and should be the horizontal pins (2,4,12,15), but that's just not how they are defined in the variants file. Since it is all muxed through the gpio matrix, that doesn't really matter (although a bit confusing). Espressif has gotten away from the H/V naming, since it doesn't really apply to the other variants, but it is kinda stuck in arduino to maintain backwards compatibility. If you are going to define your own objects, I'd stick to using the numbers |
Board
"NodeMCU-32s" & "Firebeetle2 ESP32-3"
Device Description
Board connected to "Adafruit_ST7796S_kbv" tft (although not really relevant) using the HSPI .
Hardware Configuration
#define SD_CS 15
#define TFT_CS 33
#define TFT_DC 17
#define SPI_MISO 12 // default pin
#define SPI_MOSI 13 // default pin
#define SPI_CLK 14 // default pin
#define TFT_RST -1
Version
latest master (checkout manually)
IDE Name
Arduino IDE v1.8.19
Operating System
Windows 10
Flash frequency
n/a
PSRAM enabled
no
Upload speed
n/a
Description
The 1st below sketch works fine, but only with the default HSPI pin definitions.
The 2nd below sketch with new HSPI pin definitions compiles OK, but crashes at the line “SerialD.begin();” [aka tft.begin()]
Is there any way to change the used HSPI pins outside of “setup()” and “loop()” so my above “#define SerialD tft” will work with “SerialD.print” etc?
Edit2:
@lbernstone - many thanks for below info! Interestingly the default "SPI" object "SPI.begin();" appears to use the pre-defined (SCK,MOSI, MISO,SS) variables, which on my board (nodeMCU-32S) are GPIO 18,23,19 & 5 which I understand to be the VSPI interface. But this still works fine.
The 3rd below sketch DOES work, and it a little more complex than sketch 1 above, but not too bad!
Edit 3: re. ESP32-S3
Note that the ESP32-S3 has 2 available/user SPI controllers named:
(each has slightly different capabilities).
Also note that although both above SPI controllers can be routed to any GPIO, for the fastest performance you can only use GPIOs 0-21 & 26-48 (which use the IO MUX to connect to the pins). Other pins use the GPIO MATRIX to connect to the pins and is slower.
Finally note that the SPI/TFT/SD (Arduino-ID) spi-frequency settings seem to work a bit differently on the ESP32-S3 (github.com/espressif/arduino-esp32 as at 16Jan24) compared with the ESP32-original. Specifically on the ESP32-original the following code works:
BUT on the ESP32-S3 the SD card gives the error message “sdCommand(): no token received” (I think because the SPI has ignored the default 10MHz setting for the SD card and is still using the default 40MHz setting of the TFT.)
To fix you need to specifically set the spi-frequency to the SD-cards default 10MHz frequency by changing the last couple of lines as follows:
Sketch
Debug Message
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: