21
21
* SD pin number | 8 7 6 5 4 3 2 1 9 /
22
22
* | █/
23
23
* |__▍___▊___█___█___█___█___█___█___/
24
- * WARNING: ALL data pins must be pulled up to 3.3V with external 10k Ohm resistor!
25
- * Note to ESP32 pin 2 (D0) : add 1K pull up after flashing
24
+ * WARNING: ALL data pins must be pulled up to 3.3V with an external 10k Ohm resistor!
25
+ * Note to ESP32 pin 2 (D0): Add a 1K Ohm pull-up resistor to 3.3V after flashing
26
26
*
27
27
* For more info see file README.md in this library or on URL:
28
28
* https://github.com/espressif/arduino-esp32/tree/master/libraries/SD_MMC
32
32
#include " SD_MMC.h"
33
33
34
34
// Default pins for ESP-S3
35
- // Warning: ESP32-S3-WROOM-2 is using most of the default SD_MMC GPIOs (33-37) to interface with on-board OPI flash.
36
- // If the SD_MMC is initialized with default pins it will result in rebooting loop - please
37
- // reassign the pins elsewhere using the mentioned command `setPins`.
35
+ // Warning: ESP32-S3-WROOM-2 is using most of the default SD_MMC GPIOs (33-37) to interface with the on-board OPI flash.
36
+ // If the SD_MMC is initialized with the default pins it will result in rebooting loop.
37
+ // Please reassign the pins elsewhere using the mentioned command `setPins`.
38
38
// Note: ESP32-S3-WROOM-1 does not have GPIO 33 and 34 broken out.
39
- // Note: The board SP32 -S3-USB-OTG has predefined default pins and the following definitions with the setPins() call will not be compiled.
39
+ // Note: The board ESP32 -S3-USB-OTG has predefined default pins and the following definitions with the setPins() call will not be compiled.
40
40
// Note: Pins in this definition block are ordered from top down in order in which they are on the full-sized SD card
41
- // from left to right when facing the pins down (when connected to a breadboard)
41
+ // from left to right when facing the pins down (when connected to a breadboard)
42
42
43
43
#if defined(SOC_SDMMC_USE_GPIO_MATRIX) && not defined(BOARD_HAS_SDMMC)
44
- int d1 = 21 ; // SD pin 8 - add 10k Pullup to 3.3V if using 4-bit mode (use_1_bit_mode = false)
45
- int d0 = 47 ; // SD pin 7 - add 10k Pullup
44
+ int d1 = 21 ; // SD pin 8 - Add a 10k Ohm pull-up resistor to 3.3V if using 4-bit mode (use_1_bit_mode = false)
45
+ int d0 = 47 ; // SD pin 7 - Add a 10k Ohm pull-up resistor to 3.3V
46
46
// GND pin - SD pin 6
47
- int clk = 39 ; // SD pin 5 - add 10k Pullup
47
+ int clk = 39 ; // SD pin 5 - Add a 10k Ohm pull-up resistor to 3.3V
48
48
// 3.3V pin - SD pin 4
49
49
// GND pin - SD pin 3
50
- int cmd = 40 ; // SD pin 2 - add 10k Pullup
51
- int d3 = 41 ; // SD pin 1 - add 10k Pullup to card's pin even when using 1-bit mode
52
- int d2 = 42 ; // SD pin 9 - add 10k Pullup to 3.3V if using 4-bit mode (use_1_bit_mode = false)
50
+ int cmd = 40 ; // SD pin 2 - Add a 10k Ohm pull-up resistor to 3.3V
51
+ int d3 = 41 ; // SD pin 1 - Add a 10k Ohm pull-up resistor to 3.3V to card's pin even when using 1-bit mode
52
+ int d2 = 42 ; // SD pin 9 - Add a 10k Ohm pull-up resistor to 3.3V if using 4-bit mode (use_1_bit_mode = false)
53
53
#endif
54
54
55
55
bool use_1_bit_mode = false ; // Change the value to `true` to use 1-bit mode instead of the 4-bit mode
@@ -214,9 +214,9 @@ void setup(){
214
214
Serial.println (" SDMMC_Test.ino starting!" );
215
215
216
216
// If you are using any other ESP32-S3 board than ESP32-S3-USB-OTG which has preset default pins, you will
217
- // need to specify the pins with the following example of SD_MMC.setPins()
217
+ // need to specify the pins with the following example of SD_MMC.setPins()
218
218
// If you want to use only 1-bit mode, you can use the line with only one data pin (d0) begin changed.
219
- // Please note that ESP32 does not allow pin change and will fail unless you enter the same pin config as is the hardwired.
219
+ // Please note that ESP32 does not allow pin changes and will fail unless you enter the same pin config as is the hardwired.
220
220
#if defined(SOC_SDMMC_USE_GPIO_MATRIX) && not defined(BOARD_HAS_SDMMC)
221
221
// if(! SD_MMC.setPins(clk, cmd, d0)){ // 1-bit line version
222
222
if (! SD_MMC.setPins (clk, cmd, d0, d1, d2, d3)){ // 4-bit line version
@@ -225,19 +225,10 @@ void setup(){
225
225
}
226
226
#endif
227
227
228
- /*
229
- // This is waiting for implementation in peripheral manager (periman)
230
- if(use_1_bit_mode){
231
- Serial.printf("Begin in 1-bit mode; pins: CLK=%d, CMD=%d, D0=%d\n", SD_MMC.getClkPin(), SD_MMC.getCmdPin(), SD_MMC.getD0Pin());
232
- }else{
233
- Serial.printf("Begin in 4-bit mode; pins: CLK=%d, CMD=%d, D0=%d, D1=%d, D2=%d, D3=%d\n", SD_MMC.getClkPin(), SD_MMC.getCmdPin(), SD_MMC.getD0Pin(), SD_MMC.getD1Pin(), SD_MMC.getD2Pin(), SD_MMC.getD3Pin());
234
- }
235
- */
236
-
237
228
if (!SD_MMC.begin (" /sdcard" , use_1_bit_mode)){
238
229
Serial.println (" Card Mount Failed." );
239
230
Serial.println (" Increase log level to see more info: Tools > Core Debug Level > Verbose" );
240
- Serial.println (" Make sure that all data pins have 10 kOhm pull-up resistor" );
231
+ Serial.println (" Make sure that all data pins have a 10k Ohm pull-up resistor to 3.3V " );
241
232
#ifdef SOC_SDMMC_USE_GPIO_MATRIX
242
233
Serial.println (" Make sure that when using generic ESP32-S3 board the pins are setup using SD_MMC.setPins()" );
243
234
#endif
0 commit comments