( https://github.com/WeActStudio/WeActStu ... ree/master )
On lower side is a microSD slot connected with 4 data lanes:
1. SD_DETECT_PIN not working or wrong level?
First I used this small sketch to check the contact for SD-card presence.
Code: Select all
#include <STM32SD.h> // STM32SD@1.3.2 incl. FatFs@2.1.4
#define LED PB2 // Bultin-LED is connected to GND
#define SD_DETECT_PIN PA8
Sd2Card card;
SdFatFs fatFs;
File root;
void setup() {
Serial.setRx(PA10);
Serial.setTx(PA9);
Serial.begin(115200);
delay(1000);
Serial.print("\n\n --- SDIO-Kartentest auf STM32H562RGT6 -- \n ");
pinMode(SD_DETECT_PIN, INPUT_PULLUP);
card.setDx(PC8, PC9, PC10, PC11);
card.setCMD(PD2);
card.setCK(PC12);
Serial.printf("SD_DETECT_PIN: %d CARD_INIT: %d \n", digitalRead(SD_DETECT_PIN), card.init(SD_DETECT_PIN) );
}
Code: Select all
SD_DETECT_PIN: 0 CARD_INIT: 0
Code: Select all
SD_DETECT_PIN: 1 CARD_INIT: 0
Same problem with card.init(SD_DETECT_NONE) or card.init()
As next I used a while-loop like in examples. With card.init() it works, looks like it is really slow???
Again with parameter:
Code: Select all
#define SD_DETECT_PIN PA8
Sd2Card card;
SdFatFs fatFs;
File root;
uint32_t i = 0;
void setup() {
Serial.setRx(PA10);
Serial.setTx(PA9);
Serial.begin(115200);
delay(1000);
Serial.print("\n\n --- SDIO-Kartentest auf STM32H562RGT6 -- \n ");
pinMode(SD_DETECT_PIN, INPUT_PULLUP);
card.setDx(PC8, PC9, PC10, PC11);
card.setCMD(PD2);
card.setCK(PC12);
while (!card.init(SD_DETECT_PIN)) // funktioniert nicht mit SD_DETECT
{
delay(1);
i++;
}
Serial.printf("%d ms - initialization done\n",i);
Serial.printf("SD_DETECT_PIN: %d \n", digitalRead(SD_DETECT_PIN) );
}
Code: Select all
8046 ms - initialization done
SD_DETECT_PIN: 0
a) When sketch started, microSD-card was inserted. No "initialization done" came up on Serial Monitor.
b) Then I took out card and saw thes two lines
Does librray detect inserted card by LOW-level?
So wiring on board is wrong and should be opposite way for STM32SD-library?
2. SD card not recognized!
I used a simple 4GB card class10 speed and I formatted it with the SD CARD FORMATTER.
After adding
Code: Select all
if (!fatFs.init()) {
Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
//return;
}
Inside SdFatFs.cpp I see:
Code: Select all
bool SdFatFs::init(void)
{
/*##-1- Link the SD disk I/O driver ########################################*/
if (FATFS_LinkDriver(&SD_Driver, _SDPath) == 0) {
/*##-2- Register the file system object to the FatFs module ##############*/
if (f_mount(&_SDFatFs, (TCHAR const *)_SDPath, 1) == FR_OK) {
/* FatFs Initialization done */
return true;
}
}
return false;
}
f_mount(&_SDFatFs, (TCHAR const *)_SDPath, 1) return 3
But I don't what is the real reason for the error.
Does soemone ever tested STM32SD succesful with SDIO?