cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, i am trying to integrate SD card with SPI over STM32H750VBT6 evaluation board.SD card mounted but i can't create file,I can't write into file.I checked hardware connection and code but nothing has worked for me.Any one can help to solve?

sk.6
Associate
 
3 REPLIES 3

Which board specifically, an ST EVAL/DISCO board, or a WEACT / TAOBAO / ALIEXPRESS type thing?

Helps to be specific and provide a link or picture of board.

Well still probably an issue with connectivity, configuration or software, kind of blind to any material detail.

Top level issues with FatFS all most always relate to HW and DISKIO level failing, so instrument that and make sure basic level sector read operations work. I'd focus on reading existing cards, with unimportant content. Make sure you can read and directory those first before graduating to WRITE operations and file/format operations.

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

Hi,

This is my code.can you find any error in the code

please guide me

 if(f_mount(&fs, "/", 1) != FR_OK)

  {

   Serial_PutString("SD Card mounted successfully");

  if(f_open(&fil, "test.txt", FA_READ)!=FR_OK)

    {

      printf("sucessfully opened : (%i)\r\n");

      if(f_read(&fil,buf,sizeof(&fil),&br)==FR_OK)

      {

     Serial_PutString("File read successfully");

      }

       // break;

    }

  if(f_unlink("test.txt")!=FR_OK)

  {

  Serial_PutString("File deleted successfully");

  }

   char myFilename[] = "first.txt";

   if(f_open(&fil, myFilename, FA_WRITE || FA_CREATE_ALWAYS||FA_CREATE_NEW)!=FR_OK )

   {

   Serial_PutString("File Created successfully");

   char myData[] = "Hello World";

   if(f_write(&fil, myData, sizeof(myData),&bw) !=FR_OK)

   {

   Serial_PutString("Data written to file successfully");

   }

   f_close(&fil);

   }

  }

  else

  {

   Serial_PutString("Failed to mount SD card");

  }

   f_mount(NULL, "", 0);

   printf("SD Card Unmounted Successfully!!!\r\n");

The Double OR​ (logical) is wrong, but top level functionality is dependent on you having working sector read/write code. Validate that first, then integrate file system code.

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