1
\$\begingroup\$

I've got some problems with the FATFs library and the STM32F7 Series. I want to connect a SD-Card (32GB, SanDisk, FAT32) with the F746G-Discovery-Board to save some data on it. (at first .txt-Files, later read .csv Files to visualize some measuring data).

My problem is, that the f_mount function gives me a "FR_OK" but in the next step I can't open a file with f_open. I located the problem by debugging step by step. It's in the ff.c file of the FatFs lib.

 res = find_volume(&path, &fs, mode);

At this point the program stops. jumping into the function the problem is following line

stat = disk_initialize(fs->drv);    /* Initialize the physical drive */  

So the SD-Card is not initialized/mounted? But why does the f_mount giving me the FR_OK?

It would be really nice if someone could help. Thanks!

I tried following things:

  • formatted SD-Card (exFat,..)
  • other Paths
  • adjusted clock frequency to 16 MHz for the SD Card

in main:

FIL fil;

FRESULT fr;

FATFS FatFs;

fr=f_mount(&FatFs,(TCHAR const*)SDPath,1);

if(fr!= FR_OK)
{
    Error_Handler(); 
}

else if (fr == FR_OK)
{
      char path[13] = "testfile.txt";
      fr = f_open(&fil, (char*)path, FA_WRITE | FA_CREATE_ALWAYS);
      // File should be created
      //here begins the main problem

  if ( fr == FR_OK ) // File opened
  {
       f_printf(&fil, "%d", 1234);
  }
    else if (fr != FR_OK)
    {
    Error_Handler();
    }
}

f_close(&fil);
f_mount(0,"SD",0);
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.