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.

TMS320C6748: USB peripheral does not enter host mode - puts garbage on the bus

Part Number: TMS320C6748
Other Parts Discussed in Thread: BQ25703, TPS65987

I am attempting to setup usb OTG on our TMS320C6748 DSP based system.
USB was already working in device mode, now we need to add features that require the DSP to act as a USB host.

Our system connects to USB through a USB C plug. The power configuration and data role negotiation through the CC lines are handled by an external PD3 controller (TPS65987). When a device is plugged in VBUS is supplied by the charger IC (BQ25703) in our system, which is controlled by software. The USB0_DRVVBUS pin is not connected and the USB0_ID pin is also left floating (as specified for OTG mode in the DSP reference manual).
So far everything is functional - When a device is plugged in, the PD3 controller detects it and sets itself up to be an DFP source port. Switching on the charger IC's OTG enable pin then puts 5V on VBUS.

A snippet of the log output:
===
# PD3 controller polls between sink and source modes, defaulting to UFP data mode
PD3 state: disconnected sink No connection UFP
PD3 state: disconnected source No connection UFP
PD3 state: disconnected sink No connection UFP
PD3 state: disconnected source No connection UFP

# <Plug event>
# PD3 controller lands on source mode and lands on DFP (host) mode
PD3 state: connected source Connection+Ra DFP
===

My plan is to use the PD3 controller status to determine whether to initialise the USB device driver or host driver.

Things go wrong when I try to setup host mode on the DSP.
The steps that I take are:
- Poll the PD3 controller for a plug event
- Initialize the CPPI 4.1 DMA for four endpoints
- Enable the USB peripheral clock
- Reset the USB peripheral
- Enable the USB Phy
- Setup endpoints
- Enable interrupts for the peripheral
- Enable endpoint interrupts
- Set the session request bit
- Poll the USB0_DRVVBUS bit to enable VBUS

The first issue is that the USB peripheral never seems to switch to host mode. The DEVCTL[HOSTMODE] is never set, and the DEVCTL[BDEVICE] remains set to "B" device. The session bit remains 0 and the VBUS is not being switched on.

Forcing the peripheral to operate in hostmode using the TESTMODE[FORCE_HOST] bit switches the DEVCTL lets me start a session.
With this configuration I can set the session bit and it remains active, triggering enabling of VBUS. However shortly after that, the VBUS is driven low again, and the peripheral reports a babble error. Also, when inspecting the data lines through a logic analyser the bus behaves very weird (see included capture). The DEVCTL[BDEVICE] is never set to "A" device.

Some details about the capture:
- the pulses on D- starting at 0.2s are short pulses (600ns) 1ms apart
- the pulses on D- get longer when the pulses on D+ start (600ns -> 1.5us), but are still happening every 1ms
- the pulses on D+ are 900ns and happen simultaneously with the pulses on D- (SE1)

An analog capture reveals that D+ and D- float at around 560mV:

I do not know where to look next to find what is failing.

  • Hello,

    Thanks for the detailed information. We don't support SW development on C6748 DSP any more. Please refer to this announcement and find resources from there.

    Meanwhile, I'll forward your inquiry to our HW team and see if they have any insight.

    Regards,

    Jianzhong

  • Hello,

    Correct me if I misunderstood the desired bus topology, but as I understand it you are not really wanting to use "OTG" but instead are wanting to use the C6748 in more of a "Dual Role" mode wherein the C6748 can be a USB Host (when a USB Device is plugged in), or can be a USB Device (when attached to a USB Host), but doesn't need to dynamically switch between the two modes in the same session. Please confirm.

  • Hello Luc van Leeuwen

    Please refer the below in addition to the inputs dave provided.

    To transition the MUSB controller to host mode, 1) directly ground the USB_ID pin, 2) set DEVCTL bit0 to 1, which pull high USB_DRVVBUS pin to turn on VBUS power supply.

    The MUSB controller user guide do not recommend to use TESTMODE[FORCE_HOST] for normal host mode operation.

     

    However, the MUSB controller is sensitive to the VBUS_IN pin signal: before step 2) above to set DEVCTL[bit0], VBUS_IN should be 0v. After DEVCTL[bit0] is set to 1, VBUS_IN pin should sense 5v (~4.7v?) within 100msec. Otherwise, the MUSB controller won't transition to host mode.

    Regards,

    Sreenivasa

  • Hi,

    Yes, this is correct.

    We either want to connect to a pc as a device (for updates, data extraction, etc.), or to a USB stick or a labelprinter as a host. There is no need to switch the USB mode while a connection is active.

    Edit:
    Although we don't need to dynamically switch from a functional perspective, we do not have access to the ID pin. So a dynamic role switch might be the only way to enter host mode. I have no clue on how to configure the peripheral to do this though. From what I have read, you first need to have a connection to start negotiation for role swaps. Since I never had a connection, I am not sure if this is possible.
    Is it possible to use USB OTG to establish a host when both connected ends are in device mode initially?
    Are there resources that describe setting up the USB peripheral in OTG mode? The reference manual only discusses Device and Host modes.

  • Hello Sreenivasa,

    Thank you for your response.
    I have double-checked the timing requirement for switching VBUS, and our system does meet that requirement.

    As for the ID pin, our system has this pin floating like I mentioned in my original post. We do have a testpad connected to it, so I did try connecting that to a spare GPIO and controlling the ID pin like that. When I do this, the peripheral now becomes an A device in host mode (DEVCTL[BDEVICE] = 0; DEVCTL[HOSTMODE] = 1). The code then ends up in the 'device connected' state in which it tries to read the device descriptor of the connected device. An improvement. However, this is not really an option for us since we already have systems in the field.

    Is there any way of overriding the ID pin state through a register that I missed? (I did not find reference for such things in the reference manual, other than the force host setting)
    Is there any other way of transitioning the peripheral to host mode?

  • Hi Luc,

    Unfortunately, the MUSB controller doesn't have a register bit to override the ID pin status.

    The ID pin is float if it is not pined out or not accessible, then the controller can only works in device mode. There is no other way to switch to host mode without directly grounding the ID pin.