Following code is simply giving initialisation error (simply fails at SD.begin stage).
Do I need to do anything else STM32 specific here ? Especially in terms of which SPI pins this MPU uses (but I suppose that's defined in STM32duino headers ?
I appreciate any idea on how to troubleshoot next. Wirings are double-checked but attaching a copy of it as well in case you see something obvious.
Code: Select all
#include <SPI.h>
#include <SD.h>
File myFile;
void setup() {
Serial.begin(9600);
Serial.print("Initializing SD card...");
if (!SD.begin(PA8)) {
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.");
} else {
Serial.println("error opening test.txt");
}
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
while (myFile.available()) {
Serial.write(myFile.read());
}
myFile.close();
} else {
Serial.println("error opening test.txt");
}
}
void loop() {
}