This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SD card

hello dear all,
I have a problem in create a text file in SD card. here is my code. it doesn't create text file. i work on LPC1768. would you tell me what is the problem with my code?

FATFS fs;         /* Work area (file system object) for logical drive */
FIL fsrc;         /* file objects */
FRESULT res;
UINT br;
int SD_TotalSize(void);
char path[512]="0:";
uint8_t textFileBuffer[] = "Thank \r\n";
FRESULT scan_files (char* path);

f_mount(0,&fs);

 res = f_open( &fsrc , "0:/Demo.TXT" , FA_CREATE_NEW | FA_WRITE);

    if ( res == FR_OK )
    {
      /* Write buffer to file */
      res = f_write(&fsrc, textFileBuffer, sizeof(textFileBuffer), &br);

          printf("Demo.TXT successfully created");

      /*close file */
      f_close(&fsrc);
    }
    else if ( res == FR_EXIST )
    {
          printf("Demo.TXT created in the disk");
    }

        scan_files(path);
        SD_TotalSize();

    /* Infinite loop */
    while (1)
                {}
}

Parents
  • Yeah - right!

    You're using an open-source library, and your code doesn't even work - clearly a prime target for theft!!

    And yet you expect people to fix your broken code for free?!

    So how about taking the original code you posted, and using that to demonstrate the problem?

    Add the return value checks.

    See where it's failing,

Reply
  • Yeah - right!

    You're using an open-source library, and your code doesn't even work - clearly a prime target for theft!!

    And yet you expect people to fix your broken code for free?!

    So how about taking the original code you posted, and using that to demonstrate the problem?

    Add the return value checks.

    See where it's failing,

Children