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/TM4C129ENCPDT: host ulpi with internal clock.

Part Number: TM4C129ENCPDT


Tool/software: Code Composer Studio

Hi,

 I am trying to get  board that we build to work in ULPI host mode, the ulpi chip is USB3320 and I have it configured for internal clock source.

the target is a hub.....

I can read and write the registers with no errors ever ,  but nothing is going on with the bus.

The USB0 DEV_CTL register indicates that it is in device mode and I cannot get it to go to host mode.

I had this board running on USB full speed with internal usb connection and hub with no issues.

The board was designed to allow for either internal or external usb, but  one or the other only.

 

  • Hi George,
    Have you had a chance to to try the <TivaWare_Installation>\examples\boards\dk-tm4c129x\usb_host_msc in ULPI mode?

    Please also refer to section 4.4 of the system design guideline app note on the ULPI interface careabouts. www.ti.com/.../spma056.pdf

    You may also find the below posts helpful.

    e2e.ti.com/.../561997
    e2e.ti.com/.../1108765
    e2e.ti.com/.../415145
  • all the example are device mode and external clock .
    there are no examples of ULPI host mode that i can find.
  • Maybe i need to clarify,

    All the examples and posts I have been able to find are USB 2.0 device, typically with external clock.

    I find one discrepancy in documentation , the clock divider for the 480 mhz PLL output clock is supposed to to be 8 ,
    but i then get a 30MHZ clock out of the USB clock pinand nothing works, if i set the divider to 4, i get 60MHZ out and I can talk to the ULPI.

    My pll setup is straight out of the documentation and I know for a fact the internal clock is truly 120mhz since i use it for timers and systick as 120mhz.

    I cannot get the USB controller to go into forced USB host mode.
    I can read and write the ULPI registers with no obvious issues. but the internal DEV_CTL register always indicate it is a device.
    The USB register documentation is very lacking in any detail as to what things should be at.
    all the documentation has is register names , I can only tell wheat bits are by the debugger and register view.

    ALSO , i had this firware working fine as a USB host with the internal full speed controller.
    I want to switch to external ulpi high speed , using the same code. for operation.

    as an fyi, the ID pin on the usb3320 is hard wired to ground so it should be forced to Host mode.

    I know that on ULPI, the RX_CMD that is sent back has that pin on bit 6 but i don't see any way to get that pin state in registers..
    and the USB_GPCS_DEVMOD is set to 2 by the driver , but i have no clue if this is right or wrong as there is nothing on this topic in any documentation.
  • Hello George,

    Can you please share the configuration of the USB controller being done in the application for USB host mode function? Also please specify the TivaWare version being used?
  • #include <stdint.h>
    #include <string.h>
    #include "tbooltype.h"
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"

    #include "driverlib/sysctl.h"
    #include "driverlib/rom.h"
    #include "driverlib/rom_map.h"
    #include "driverlib/usb.h"


    #include "third_party/fatfs/src/ff.h"

    #include "usblib/usblib.h"
    #include "usblib/usbhid.h"
    #include "usblib/host/usbhost.h"
    #include "usblib/host/usbhhid.h"
    #include "usblib/host/usbhhub.h"


    #include "usblib/host/usbhhidkeyboard.h"

    //#include "utils/ustdlib.h"

    #include "usb_host_hub.h"


    // The size of the host controller's memory pool in bytes.
    //
    //*****************************************************************************
    #define HCD_MEMORY_SIZE 128

    //*****************************************************************************
    //
    // The memory pool to provide to the Host controller driver.
    //
    //*****************************************************************************
    uint8_t g_pui8HCDPool[HCD_MEMORY_SIZE * MAX_USB_DEVICES];

    //*****************************************************************************
    //
    // Declare the USB Events driver interface.
    //
    //*****************************************************************************
    DECLARE_EVENT_DRIVER(g_sUSBEventDriver, 0, 0, USBHCDEvents);

    //*****************************************************************************
    //
    // The global that holds all of the host drivers in use in the application.
    // In this case, only the Keyboard class is loaded.
    //
    //*****************************************************************************
    static tUSBHostClassDriver const * const g_ppHostClassDrivers[] =
    {
    &g_sUSBHostMSCClassDriver,
    &g_sUSBHIDClassDriver,
    &g_sUSBHubClassDriver,
    &g_sUSBEventDriver
    };

    //*****************************************************************************
    //
    // This global holds the number of class drivers in the g_ppHostClassDrivers
    // list.
    //
    //*****************************************************************************
    static const uint32_t g_ui32NumHostClassDrivers =
    sizeof(g_ppHostClassDrivers) / sizeof(tUSBHostClassDriver *);

    //*****************************************************************************
    //
    // The number of SysTick ticks per second.
    //
    //*****************************************************************************
    #define TICKS_PER_SECOND 100
    #define MS_PER_SYSTICK (1000 / TICKS_PER_SECOND)





    //*****************************************************************************
    //
    // Status bar boxes for hub ports.
    //
    //*****************************************************************************
    #define NUM_HUB_STATUS 4
    struct
    {
    //
    // Holds if there is a device connected to this port.
    //
    bool bConnected;

    //
    // The instance data for the device if bConnected is true.
    //
    uint32_t ui32Instance;

    //device class

    uint32_t Class;
    uint32_t SubClass;

    }
    g_psHubStatus[NUM_HUB_STATUS];


    /*****************************************************************************
    //
    // This is the generic callback from host stack.
    //
    // pvData is actually a pointer to a tEventInfo structure.
    //
    // This function will be called to inform the application when a USB event has
    // occurred that is outside those related to the keyboard device. At this
    // point this is used to detect unsupported devices being inserted and removed.
    // It is also used to inform the application when a power fault has occurred.
    // This function is required when the g_USBGenericEventDriver is included in
    // the host controller driver array that is passed in to the
    // USBHCDRegisterDrivers() function.
    //
    *****************************************************************************/

    extern char HIDDEV_connected;

    void
    USBHCDEvents(void *pvData)
    {
    tEventInfo *pEventInfo;
    uint8_t ui8Port;

    //
    // Cast this pointer to its actual type.
    //
    pEventInfo = (tEventInfo *)pvData;

    //
    // Get the hub port number that the device is connected to.
    //
    ui8Port = USBHCDDevHubPort(pEventInfo->ui32Instance);

    switch(pEventInfo->ui32Event)
    {
    case USB_EVENT_UNKNOWN_CONNECTED:
    case USB_EVENT_CONNECTED:
    {
    //
    // If this is the hub then ignore this connection.
    //
    if(USBHCDDevClass(pEventInfo->ui32Instance, 0) == USB_CLASS_HUB)
    {
    break;
    }

    //
    // If this is not a direct connection, then the hub is on
    // port 0 so the index should be moved down from 1-4 to 0-3.
    //
    if(ui8Port > 0)
    {
    ui8Port--;
    }

    //
    // Save the device instance data.
    //
    g_psHubStatus[ui8Port].ui32Instance = pEventInfo->ui32Instance;
    g_psHubStatus[ui8Port].bConnected = true;
    g_psHubStatus[ui8Port].Class = USBHCDDevClass(pEventInfo->ui32Instance, 0);
    g_psHubStatus[ui8Port].SubClass = USBHCDDevSubClass(pEventInfo->ui32Instance, 0);
    // usbtmr=0;
    if (g_psHubStatus[ui8Port].Class==3)
    HIDDEV_connected=1;

    //
    // Update the port status for the new device.
    //

    break;
    }
    //
    // A device has been unplugged.
    //
    case USB_EVENT_DISCONNECTED:
    {
    //
    // If this is not a direct connection, then the hub is on
    // port 0 so the index should be moved down from 1-4 to 0-3.
    //
    if(ui8Port > 0)
    {
    ui8Port--;
    }

    //
    // Device is no longer connected.
    //
    g_psHubStatus[ui8Port].bConnected = false;
    if (g_psHubStatus[ui8Port].Class==3)
    HIDDEV_connected=0;


    //
    // Update the port status for the new device.
    //

    break;
    }
    default:
    {
    break;
    }
    }
    }





    //*****************************************************************************
    //
    // This is the callback from the USB HUB mouse handler.
    //
    // pvCBData is ignored by this function.
    // ui32Event is one of the valid events for a mouse device.
    // ui32MsgParam is defined by the event that occurs.
    // pvMsgData is a pointer to data that is defined by the event that occurs.
    //
    // This function will be called to inform the application when a mouse has
    // been plugged in or removed and any time mouse movement or button pressed
    // is detected.
    //
    // This function will return 0.
    //
    //******************************tHubInstance***********************************************



    void
    HubCallback(tHubInstance *psHubInstance, uint32_t ui32Event,
    uint32_t ui32MsgParam, void *pvMsgData)
    {
    // usbtmr=0;
    }



    extern uint32_t g_ui32SysClock;


    void
    USBULPIPinoutSet(void)
    {



    //
    // Enable all the peripherals that are used by the ULPI interface.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);

    //
    // ULPI Port B pins.
    //
    ROM_GPIOPinConfigure(GPIO_PB2_USB0STP);
    ROM_GPIOPinConfigure(GPIO_PB3_USB0CLK);
    ROM_GPIOPinTypeUSBDigital(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_3);
    GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_3,
    GPIO_STRENGTH_12MA, GPIO_PIN_TYPE_STD);

    //
    // ULPI Port P pins.
    //
    ROM_GPIOPinConfigure(GPIO_PP2_USB0NXT);
    ROM_GPIOPinConfigure(GPIO_PP3_USB0DIR);
    ROM_GPIOPinConfigure(GPIO_PP4_USB0D7);
    ROM_GPIOPinConfigure(GPIO_PP5_USB0D6);
    ROM_GPIOPinTypeUSBDigital(GPIO_PORTP_BASE, GPIO_PIN_2 | GPIO_PIN_3 |
    GPIO_PIN_4 | GPIO_PIN_5);
    GPIOPadConfigSet(GPIO_PORTP_BASE,
    GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5,
    GPIO_STRENGTH_12MA, GPIO_PIN_TYPE_STD);

    //
    // ULPI Port L pins.
    //
    ROM_GPIOPinConfigure(GPIO_PL5_USB0D5);
    ROM_GPIOPinConfigure(GPIO_PL4_USB0D4);
    ROM_GPIOPinConfigure(GPIO_PL3_USB0D3);
    ROM_GPIOPinConfigure(GPIO_PL2_USB0D2);
    ROM_GPIOPinConfigure(GPIO_PL1_USB0D1);
    ROM_GPIOPinConfigure(GPIO_PL0_USB0D0);
    ROM_GPIOPinTypeUSBDigital(GPIO_PORTL_BASE, GPIO_PIN_0 | GPIO_PIN_1 |
    GPIO_PIN_2 | GPIO_PIN_3 |
    GPIO_PIN_4 | GPIO_PIN_5);
    GPIOPadConfigSet(GPIO_PORTL_BASE,
    GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 |
    GPIO_PIN_4 | GPIO_PIN_5,
    GPIO_STRENGTH_12MA, GPIO_PIN_TYPE_STD);

    //
    // Port B pins used to control the external USB reset.

    //
    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_4 );
    ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4, GPIO_PIN_4 );
    }


    volatile static uint8_t buf[128];

    void CaptureULPI(){
    buf[0] = USBULPIRegRead(USB0_BASE, 0);
    buf[1] = USBULPIRegRead(USB0_BASE, 1);
    buf[2] = USBULPIRegRead(USB0_BASE, 2);
    buf[3] = USBULPIRegRead(USB0_BASE, 3);
    buf[4] = USBULPIRegRead(USB0_BASE, 4);
    buf[7] = USBULPIRegRead(USB0_BASE, 7);
    buf[0xa] = USBULPIRegRead(USB0_BASE, 0xa);
    buf[0xD] = USBULPIRegRead(USB0_BASE, 0xd);
    buf[0x10] = USBULPIRegRead(USB0_BASE, 0x10);
    buf[0x13] = USBULPIRegRead(USB0_BASE, 0x13);
    buf[0x14] = USBULPIRegRead(USB0_BASE, 0x14);
    if (buf[0]!=0x24)
    return;
    }





    extern volatile int gptimer3;
    extern uint32_t g_ui32SysClock;



    void Init_USBhost(){
    uint32_t i32Idx;
    uint32_t ui32Setting;
    int ui32PLLRate;

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);

    USBULPIPinoutSet();


    //
    // Enable Clocking to the USB controller.
    //

    //
    // Tell the USB library the CPU clock and the PLL frequency.
    //
    //


    // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
    // ROM_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);


    // uint32_t ui32PLLRate,i32Idx;


    // SysCtlVCOGet(SYSCTL_XTAL_25MHZ, &ui32PLLRate);


    //
    // Initialize the hub port status.
    //
    for(i32Idx = 0; i32Idx < NUM_HUB_STATUS; i32Idx++)
    {
    g_psHubStatus[i32Idx].bConnected = false;
    }


    //
    // Enable Interrupts
    //
    ROM_IntMasterEnable();


    //
    // Tell the USB library the CPU clock and the PLL frequency.
    //
    // USBDCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &g_ui32SysClock);


    // USBDCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate);

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


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


    //
    // 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.
    //
    ui32Setting = USBLIB_FEATURE_ULPI_HS;
    USBOTGFeatureSet(0, USBLIB_FEATURE_USBULPI, &ui32Setting);

    ui32Setting = USBLIB_FEATURE_POWER_SELF;
    USBOTGFeatureSet(0,USBLIB_FEATURE_POWER, &ui32Setting);

    USBOTGFeatureSet(0, USBLIB_FEATURE_CPUCLK, &g_ui32SysClock);
    ui32PLLRate = 60000000 *4;
    USBOTGFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate);

    //
    // Initialize the USB controller for Host mode.
    //
    /* ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4, 0 );
    gptimer3 = 3;
    while (gptimer3);
    ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4, GPIO_PIN_4 );
    gptimer3 = 3;
    while (gptimer3);
    */


    // USBULPIRegWrite(USB0_BASE, 4,0x40);
    // buf[4] = USBULPIRegRead(USB0_BASE, 4);

    // USBHighSpeed(USB0_BASE,true);
    // ULPIPowerTransceiver(USB0_BASE, f);


    KeyboardOpen();

    // OPen Thumb drive int
    MSCOpen(g_ui32SysClock);
    //
    // Open a hub instance and provide it with the memory required to hold
    // configuration descriptors for each attached device.
    //
    USBHHubOpen(HubCallback);

    USBHCDInit(0, g_pui8HCDPool, sizeof(g_pui8HCDPool));
    CaptureULPI();

    }

    tivaware 2.1.4.178



    Pretty convince that the USB controller simply does not do ULPI host mode.

    No matter how i setup the interface, as soon as i "set the start session" bit , the ULPI if changed to FS receive settings and nothing i have been able to set can make it go to host settings.
    anytime i start session{in register view as well }, it reverts to device.
  • P.S.
    clock is set in main as follows.

    //
    //Set clock to Run from the PLL at 120 MHz.
    // and set g_ui32SysClock to its value so we can use it to init many other clock rate sensitive devices and functions.
    //
    g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_480), 120000000);
  • My reply to this seems o have gotton lost

    Tivaware 2.1.4.178



    void
    USBULPIPinoutSet(void)
    {



    //
    // Enable all the peripherals that are used by the ULPI interface.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);

    //
    // ULPI Port B pins.
    //
    ROM_GPIOPinConfigure(GPIO_PB2_USB0STP);
    ROM_GPIOPinConfigure(GPIO_PB3_USB0CLK);
    ROM_GPIOPinTypeUSBDigital(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_3);
    GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_3,
    GPIO_STRENGTH_12MA, GPIO_PIN_TYPE_STD);

    //
    // ULPI Port P pins.
    //
    ROM_GPIOPinConfigure(GPIO_PP2_USB0NXT);
    ROM_GPIOPinConfigure(GPIO_PP3_USB0DIR);
    ROM_GPIOPinConfigure(GPIO_PP4_USB0D7);
    ROM_GPIOPinConfigure(GPIO_PP5_USB0D6);
    ROM_GPIOPinTypeUSBDigital(GPIO_PORTP_BASE, GPIO_PIN_2 | GPIO_PIN_3 |
    GPIO_PIN_4 | GPIO_PIN_5);
    GPIOPadConfigSet(GPIO_PORTP_BASE,
    GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5,
    GPIO_STRENGTH_12MA, GPIO_PIN_TYPE_STD);

    //
    // ULPI Port L pins.
    //
    ROM_GPIOPinConfigure(GPIO_PL5_USB0D5);
    ROM_GPIOPinConfigure(GPIO_PL4_USB0D4);
    ROM_GPIOPinConfigure(GPIO_PL3_USB0D3);
    ROM_GPIOPinConfigure(GPIO_PL2_USB0D2);
    ROM_GPIOPinConfigure(GPIO_PL1_USB0D1);
    ROM_GPIOPinConfigure(GPIO_PL0_USB0D0);
    ROM_GPIOPinTypeUSBDigital(GPIO_PORTL_BASE, GPIO_PIN_0 | GPIO_PIN_1 |
    GPIO_PIN_2 | GPIO_PIN_3 |
    GPIO_PIN_4 | GPIO_PIN_5);
    GPIOPadConfigSet(GPIO_PORTL_BASE,
    GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 |
    GPIO_PIN_4 | GPIO_PIN_5,
    GPIO_STRENGTH_12MA, GPIO_PIN_TYPE_STD);

    //
    // Port B pins used to control the external USB reset.

    //
    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_4 );
    ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4, GPIO_PIN_4 );
    }




    void Init_USBhost(){
    uint32_t i32Idx;
    uint32_t ui32Setting;
    int ui32PLLRate;

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);

    USBULPIPinoutSet();


    //
    // Enable Clocking to the USB controller.
    //

    //
    // Tell the USB library the CPU clock and the PLL frequency.
    //
    //


    // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
    // ROM_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);


    // uint32_t ui32PLLRate,i32Idx;


    // SysCtlVCOGet(SYSCTL_XTAL_25MHZ, &ui32PLLRate);


    //
    // Initialize the hub port status.
    //
    for(i32Idx = 0; i32Idx < NUM_HUB_STATUS; i32Idx++)
    {
    g_psHubStatus[i32Idx].bConnected = false;
    }


    //
    // Enable Interrupts
    //
    ROM_IntMasterEnable();


    //
    // Tell the USB library the CPU clock and the PLL frequency.
    //
    // USBDCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &g_ui32SysClock);


    // USBDCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate);

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


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


    //
    // 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.
    //
    ui32Setting = USBLIB_FEATURE_ULPI_HS;
    USBOTGFeatureSet(0, USBLIB_FEATURE_USBULPI, &ui32Setting);

    ui32Setting = USBLIB_FEATURE_POWER_SELF;
    USBOTGFeatureSet(0,USBLIB_FEATURE_POWER, &ui32Setting);

    USBOTGFeatureSet(0, USBLIB_FEATURE_CPUCLK, &g_ui32SysClock);
    ui32PLLRate = 60000000 *4;
    USBOTGFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate);

    //
    // Initialize the USB controller for Host mode.
    //
    /* ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4, 0 );
    gptimer3 = 3;
    while (gptimer3);
    ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4, GPIO_PIN_4 );
    gptimer3 = 3;
    while (gptimer3);
    */


    // USBULPIRegWrite(USB0_BASE, 4,0x40);
    // buf[4] = USBULPIRegRead(USB0_BASE, 4);

    // USBHighSpeed(USB0_BASE,true);
    // ULPIPowerTransceiver(USB0_BASE, f);


    KeyboardOpen();

    // OPen Thumb drive int
    MSCOpen(g_ui32SysClock);
    //
    // Open a hub instance and provide it with the memory required to hold
    // configuration descriptors for each attached device.
    //
    USBHHubOpen(HubCallback);

    USBHCDInit(0, g_pui8HCDPool, sizeof(g_pui8HCDPool));
    CaptureULPI(); { reads ulpi registers into a array i can check to see what is set/changed}

    }


    pretty convinced now that ULPI host mode is not possible, as soon as i set "start session" the registers get changed to device mode settings.....

    please note the commented out code, i tried a LOT of things ........

  • Hello George

    George Jaray32 said:
    //
    // 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.
    //
    ui32Setting = USBLIB_FEATURE_ULPI_HS;
    USBOTGFeatureSet(0, USBLIB_FEATURE_USBULPI, &ui32Setting);

    ui32Setting = USBLIB_FEATURE_POWER_SELF;
    USBOTGFeatureSet(0,USBLIB_FEATURE_POWER, &ui32Setting);

    USBOTGFeatureSet(0, USBLIB_FEATURE_CPUCLK, &g_ui32SysClock);
    ui32PLLRate = 60000000 *4;
    USBOTGFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate);

    Whya re you calling USBOTGFeatureSet for Host function when it should be USBHCDFeatureSet. For each of the USBDCD commands there is a USBHCD command as well.

  • mostly because the example i started with was that way, it was aa OTG host controller , i only need forced host. 

     but really its kind of meaningless as "feature set" just sets internal parameter values to be used by "init" , it does not actually change what is executed. 

    only "USBHCDInit" sets host specific settings using the paramters preset by feature set. 

    ___________________________________________________________________

    ui32Setting = USBLIB_FEATURE_ULPI_HS;
    USBOTGFeatureSet(0, USBLIB_FEATURE_USBULPI, &ui32Setting);

     simply result  in  an  int being set to 16 which is ulpi mode  , then init sets the device into ULPI, then sets the ULPI registers to HS.   this is actually mapped to the same in all 3 cases.

    the parameter only controls a branch to  set the ULPI registers HS , FS or LS.

    ____________________________________________________________________

    ui32Seting = USBLIB_FEATURE_POWER_SELF;
    USBOTGFeatureSet(0,USBLIB_FEATURE_POWER, &ui32Setting);

    this is meaningless in host mode and is left over from early hit and miss trying.  in my code  tracing the parameter it sets, is not used by the init .

    ___________________________________________________________________

    USBOTGFeatureSet(0, USBLIB_FEATURE_CPUCLK, &g_ui32SysClock);

         simply tells the usb lib the cpu clock rate.   ALWAYS means the same.

    ___________________________________________________________________


    ui32PLLRate = 60000000 *4;
    USBOTGFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate);

      simply tells the usb lib to set the desired frequency.  

    because the ULPI mode is set, this make the clock coming off the clock pin be 60MHZ, and internally sourced, if its "0" the USB clock is external {from the ULPI}..

    the TI code only had one rule check, the number must be dividable by 60MHZ,.

    all other methods of usb usage have this set to 0 , external ULPI clock source MUST be 60mhz .

    ___________________________________________________________________

     all the above i verified by stepping through the debugger , {I copied the needed source to my project to walk  through the source code. }

    yes it probably should be  set to  USBHCDFeatureSet , but the net result is not altered as non of the feature set's are host specific , they set a values used by the INIT cal the same way for all modes. 

    the failure {bad behavior } occurs when i call    USBHCDInit(0, g_pui8HCDPool, sizeof(g_pui8HCDPool));

    no matter how the code initialize's the ULPI registers,  this call sets the ULPI registers to the same but  different values ,  {specifically FS mode and device mode}

     FYI: all the previous settings are properly set into the ULPI registers and internal USB registers.

    BUT. when the single call  the that sets the "start session"  bit in the DEV_CTRL register is set,

    the ULPI registers change to device mode settings  and the "start session"  bit is cleared. the DEV_CTRL register also indicates Device Mode not host..

    this call in the tivaware code is at the end of init as this is the call that normally starts host mode.

    when walking through the sampe code in NORMAL internal USB mode , this call actually does change the USB controller into host mode, and the DEV_CTRL register and the session start bit remains set properly for Host mode..

     

    I can change all those calls , but they don't really mean anything specific to the setting of host, device or otg.

     

  • P.S.

    I have been chasing this at a Hardware register level for some time now.

    In the tm4c129x , there is no real specific forced host, what there is , is a hardware register, that can be set to ignore ID and vbus status and always assume the settings for host. ID grounded and vbus valid good.

    but that implies and internal settings, externally the ULPI provides this info. in particular, the ID PIN, but it appears that both are ignored.

    The state of the ID pin is the thing that determines OTG host or device. it is hard wired to ground in the ULPI,
    but it's state is only reported in the RX cmd from the ULPI, which is not in a register and the internal USB does not separate it out meaningfully.

    the only example of ULPI usage I have found , {and there are very few } are as device with external clock source.