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: USB in manual Host mode

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

In our design I am using the pins PB0 (USBID) and PB1 (VBUS) for a second CAN bus. The VBUS signal is therefore monitored on another GPIO pin. The USB interface is only used in Mass storage device class (USB stick).

How do I config the USB driver to manually to be able to control the USBPEN and USBFLT pins?

I have modified the usb_host_msc example with no success.

My Initialization Code:

void Init_USB(void)
{
    uint32_t ui32PLLRate;

    g_eState = STATE_NO_DEVICE;
    g_eUIState = STATE_NO_DEVICE;
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
    ROM_uDMAEnable();
    ROM_uDMAControlBaseSet(g_sDMAControlTable);

    USBStackModeSet(0, eUSBModeHost, 0);
 
    USBHCDRegisterDrivers(0, g_ppHostClassDrivers, g_ui32NumHostClassDrivers);

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

    USBHCDPowerConfigInit(0, USBHCD_VBUS_MANUAL | USBHCD_FAULT_VBUS_NONE);  
    

    SysCtlVCOGet(SYSCTL_XTAL_25MHZ, &ui32PLLRate);
    USBHCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &ui32SysClock);
    USBHCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate);
    USBHCDInit(0, g_pHCDPool, HCD_MEMORY_SIZE);       // Initialize the USB controller for host operation.
    MAP_USBHostPwrEnable(USB0_BASE);                                 // Apply USB Power
    f_mount(0, &g_sFatFs);      // Initialize the file system.
    eStateCopy = g_eUIState;
}

Anybody who know about a working example?

Best Regards

Henning

  • Hello Henning,

    I may not be fully clear on your questions. Are you looking for a solution to use different pins for VBUS and USBID? Or do you only need help with how to configure the USB0EPEN and USB0PFLT pins?

    The code you posted is a bit confusing for me as well. You have a call for SYSCTL_PERIPH_UDMA with in the USB init? Are you wanting to use the UDMA for this as well...? I don't believe there are any uDMA channels which handle anything related to USB...

    In any case, for GPIO that are controlled by USB you need a SysCtlPeripheralEnable call for the SYSCTL_PERIPH_GPIOx that the pin falls under (x being the port name, so Port B would be SYSCTL_PERIPH_GPIOB for example).

    Then you also need to use GPIOPinConfigure to configure the exact pin such as GPIOPinConfigure(GPIO_PD6_USB0EPEN);

    Lastly, you need the API calls for either GPIOPinTypeUSBAnalog or GPIOPinTypeUSBDigital depending on your pin functionality (USB0EPEN is a TTL buffer type and therefore would be configured as digital for example, see Table 26-4 of the datasheet for help with that portion).

    The closest working examples we have at the usb_stick_demo and usb_stick_update examples.
  • Hello Ralph,

    The example I attached is a direct copy of usb_host_msc example, in that uDMA is used.

    I solved the issue by forcing to USB Host mode:

    USBStackModeSet(0, eUSBModeForceHost, 0);

    This mode disable the VBUS and ID pins.

    To enable power to usb, I used following Initialization:

    USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);

    After that I had power signal to the USB and I was able to use PB0 and PB1 (VBUS and ID pins) for a second CAN bus.


    Besr Regards,

    Henning