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.

USB Host MSC on TM4C123GH6PM - last data not written on some USB-Sticks

Hello.

My application receives ASCII data from a serial port and writes them in a TXT file on the connected USB-Stick.

Everything seems to work fine but, only with certain models of sticks (not branded 8GB), when I disconnect the drive and open it on the PC, I can see that a variable number of bytes (about 20 to 40) is missing at the end of file. This is systematic and independent on how many data I write into the file.

Obviously the problem is not present when I write data to the USB-Stick using the PC.

Can anyone help me to solve this issue?

Thanks

Mario

  • Hello Mario,

    1. Did you check from the TM4C on a file read the file shows up OK after writing?
    2. Does the FAT FS show any error flag after writing the data to the memory stick?

    Regards
    Amit
  • Hi Amit,

    1. In TM4C, if I open the file for read and read a line, then data are written completely.
    2. The FATFS doesn't show any error opening, writing and closing the file.

    What I see is that missing data match with those passed to the last write command.

    NOTE: in order to exclude any serial port managing problem, I implemented a small function which opens the file, writes some test lines and closes it. The problem disappears only when I execute a file read at the end of this sequence.

    Have you an explanation for this behaviour?

    Regards
    Mario
  • Hello Mario,

    While I have not seen this issue, what it could be is that the Buffer is not committed to the USB drive. The read operation is what is causing the flush to the memory stick. Have you written a custom program or is it the standard example as given in DK-TM4C123?

    Regards
    Amit
  • Hello Amit,

    I am using a custom program, but I don't understand why it works well with almost all the USB-sticks.
    The read after the write could be a solution, but it is very bad in terms of speed.
    Can you suggest any other test to find a different (better) solution?

    Regards
    Mario
  • Hello Mario

    Without having the same stick and program on my side it is difficult to say. It may be possible that the USB Stick has a nuance which the TivaWare drivers are not taking care of. I would suggest using the standard example to first confirm the same.

    Regards
    Amit