f_mount always return FR_DISK_ERR when using 4 bit wide SDIO bus but works perfectly with 1 bit SDIO bus
I have NUCLEO-F767ZI 216Mhz and a SD card breakout board. I am using cube mx 5.2.0 and FW_F7_V1.15.0 for code generation. I want to read/write in a file on a sd card. I have enabled SDMMC1 (SD 4 bit wide bus) in cube mx and also enabled FATFS middleware for sd card.
SDIO CLK divide factor 3
MAX_SS 4096
and all other parameters are default
I have connected SDIO pin correctly (double checked) .
When I use 1 bit SDIO bus it works perfectly for same code.
Code:
FATFS SDFatFS ;
FIL SDFile ;
res =f_mount ( &SDFatFS , SDPath,1);
char myFileName[]= "abc.txt"; // create new file
if (res == FR_OK){
res=f_open ( &SDFile , myFileName, FA_WRITE | FA_CREATE_ALWAYS); // open in write mode
}
char myData[] = "xyx,ghj,acceleration,target position\n 1000,231.25,10,500.5";
if (res == FR_OK){
res=f_write ( &SDFile, myData , sizeof(myData), &myBytes);
}
f_close(&SDFile);
