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.

FATfs fopen() creates new file with wrong file name

Other Parts Discussed in Thread: MSP430F5438A, MSP430WARE

Hello Everyone!

MSP430f5438A

tirtos_msp430_2_00_02_36

micro SDcard 64GB (UHS-I card) filesystem: FAT32

I am having issue with fopen() function. The first fopen() function call to create a new file, creates a file with wrong filename. e.g: if I want to create file with name "arslan.txt", then it creates the file with name "rrslan.txt".

So it replaces the first letter of the name with the second letter. And this only happens for the first file.

And for the 2nd and third file, sometimes it adds an extra "0" in the name with a space. e.g: for "arslan.txt" it creates "arslan 0.txt"

Other functions fwrite() fclose() works.

Can anyone please help me out?

Thanks!

Arslan

 

  • an update:

    FATfs is working on SDHC microSD 16GB card and it stores files with correct data and filename. 

    BUT it is not working properly on SDXC microSD 64GB card. It stores data correctly but with wrong filenames. File names usually have extra spaces and extra 0's in the name and it is quite random. So if I store 8 files then usually 2 3 files are stored with wrong file names. So can anyone please help me out?

    Please!

    Thanks!

    Arslan

  • Hi Arslan,

    Sorry for the delayed response.

    The TI-RTOS FatFs module uses the R0.08 release of FatFs.  This module supports Fat12, Fat16 and Fat32 file systems.  

    The reason you are seeing odd behavior is that SDHC cards use the Fat file system (Fat12, Fat16, Fat32) but SDXC cards actually use a patented proprietary exFAT file system.  It is possible that this new format is NOT backwards compatible.

    Additionally, the SDSPI driver has not been tested on exFAT.  There may be some changes required to support exFAT, so trying to use it on exFAT will result in unexpected behavior.

    Regards,

    -- Emmanuel 

  • Hi Emmanuel,

    Thank you for your reply!

    I reformatted the SDcard to FAT32 filesystem.

    And an interesting thing is that at SPI clock frequency 23MHz, it was doing strange this but when I changed the SPI clock to 22 MHz, it worked.

     

    Can you please tell me how can I use SD card at 25MHz clock frequency?

    Thanks!

     

    Regards

    Arslan

  • Hi Arslan,

    Great to hear you were able to resolve the problem with the SD card.  Can you elaborate on what you were seeing at 23 MHz?  We do not test the driver at those frequencies, so we are unaware of problems occur at 23 MHz.  

    If you are already running the SD card ad 22 MHz, I am guessing you already bumped the CPU clock to 25 MHz.  The SDSPI driver sets the SPI bitrate using MSP430ware driverlib, particularly the USCI_A_SPI_masterChangeClock API.  To set the SPI bit clock to be equal to SMCLK (no prescalar used), the UCABRW register must be zero.  This can only be done by using a desired frequency greater than SMCLK.

    In other words, before you open the SDSPI driver, set the SDSPI_Params bitRate greater than SMCLK (25000001 should do just fine).

    Regards,

    -- Emmanuel

  • Hi Emmanuel,

    By setting SDSPI_Params bitRate 1 greater than desired frequency solved the problem.

    Thank you for your help!

    Regards!

    Arslan

  • Hello Arslan,
    I am trying to do exactly what you have done for the MSP430f5438a, but have been unable to find a good footing on how to begin. Is the source code you used available online? is their any examples that you used to accomplish this? i understand there is source code for a different variant of MSP430, but I am unaware on how to port it to the my MSP430. Thanks in advance for your help!
  • If you don't get a reply from Arslan and need help, please start a new thread detailing your issue (and device and versions).

    Todd