2021-09-16 12:44 AM
I'm trying to make a program one of the features of which is SD card support. I'm using HAL libraries entirely, it's hard to find an example that combines SD card, SDIO communication and HAL libraries.
1. problem is that function f_mkdir, f_open returns FR_DISK_ERR no matter what order they are used.
I checked the physical connections, the signals show up in the communication. If there is no SD card in the slot it returns FR_NOT_READY.
2. i don't use an SD Card detect switch, could it be because of this? How can I bypass Dtetect_SDIO? Or make it so that the program works?
MCU: STM32F103VETxLQFP100
CubeIDE v1.7.0
CubaMX v6.3.0
The target program looks different, but with this code I tried to find errors.
uint32_t wbytes; //File write counts
uint8_t wtext[] = "text to write logical drive"; //file write buffer
short int res[5];
res[0] = f_mount(&SDFatFS, (TCHAR const*)SDPath, 0);
if(res[0] == FR_OK)
{
res[1] = f_mkdir("sd_test"); //daje FR_DISK_ERR
res[2] = f_open(&SDFile, "test.txt", FA_CREATE_ALWAYS | FA_WRITE | FA_READ); //daje FR_DISK_ERR
if(res[2] == FR_OK)
res[3] = f_write(&SDFile, wtext, sizeof(wtext), (void *)&wbytes);
else
res[3] = 21;
res[4] = f_close(&SDFile);
}
2021-09-16 01:00 AM
Perharps help
https://controllerstech.com/interface-sd-card-with-sdio-in-stm32/
There are a plenty of good ideas and examples for STM32.
2021-09-16 04:17 AM
Unfortunately I have seen, checked and in my case it does not help with my problem.
2021-09-16 05:13 AM
I try this microSD comunication on 32F401xxx CPU. A have some trouble when I use only internal CPU pullups. After I use 10k external pullups, good 3,3V power source and power blocking capacitors, there were no problem here.
2021-09-17 12:42 AM
2021-09-17 01:23 AM
Is it possible to read some file on uSD?
2021-09-17 01:49 AM
2021-09-17 03:55 AM
Hello @KMach.2 ,
Could you please provide the reference of the SD Card used.
I also invite you to take a look at the examples provided in our firmware package ( Path : Projects\STM3210C_EVAL\Applications\FatFs )
and customize it to your board.
BeST Regards,
Walid
2021-09-17 06:18 AM
2021-09-17 10:46 PM
And when you save a file from a PC to the card, can you then open it and read it?