AnsweredAssumed Answered

I have a problem with FATFS

Question asked by quoc.anh on Dec 1, 2017
Latest reply on Dec 1, 2017 by Clive One

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...

Outcomes