AnsweredAssumed Answered

f_getfree API returns FR_INVALID_DRIVE error

Question asked by Niyathi Shenoy on Mar 15, 2018
Latest reply on Mar 15, 2018 by Clive One

Hi clive,

I am using a 32 GB SD card,

My code by using the API f_getfree() is as follows:

 

if (f_mount(&myFATAFS, SDPath, 1) == FR_OK) {
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_12);

 

f_getfree("1:", &Free_clust, &myFATAFS);
tot_sect = (myFATAFS.n_fatent - 2) * myFATAFS.csize;
fre_sect = Free_clust * myFATAFS.csize;
sprintf(coeff3,"%10lu MiB total drive space.\n\r %10lu MiB available.\n\r", tot_sect/2/1024,Free_clust/2/1024);
HAL_UART_Transmit(&huart2,(uint8_t *) coeff3, 65, 50);

}

 

But the output that i get is as follows :

30416 MiB total drive space.

0 MiB available.

 

 

However, my SD card is formatted and there is nothing in it.Please help me here.

 

Also, f_getfree API returns a FR_INVALID_DRIVE error i.e., finding the logical drive function returns me the volume as -1 even if my sd card is connected.But a f_write api writes files and directories into the sd card. Please help. 

Outcomes