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.

f_write for "LaunchPad MSP430F5529 USB Evaluation Kit"

Other Parts Discussed in Thread: MSP430F5529

I'm using the "LaunchPad MSP430F5529 USB Evaluation Kit", and I'm editing the sample code "emulStorageKeyboard" to add a function for append in a file the data read from the adc converter.

the function is :

void saveStrToFile(char* path)
{
    FIL fileObj;       // FatFs file object
    FATFS fileSysObj;  // FatFs handle for a volume
    FRESULT result;    // Stores FatFS result codes
    WORD bytesWrite;    // Returns the number of bytes actually write

    // We fetch the string each button press, in case the user changed it via
    // the host OS, which they can do at any time.

    // Mount the volume and open the file
    f_mount(0, &fileSysObj);
    result = f_open(&fileObj, (TCHAR*)path, FA_OPEN_ALWAYS | FA_WRITE);
    
    f_lseek (&fileObj,f_size(&fileObj));
    
    // It's possible the user could delete the file, so we check for this.
    if (result == FR_OK)
    {
        // Write the file and close it
        btnStrLen = strlen(btnStr);
        result = f_write(&fileObj, btnStr, btnStrLen, &bytesWrite);
        
        f_sync(&fileObj);
        
        f_close(&fileObj);
        f_mount(0, NULL);
    }
}


with the debugger I see that the data is written to the memory " storageVol []" (address 0x10000" ) but if open the file from Windows Explorer I can not find the data.

If I make the safely remove hardware from your PC by clicking on "Eject F5529LP" and then I open Windows Explorer, I find all of the data in the file.

 

**Attention** This is a public forum