cancel
Showing results for 
Search instead for 
Did you mean: 

I have a problem with FATFS

hukhongcongtu26111993
Associate II
Posted on December 01, 2017 at 04:40

I am working with STM32F407 Discovery Board and micro SD Card. I use STM32CubeMX version 4.23 to config SDIO 4 bit.

This is my code to read data from micro sd card: 

FATFS myfatfs;

 

FIL myfile;

 

uint8_t SD_Data_Read_Arr[100];

 

uint32_t readbyte;

/* USER CODE BEGIN 2 */

if(BSP_SD_Init()!=MSD_OK){};

if(f_mount(&myfatfs,'',1)!=FR_OK){};

if(f_open(&myfile,'123.txt',FA_READ)!=FR_OK){};

if(f_read(&myfile,SD_Data_Read_Arr_1,100,&readbyte)!=FR_OK){};

/* USER CODE END 2 */

while(1)

 

{

 

}

I load my code into MCU and debug by Kiel C. Then I observe SD_Data_Read_Arr in watch1 monitor. 

I have two micro SDCard. One is Transcend,SDHC ,16GB and one is China's item( It do not have manufacturer),2GB. 

I connect micro sd card to MCU through SD socket. 

When I use 2GB micro sd card. My code was run and I can see data of SD_Data_Read_Arr in watch1 monitor.

But when I use 16GB micro SDcard. SD_Data_Read_Arr  do not have any data. I get error in f_mount(&myfatfs,'',1) is FR_NO_FILESYSTEM. 

I have some question:

1. Why can't I work with SDHC

 card?

2. How can I solve this problem?

3. When I use STM32CubeMx, how can I config to work with all SDcard type? 

Thanks for any help! If you need, I can upload my project...

#sdhc #stm32-stm32cube #fatfs-sdio
2 REPLIES 2
Posted on December 01, 2017 at 05:02

>>I am working with STM32 Discovery Board

That narrows things down to a few dozen boards, care to be more specific?

The functions return error codes, you really should pay attention to those and stop ploughing onward when things fail.

Several reports of issues with CubeMX code for this, can't help you with those.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 01, 2017 at 05:05

Sorry

Turvey.Clive.002

. I was update my question! and I used STM32F407 Discovery board!