How to use SD_MMC.setPins()?
Posted: Fri Oct 21, 2022 6:55 am
Hi
I am trying to use IO4 as SD_MMC's D0 to avoid conflict of ESP32 bootstrap with IO2 which is the default SD_DATA0 pin of SD_MMC driver.
My original wiring was:
SD_CMD : IO15 with 10k pullup
SD_CLK : IO14
SD_DATA0 : IO2 (with 10k pullup after code download)
The original wiring works OK but I needed to solder a 10K pullup to IO2 everytime I downloaded a new code and it is very tedious.
I came up with an idea to use SD_MMC.setPins() to use IO4 as the SD_DATA0 with a permanent 10K pullup. The new wiring is :
SD_CMD : IO15 with 10k pullup
SD_CLK : IO14
SD_DATA0 : IO4 with 10k pullup
IO2 is now unconnected so that there is no bootstrap issue.
My code to set IO4 as SD_DATA0 is:
Unfortunately, SD_MMC.setPins() does not work as expected with "Set pin failed!" messages followed by ("Card Mount Failed").
Is there anything I have missed?
John
I am trying to use IO4 as SD_MMC's D0 to avoid conflict of ESP32 bootstrap with IO2 which is the default SD_DATA0 pin of SD_MMC driver.
My original wiring was:
SD_CMD : IO15 with 10k pullup
SD_CLK : IO14
SD_DATA0 : IO2 (with 10k pullup after code download)
The original wiring works OK but I needed to solder a 10K pullup to IO2 everytime I downloaded a new code and it is very tedious.
I came up with an idea to use SD_MMC.setPins() to use IO4 as the SD_DATA0 with a permanent 10K pullup. The new wiring is :
SD_CMD : IO15 with 10k pullup
SD_CLK : IO14
SD_DATA0 : IO4 with 10k pullup
IO2 is now unconnected so that there is no bootstrap issue.
My code to set IO4 as SD_DATA0 is:
Code: Select all
if(!SD_MMC.setPins(14, 15, 4))///SD_CLK=14, SD_CMD=15, SD_D0=4
{
Serial.println("Set pin failed!");
}
while(!SD_MMC.begin("/cdcard", true)){ ///We are using pins SD_DATA0 and _DATA1 only
Serial.println("Card Mount Failed");
delay(500);
}
Is there anything I have missed?
John