Using timer to save files in SD card with interrupt
Hi all,
I'm trying to use Timer16 to create a 50Hz timer to save files in the SD card. I managed to make the timer work blinking a LED, but when I put the code to save it only saves one line. Here's the logic:
First I create a file and initiate the timer in the USER CODE BEGIN 2 (I want to state that if I start the timer after the SD has been created, it doesn't work (don't know why)).
//Timer
HAL_TIM_Base_Start_IT(&htim16);
//Mount SD
fresult = f_mount(&fs, "", 0);
f_getfree("", &fre_clust, &pfs);
total = (uint32_t)((pfs->n_fatent - 2) * pfs->csize * 0.5);
bufclear();
free_space = (uint32_t)(fre_clust * pfs->csize * 0.5);
//Open file to read / create it if it doesn't exist
//fresult = f_open(&fil, file_name, FA_OPEN_ALWAYS | FA_WRITE);
fresult = f_open(&fil, "testeTimer2.csv", FA_OPEN_ALWAYS | FA_WRITE);
f_gets(buffer, f_size(&fil), &fil);
fresult = f_lseek(&fil, f_size(&fil));
fresult = f_puts("cabecalho,numero,tempo,ticks,ano,mes,dia,hora,minuto,segundo\n", &fil);
//Close file
fresult = f_close(&fil);
After, in the USER CODE BEGIN 4, I have the callback function as follow:
