2021-02-10 04:07 AM
This is sd_command line via logic analyzer. I'm writing 1024 bytes every second. But sd_commend do like that. And that's problem for me. If i wanna save some datas. sd_command line spoilng and locking my stm32f411 mcu's. I need help i don't understand to where is the problem or problems? If u want configuration code or file i can send....
f_rslt = f_mount(&myFatFS, SDPath, 1);
f_rslt = f_open(&myFile, "TextFile.txt", FA_WRITE | FA_OPEN_APPEND);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
counter++;
f_rslt = f_write(&myFile, data, sizeof(data), &myBytes);
if(f_rslt == FR_OK)
{
}
else
{
}
HAL_Delay(100);
if(counter == 10)
{
f_rslt = f_close(&myFile);
f_rslt = f_open(&myFile, "TextFile.txt", FA_WRITE | FA_OPEN_APPEND);
}
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
2021-02-10 09:54 AM
Ok, hard to understand the exact issue here.
The loop needs an exit strategy.
The error status needs to be checked an acted upon.
The f_close() will create a lot of SDIO traffic as it flushes file system structures to the media.
Do you need to f_seek() to the end of a file to append? I don't recall.
This is all top-level stuff, to understand what's happening you'll need to instrument DISKIO layer, monitoring the read/write operations, and outputting error/failure information.
The F411 should be capable of continuous operation of SDIO/FATFS.
Writing a lot of small data via f_write() will be super inefficient, you should manage buffering so you flush data at multiples of the sector/cluster size, and aligned on those boundaries.