This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/MSP432P4111: RTOS/MSP432P4111

Part Number: MSP432P4111

Tool/software: TI-RTOS

I had the same problem and your solution works. The problem is that f_mount returns FR_OK only if the first time is called there is a microSD in the shueld. If there is not one and f_mount is called once, the seocnd time is called (now with a microSD inside the shuield) it does not return FR_OK.

Does this have any solution?

Thank you.

  • Hello,

    The "fatsd" example uses the SDFatFS driver. It looks like this driver is written to be called only once by the application.

    I will do some more tests and get back.

    Thanks,
    Sai
  • Good morning, 

    Do you have any good news on this topic?

    Thank you.

  • I was able to try the following scenario successfully by modifying "fatsd" example.

    • SD card not inserted
      • Call "SDFatFS_open" (returns valid handle)
      • Call fopen in "w+" mode (returns NULL handler)
      • Call "SDFatFS_close" (with the handle returned by SDFatFS_open)
    • SD card inserted
      • Call "SDFatFS_open" (returns valid handle)
      • Call fopen (returns valid handler)

    The following is the code snippet to run with the above scenario. This code snippet is a modification of the fatsd.c file.

        bool bFirst = true;
    /* Run a loop till fopen returns a valid handle */ while(sdfatfsHandle == NULL) { /* Mount and register the SD Card */ sdfatfsHandle = SDFatFS_open(Board_SDFatFS0, DRIVE_NUM); if (sdfatfsHandle == NULL) { Display_printf(display, 0, 0, "Error starting the SD card\n"); while(1); } /* Try to open the source file */ /* Open file for both reading and writing */ src = fopen(inputfile, "w+"); if (!src) { if(bFirst) { Display_printf(display, 0, 0, "SD card not found.\nPlease " "insert SD Card\n"); bFirst = false; } /* SD card might not have been inserted. Unmount and unregister * the SD card. */ SDFatFS_close(sdfatfsHandle); /* Clear the handle to try to mount the SD card again in the hope * that SD card is inserted. */ sdfatfsHandle = NULL; } else{ /* If we reached here, it means the SD card is inserted and a file * has been opened for reading and writing */ Display_printf(display, 0, 0, "SD Card is inserted\n"); } } fwrite(textarray, 1, strlen(textarray), src); fflush(src); /* Reset the internal file pointer */ rewind(src); Display_printf(display, 0, 0, "New file created\n");

    This code snippet should be included between the following lines in the file fatsd.c

        Display_printf(display, 0, 0,
            "You will get errors if your SD card is not formatted with a filesystem.\n");
    
        /* Now output the outputfile[] contents onto the console */
        dst = fopen(outputfile, "r");
        if (!dst) {

    Hope this helps!

    Thanks,

    Sai

**Attention** This is a public forum