Have been trying for 2 days now to access the SD card on the micromod 2 slot main board. Using SAMD51 processor board. Every chip select and spi command tried does not find an sd card. Using a 16GB SD card. Card is formatted FAT32, and reads/writes find in WIndows. But no matter what I try in code, it will not find the card.
Any suggestions or debugging tips?
Thanks,
Craig
The SAMD51 has limited IO; I believe you need to specify the pins being used for the SD card. What code are you using? The double uses D6 for CS (instead of the usual D1)
You can try this sample code and see what shakes out
#include <SPI.h>
#include <SD.h>
const int SD_CS_PIN = 6; // G4 on SAMD51 = D6
const int SD_ENABLE = 35; // I2C_SDA1 = D35, active LOW
File myFile;
void setup() {
// Enable SD card power (active LOW)
pinMode(SD_ENABLE, OUTPUT);
digitalWrite(SD_ENABLE, LOW);
Serial.begin(9600);
while (!Serial) { ; }
Serial.print("Initializing SD card...");
if (!SD.begin(SD_CS_PIN)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
myFile = SD.open("test.txt", FILE_WRITE);
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
myFile.close();
Serial.println("done.");
}
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
while (myFile.available()) {
Serial.write(myFile.read());
}
myFile.close();
}
}
void loop() {}
If you have an alternate MicroMod processor you can also swap them (sometimes that’s easier than custom code)