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.

TM4C129 as a USB Host

Other Parts Discussed in Thread: TM4C129DNCPDT

Hi,

I'm using TM4C129DNCPDT. I'm developing an application where USB stick will be connected to USB port of my board, then TM4C129 should recognize it and read particular file from it. Actually I'm new to USB development and as per my understanding of Tivaware documents and USB, TM4C129 will act as USB host. Is it correct?  
Also do I need to implement file system in my software to be able to read particular file from USB stick?

Thanks,

Abhay 

  • Hello Abhay,

    The USB on TM4C devices is a OTG device, meaning it will work as both Host or Device depending on the way it is configured. There is already an example for USB to interface to a USB Stick

    C:\ti\TivaWare_C_Series-2.1.0.12573\examples\boards\dk-tm4c123g\usb_host_msc

    Regards

    Amit

  • Hi Amit,

    Is the above example available in only the latest version of Tivaware (2.1 in example provided by you)?

    Is it available for Tivaware 2.0?

    Thanks,

    Abhay

  •  

    Hi Amit,

    One more query, I tried compiling usb_host_msc with my project, I got some errors related to non-existence of the "third_party" folder. I could see there was no folder named "third_party" inside TivvaWare directory, So I copied the folder "third_party"  from TivaWare_C_Series-2.0.1.11577 (inside TI folder) to "TivaWare" folder. I could see disappearance of the errors, Is this the correct way to resolve the errors?

     

    Thanks,

    Abhay

  • Hello Abhay

    The third_party folder comes if you install the full TivaWare Installer. It should be OK to do so from the other but since the TM4C129 examples may have changed so would have some of the 3rd party settings.

    Regards

    Amit

  • Hi Amit,

    I'm referring the code usb_host_msc.c as per your reply for TM4C129. As per pinout configuration it seems following signals are used in it - USB0ID, USB0VBUS,USB0EPEN,  USB0PFLT, USB0DM and USB0DP.

    But in our hardware, we using following signals only - USB0EPEN,  USB0PFLT, USB0DM and USB0DP. So I'm configuring only these signals. In this situation, will the above code (usb_host_msc.c) work?

    Thanks,

    Abhay

  • Hi Amit,

    Any update related to my query on USB signals?

    Thanks,

    Abhay

     

  • Hello Abhay

    It should work even with this 4 pins. To check, that I ran the usb_host_msc application on the DK-TM4C129 with the configuration of USB0ID and USB0VBUS commented and it still continued to connect to the USB Mass Storage device.

    Regards

    Amit

  • Hi Amit,

    I'm not getting device detected/enumerated. Please refer the following code - I think that there is some problem in intial setup. I've not populated while(1) loop to keep the post small. when I try to run the the code, it always shows STATE_NO_DEVICE.

    main()
    {
     //Clock setting
     SysCtlClockFreqSet(SYSCTL_OSC_INT | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480, 120000000);
     
     //Pinout Setting -  USB0EPEN-> Port A_6, USB0PFLT->Port A_7, USB0DP->Port L_6, USB0DM->Port L_7
     SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
     HWREG(GPIO_PORTA_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
        HWREG(GPIO_PORTA_BASE + GPIO_O_CR) = 0xff;
        ROM_GPIOPinConfigure(GPIO_PA6_USB0EPEN);
        ROM_GPIOPinConfigure(GPIO_PA7_USB0PFLT);
        ROM_GPIOPinTypeUSBDigital(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7);
        ROM_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);
     
     // Initialize the USB stack for host mode.
        USBStackModeSet(0, eUSBModeForceHost, 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 USB controller for host operation.
        USBHCDInit(0, g_pHCDPool, HCD_MEMORY_SIZE);
     
     while(1)
     {
      USBHCDMain();
      switch(g_eState)
            {
       case STATE_DEVICE_ENUM:
          while(USBHMSCDriveReady(g_psMSCInstance))
       {
        ROM_SysCtlDelay(setclock / 100);
       }

       break;
       case STATE_NO_DEVICE:
       case STATE_UNKNOWN_DEVICE:
       case STATE_TIMEOUT_DEVICE:
       case STATE_POWER_FAULT:
      }
     }
    }

     

    Thanks,

    Abhay

  • Hi Amit,

    Actually no MSCCallback is happening.

     

    Thanks,

    Abhay

  • Hello Abhay,

    Can you zip the CCS project and attach it to the post

    Regards

    Amit

  • Hi Amit,

    Please find the attached code.

     

    Thanks,

    Abhay

    usb_host_msc.zip
  • Hello Abhay

    You forgot to add the USB Interrupt Handler in the startup file

    extern void USB0OTGModeIntHandler(void);

    and map it in the vector table in the startup file

        USB0OTGModeIntHandler,                      // USB0
    After making this small change, the USB Drive is coming up

    Regards

    Amit

  • Hi Amit,

    Thanks you for pointing this. Now after adding this ISR i'm getting into callback.

    Thanks,

    Abhay

  • Hi Amit,

    I have one query - as you asked me to add "USB0OTGModeIntHandler" in startup file. As the name suggests OTG, do we need to configure the OTG mode?

     But in usb_host_msc.c, we are configuring host mode by using "USBStackModeSet(0, eUSBModeForceHost, 0)".

    I could read the files on USB stick successfully with above settings - i.e. "USB0OTGModeIntHandler" and "USBStackModeSet(0, eUSBModeForceHost, 0)".

    Am I doing correct  way? Please clarify.

    Thanks,

    Abhay

  • Hello Abhay,

    It is a naming convention for the Interrupt handlers in TM4C. You can call the interrupt handler anything else also. However when doing so you would need to update the name's all over the usblib.

    Regards

    Amit