cancel
Showing results for 
Search instead for 
Did you mean: 

usb otg host/device mode switch

JChen.24
Associate III

Hi,

I have STM32F746 discovery board. I use USB OTG host/device mode on the Micro USB FS port.  

If the OTG cable plugged is a flash drive, the firmware detect as a MSC host mode. If the OTG cable

plugged is a USB type A to micro USB, the firmware detect as a VCP serial device mode.

How the firmware automatically detect device/host mode when the different OTG cable plug in? Is there any USB read

pin signal level change between the two cables?

7 REPLIES 7
TDK
Guru

If a device is a slave, it ties the ID pin to GND. The OTG hardware can have a weak pullup on this pin and if the signal is low, the attached item is a device, otherwise it is a host.

If you feel a post has answered your question, please click "Accept as Solution".

Thank you very much for the info. I will try it.

JChen.24
Associate III

I measure 0V on id line, with both flash drive(host) and VCP(device) USB OTG cables.

Is there any examples for OTG Dual Role Device operation on F7 series?

I have separate firmware for host and device mode, but do not know how to combine them.

TDK
Guru

Do you have a pullup on the line?

If you feel a post has answered your question, please click "Accept as Solution".
JChen.24
Associate III

I am using STM32F746G Discovery board, no pull up resistor in id line.

Use internal pull-ups on the ID pin, if there's no external one.

There's no ready-made OTG support in Cube, as far as I know. You need to stop ("deinit") the device stack and start the host stack, and vice versa, when the ID pin state changes.

JW

JChen.24
Associate III

I got it running. Thanks a lot! TDK and waclawek.