Good day all,
I am trying to access an SD card with an ESP32-S3-DEVKITC-1 via HSPI.
With the following code, I can not mount the SD card.
#include <SPI.h>
#include <SD.h>
#define HSPI_MISO 12
#define HSPI_MOSI 13
#define HSPI_SCLK 14
#define HSPI_CS 5
static const int spiClk = 240000000; // 1 MHz
SPIClass SPISD(HSPI);
void setup() {
Serial.begin(115200);
SPISD.begin();
SPISD.begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI, HSPI_CS); //SCLK, MISO, MOSI, SS
pinMode(HSPI_CS, OUTPUT); //HSPI SS
if (!SD.begin(HSPI_CS, SPISD))
{
Serial.println("Card Mount Failed");
return;
}
uint8_t cardType = SD.cardType();
if (cardType == CARD_NONE)
{
Serial.println("No SD card attached");
return;
}
Serial.print("SD Card Type: ");
if (cardType == CARD_MMC)
{
Serial.println("MMC");
}
else if (cardType == CARD_SD)
{
Serial.println("SDSC");
}
else if (cardType == CARD_SDHC)
{
Serial.println("SDHC");
}
else
{
Serial.println("UNKNOWN");
}
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
Serial.printf("SD Card Size: %lluMB\n", cardSize);
Serial.printf("Total space: %lluMB\n", SD.totalBytes() / (1024 * 1024));
Serial.printf("Used space: %lluMB\n", SD.usedBytes() / (1024 * 1024));
}
void loop()
{
delay(1000);
}
Many greetings.