Problem using µSD card with SDIO and FatFs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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);
}
- Labels:
-
FatFS
-
SDIO-SDMMC
-
STM32F1 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-09-16 1: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-09-16 4:17 AM
Unfortunately I have seen, checked and in my case it does not help with my problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-09-16 5: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-09-17 12:42 AM
I'm using 5V USB voltage and TC1107 stabilizer to obtain 3.3V with 47K resistors. This is probably not the problem. I checked the other resistors just to be sure. Also no.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-09-17 1:23 AM
Is it possible to read some file on uSD?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-09-17 1:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-09-17 3: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-09-17 6:18 AM
I tried it on two different cards. The first, target one is a 2GB kingston older one and the second one is a 4GB kingston SDHC. I don't know their parameters, but I specifically chose smaller/older cards. I formatted them properly to FAT format before using them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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?
