cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with f_read and f_lseek in fatFs

sahar shakoori
Associate
Posted on January 07, 2018 at 15:33

I'm trying to connect to a2GB 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);
 }�?�?�?�?�?�?�?

#stm32f0 #fatfs #sd-card #spi
3 REPLIES 3
Imen.D
ST Employee
Posted on January 09, 2018 at 11:40

Hello,

Please refer to the following discussions if you have similar issue:

-

https://community.st.com/0D50X00009bMM8bSAG

-

https://community.st.com/0D50X00009XkWyLSAV

Best Regards,

Imen.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on January 10, 2018 at 15:58

thank you so much

Posted on January 10, 2018 at 16:18

Not sure how applicable SDIO implementation details are to SPI. Assume FatFs is solid and you need to focus on testing and validating your code in DISKIO.C and below.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..