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.

Tiva C TM4C123GH6PM USB Host setup

Other Parts Discussed in Thread: TM4C123GH6PM

Hi there,

so I am trying to run my tiva c in usb host mode in order to connect a usb stick to the board, however i run into my faultISR on this line :

GPIOPinTypeUSBDigital(GPIO_PORTH_BASE, GPIO_PIN_3 | GPIO_PIN_4);

 when i try to run the code from the tivaware usb manual

//
// Enable Clocking to the USB controller.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
//
// Enable the peripherals used by this example.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
//
// Set the USB0EPEN and USB0PFLT pins to be controlled by the USB
// controller.
//
GPIOPinTypeUSBDigital(GPIO_PORTH_BASE, GPIO_PIN_3 | GPIO_PIN_4);
//
// Register the host class drivers.
//
USBHCDRegisterDrivers(0, g_ppsUSBHostClassDrivers,
g_ui32NumHostClassDrivers);
//
// Call any open routines on the device class interfaces here so that they
// are ready to receive callbacks if the device is already inserted on
// power on.
//
USBHMSCDriveOpen(0, MSCCallback);

//
// Initialize the host controller.
//
USBHCDInit(0, g_pui8HCDPool, HCD_MEMORY_SIZE);

tUSBHMSCInstance* device = USBHMSCDriveOpen(0, mscCallback);

while(USBHMSCDriveReady(device)) {

}

printf("Done initializing.\n");

I read something about 0-ohm resistors that need to be present for otg/host mode to work, is this related to my problem? If so, how would I go about attaching them to R25 and R29 on my tiva c?

Sorry If this sounds very newbish, however it is one of my first mc projects.

Thanks for the help.

  • Hello Kural

    On the TM4C123GH6PM GPIO Port H does not exist.

    To map the USB0EPEN and USB0PFLT on the TM4C123GH6PM the following options exist

    USB0EPEN: PF4 or PC6 or PD2

    USB0PFLT: PC7 or PD3

    For using the above pins (e.g. PD2 and PD3) the above will change to

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    //
    // Set the USB0EPEN and USB0PFLT pins to be controlled by the USB
    // controller.
    //
    GPIOPinTypeUSBDigital(GPIO_PORTD_BASE, GPIO_PIN_2 | GPIO_PIN_3);

    Are you sure you are compiling the code with the correct define for PART_TM4C123GH6PM and TARGET_IS_BLIZZARD_RB1 ?

    Regards

    Amit

  • Hi Amit,

    thanks for your reply.

    I changed my code to what you suggested, now it wont trigger a fault interrupt anymore, however i still cant get my mass storage device to connect to the TM4C123GH6PM ( getting an infinite loop at 

    while(USBHMSCDriveReady(device)) {

    Both defines you mentioned are defined in the compiler's build settings. I've been able to get device mode working, just host mode seems to be an issue. I am connecting a usb stick via a micro-usb adapter to the micro usb port, maybe thats the issue?

    Thanks for your help.

  • Hello Kurai,

    What about the DP DM signals. I do not see the same being configured. Also is this the TM4C123 LaunchPad you are using?

    Regards

    Amit

  • Hello Amit,

    yep, I am using the TM4C123 LaunchPad for this. If they are not in the code I provided, I probably haven't set them up. How would I go about that? I believed I was good to go with the sample code provided by the manual, guess I was wrong :(

    Btw, this is my setup if that helps: 

  • Hello Kurai,

    I am not sure from where you have picked up the code. But for reference you can refer to the following code in TIVAWare 2,1.0 release.

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

    Please note that the code given here is for the DK-TM4C123 and not the LauncPad so you would need to check the Pin Configurations.

    Regards

    Amit

  • thanks for the hint Amit. the sample code i've been using comes from the tivaware usb library documentation.

    i have trouble figuring out what pins i need on the launchpad. any pointers on that?

  • Hello Kurai,

    The pins to be configured for USB can be got from the LaunchPad User Guide on the TIVA-C web site which has the Schematic and the Pin description for the USB Pads.

    Regards

    Amit

  • Hello Kurai,

    I had the same problem as yours and it didn't work until I had to do some soldering in the device:

    1- Under the power switch there is three holes, you have to connect the ones above R14 and move the switch towards the device mode, you can use a wire but I did soldering for a fixed solution.
    2- Populate 0-ohm resistors on R25 and R29 that are next to the USB connector, in my case I did normal soldering and it was fine.
  • Hello user4237830,

    A picture addition to the forum would be a great asset.

    Regards
    Amit