2021-02-18 03:38 AM
hi i have a problem with sd card, i am trying to write a file.txt using the fats library
i am using cube mx old version and sdio reader data0, clk, cmd ....
here the code:
MX_GPIO_Init ();
MX_USART2_UART_Init ();
MX_SDIO_SD_Init ();
MX_FATFS_Init ();
/ * USER CODE BEGIN 2 * /
/ * USER CODE END 2 * /
UINT testbyte;
/ * USER CODE BEGIN 2 * /
FATFS myFATFS;
FIL myFILE;
if (f_mount (& myFATFS, SDPath, 1) == FR_OK) {
HAL_GPIO_TogglePin (LD2_GPIO_Port, LD2_Pin);
char mypath [] = "test1.txt";
char myData [] = "hello world";
if (f_open (& myFILE, mypath, FA_WRITE | FA_CREATE_ALWAYS) == FR_OK) {
HAL_GPIO_TogglePin (LD2_GPIO_Port, LD2_Pin);
if (fwrite (& myFILE, myData, sizeof (myData), & testbyte) == FR_OK) {
HAL_GPIO_TogglePin (LD2_GPIO_Port, LD2_Pin);
}
f_close (& myFILE);
}
the problem that enters f_mount, opens the file then f_write is ok but when I go to check the sd card I see the file open but no data written ...
thank you
2021-02-18 03:39 AM
i use sd card 4bit no dma