HAL_SD_ERROR_TX_UNDERRUN when using FATFS
I'm trying to use FATFS on NUCLEO-F401RE to write a file into the SD Card.
I generated the project into cube MX and added thi code before the while(1) loop:
/* USER CODE BEGIN 2 */
temp = f_mount(&StrutturaCtrFS,"",1);
if(FR_OK != temp){
while(1);
}
temp = f_open(&File_CFG,"Cfg.ini", FA_READ | FA_WRITE | FA_CREATE_ALWAYS);
if(FR_OK != temp){
while(1);
}
temp = f_write(&File_CFG, "CIAO",4,0);
if(FR_OK != temp){
while(1);
}
f_close(&File_CFG);
/* USER CODE END 2 */it stops in F_wirte instruction. With debugger I founded that the error is a HAL_SD_ERROR_TX_UNDERRUN in HAL_SD_WriteBlocks (line 782 in stm32f4xx_hal_sd.c).
Attached there is my .ioc file
The SD is connected as this:
MISO -> PC8 (SDIO_DO)
MOSI -> PD2 (SDIO_CMD)
CLK -> PC12 (SDIO_SK)
CS -> PC3 ( GPIO OUTPUT HIGH)
also (because my SD card slot doesn't have a SD_presence pin) I put PC9 of FATFS to GND.
What's wrong in this project ?
Thanks to all.
