FatFs Writing Cmds(f_printf) Slows Down ADC
Hello,
I'm using SDMMC to save ADC DMA data to an SD card on Nucleo H723ZG. I made some tests and got distorted results. Then I realized a problem, sampling speed is too slow when I use fatfs writing commands. What might be the problem?
I use a 64K buffer for ADC.
The code for the writing process with half and full callback:
/* USER CODE BEGIN 4 */
void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc) {
for (int i = 0; i < ADC_BUF_LEN/2; i++) {
fres = f_printf(&fil, "%d\n", adc_buf[i]);
}
}
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) {
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_11);
for (int i = ADC_BUF_LEN/2; i < ADC_BUF_LEN; i++) {
fres = f_printf(&fil, "%d\n", adc_buf[i]);
}
if(HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin)==GPIO_PIN_SET){ //Check if button pressed
f_close(&fil);
f_mount(NULL, "", 0);
myprintf("closed\r\n");
}
}
/* USER CODE END 4 */The first pic is from full callback without fatfs write cmds:
The second pic is with fatfs write cmds.
Another problem is it gets much slower if f_close is not done yet.

