Problem using µSD card with SDIO and FatFs
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);
}
