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.

CCS/TM4C1294NCPDT: Writing data to USB flash drive

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

I am fairly new to programming my Tivaware C Series launchpad and so I was wondering if someone could take a look at some code I made to write some data into a .csv file on an external flash drive connected to my launchpad. Compiling show no errors but when I debug the program it goes into a fault error. If you can help me with this issue it would be very useful for me, thank you.

    //
    // Configure SysTick for a 100Hz interrupt.
    //
    ROM_SysTickPeriodSet(ui32SysClock / TICKS_PER_SECOND);
    ROM_SysTickEnable();
    ROM_SysTickIntEnable();

    //
    // Enable the uDMA controller and set up the control table base.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
    ROM_uDMAEnable();
    ROM_uDMAControlBaseSet(g_sDMAControlTable);

    //
    // Initialize the USB stack mode and pass in a mode callback.
    //
    USBStackModeSet(0, eUSBModeHost, 0);

    //
    // Register the host class drivers.
    //
    USBHCDRegisterDrivers(0, g_ppHostClassDrivers, g_ui32NumHostClassDrivers);

    //
    // Open an instance of the mass storage class driver.
    //
    g_psMSCInstance = USBHMSCDriveOpen(0, MSCCallback);

    //
    // Initialize the power configuration.  This sets the power enable signal
    // to be active high and does not enable the power fault.
    //
    USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);

    //
    // Tell the USB library the CPU clock and the PLL frequency.  This is a
    // new requirement for TM4C129 devices.
    //
    SysCtlVCOGet(SYSCTL_XTAL_25MHZ, &ui32PLLRate);
    USBHCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &ui32SysClock);
    USBHCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate);

    //
    // Initialize the USB controller for host operation.
    //
    USBHCDInit(0, g_pHCDPool, HCD_MEMORY_SIZE);

    //
    // Initialize the file system.
    //
    f_mount(0, &g_sFatFs);
    f_open(&g_sFileObject, "F:/data.csv", FA_READ |  FA_WRITE |  FA_OPEN_ALWAYS );
    DWORD size = (&g_sFileObject)->fsize;

    FRESULT fresult = f_lseek(&g_sFileObject,size);
    f_write(&g_sFileObject, "1000.00,1001.00,1002.00,1003.00,1004.00,1005.00,1006.00,150,151,152,1,10000,10001,10002,360.1234\n", sizeof("1000.00,1001.00,1002.00,1003.00,1004.00,1005.00,1006.00,150,151,152,1,10000,10001,10002,360.1234\n"), 0);
    f_sync(&g_sFileObject);

    f_close(&g_sFileObject);