Core S3 SD/TF Card Issues
-
Hi Guys,
I have a core S3 that I am trying to program via the Arduino IDE as UiFlow 2 is missing a lot of the capabilites for the S3.
I have also tried this with a standard ESp32 S3 board and get the same issue but could do with some guidance.
My Code:
// Include required libraries #include "M5CoreS3.h" #include "Arduino.h" #include "Audio.h" #include "SD.h" #include "FS.h" // microSD Card Reader connections #define SD_CS 15 #define SPI_MOSI 37 #define SPI_MISO 35 #define SPI_SCK 36 // I2S Connections #define I2S_DOUT 39 #define I2S_BCLK 40 #define I2S_LRC 41 // Create Audio object Audio audio; void setup() { M5.begin(); // Set microSD Card CS as OUTPUT and set HIGH pinMode(SD_CS, OUTPUT); digitalWrite(SD_CS, HIGH); // Initialize SPI bus for microSD Card SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI); USBSerial.print("MOSI: "); USBSerial.println(MOSI); USBSerial.print("MISO: "); USBSerial.println(MISO); USBSerial.print("SCK: "); USBSerial.println(SCK); USBSerial.print("SS: "); USBSerial.println(SS); SPIClass SPI1(HSPI); // Start microSD Card if(!SD.begin(SD_CS, SPI1)) { USBSerial.println("Error accessing microSD card!"); while(true); } // Setup I2S audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT); USBSerial.println("Pinout Set!"); // Set Volume audio.setVolume(5); USBSerial.println("Volume Set Set!"); // Open music file audio.connecttoFS(SD,"/demo.mp3"); USBSerial.println("File Open!"); } void loop() { audio.loop(); }
Basically, I keep getting the message "Error accessing microSD card!" on the terminal. Pretty sure I have the pins right? And the card is formatted to FAT32.
For some reason, I just cannot get it to read
Any Ideas?
Thanks
-
Hello @djh82uk
firstly SD_CS is GPIO 4 - see pin map here.
Secondly it looks like the TFT (which also uses SPI) uses MISO as DC. From an ESP32 perspective MISO is an input but DC needs to be an output. So the TFT driver configures the MISO GPIO to an output. This conflicts with the SD card, which is on the same SPI bus and requires MISO to be an input. Not sure how to resolve that so that TFT and SD card can coexist.
Thirdly the M5CoreS3 library sets the voltage for the SD card incorrectly to 1.3 V instead of 3.3 V. I posted a PR for that.
A simple SD card example which works for me (but it disables the TFT) is here.
Thanks
Felix -