AnsweredAssumed Answered

Problem with f_read and f_lseek in fatFs

Question asked by sahar shakoori on Jan 7, 2018
Latest reply on Jan 10, 2018 by Clive One

I'm trying to connect to a 2GB sd card class 6 with stm32f091cctx MCU via SPI. Using fatFs library ver. R0.13a I'm able to mount the drive and open the file with f_mount and f_open functions. But when it comes to reading from file, it just freezes somewhere in f_read function. Also when I try to change the position of pointer with f_lseek, again it freezes. f_lseek works only when I write it as f_lseek(&MyFile, 0). 

This part of my code is as below: 

 

if(FATFS_LinkDriver(&SD_Driver, SDPath) == 0)
{
   f_mount(&SDFatFs, (TCHAR const*)SDPath, 1);
   f_open(&MyFile, "SAMPLE1.WAV", FA_READ);
   f_lseek(&MyFile, 200);
   f_read(&MyFile, rtext, 1000, (UINT*)&bytesread);
}

Outcomes