FatFS USB Host and SD

Discussion in 'Programmer's Corner' started by chrisw1990, Jun 3, 2012.

  1. chrisw1990

    Thread Starter Active Member

    Oct 22, 2011
    543
    41
    Trying to implement FatFS on my project to implement a Micro SD card, and a USB Host on a PIC32MX795F512L.
    i have implemented the two interfaces separately, using microchips stuff, but.. im finding the FatFS system difficult to implement due to a confusing demo app from microchip for the PIC32 that doesnt compile.
    The USB for FatFS doesnt have any demo workspace, so i dont know how to use the pic32 hardware with FATfs..
    help please:D:D
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    I've used Microchip's file system on PIC32's a few times, and actually I don't understand why people seem to have such insurmountable problems with it. It worked pretty much first time I tried it on a PIC18.

    Here's how I did one app where I wanted my graphic display app to access the SD card files, and I also wanted to use the USB side to make the SD card accessible to the PC. So I essentially had a SD based flash drive + my app.

    I started with "Device - Mass Storage - SD Card reader" (which DOES have a demo workspace) as a base to jump start the USB side. My app code resides in another .c module that gets called from InitializeSystem(); and ProcessIO(); as these are the two places to add application calls to a USB app.

    Even though that app "knows" about the file system you have to add file system support again to use it from your app. I believe the USB side requires different code, I've never gone down that path to see why once it worked for me. So add the standard "FSIO.c" and "SD-SPI.c" to your project build. Also the standard "FSIO.h" and "SD-SPI.h" meed be in your search part. You will need to move a copy of "FSConfig.h" into your project folder as that needs to be customized to your needs (though it may work as is at first, you can customize to remove things you do not use to save memory later).

    Your HardwareProfile.h file needs to define the SPI interface and other lines for the SD card. I believe if you leave it out the compiler will bark about the undefined items you need to add.
     
  3. chrisw1990

    Thread Starter Active Member

    Oct 22, 2011
    543
    41
    Yeh, i agree, microchips stuff is easy to use, and the USB device is simple, but im trying to implement a USB Host, and it doesnt have the ProcessIO function for the USB Host.
    I have fully implemented the SD card, and the USB Host separately with the microchip, its just implementing them simultaneously.
     
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    I don't know what your app does, but you could call FSInit() at power on or the top of main() then your file sys is always available to use... or just init and go as needed.

    The MDDFS is not a state machine as the USB is, it just does each function till completion. True it preserves some state info on the side but it needs no periodic handling.
     
Loading...