Skip to main content
Graduate
January 12, 2024
Question

USB OTG dual role - auto switch over - configuring

  • January 12, 2024
  • 3 replies
  • 2155 views

Hello,

We are using a STM32F407 discovery board. We need to configure the USB as OTG/Dual_Role_Device. I have each (USB Host and USB Device) working in separate projects

In CubeMX when I select OTG/Dual_Role_Device, the USB_DEVICE and USB_HOST are grayed out as well as the FATFS not having USB Disk as an option.

Why is this?

Any example out there?

I did see this thread where the issue was also seen.

https://community.st.com/t5/stm32-mcus-products/usb-otg-dual-role-selection-from-cube-mx/td-p/569876

It appears from this that the OTG dual mode auto switching functionality between USB HOST and USB Device is have never worked - broken?

Does anyone have any work arounds for this?

Thanks for any help.

Brent

 

 

 

 

 

 

 

    This topic has been closed for replies.

    3 replies

    Super User
    January 13, 2024

    > It appears from this that the OTG dual mode auto switching functionality between USB HOST and USB Device is have never worked - broken?

    Why do you think there *is* some automatic switchover?

    JW

     

    BAWAuthor
    Graduate
    January 22, 2024

    Not sure I understand what you are asking?

    Can you point me to a working example of the auto switchover?

    Can you help me understabd why in CubeMX when I select OTG/Dual_Role_Device, the USB_DEVICE and USB_HOST are grayed out as well as the FATFS not having USB Disk as an option?

    Thanks for your help.

    Brent

     

     

     

    BAWAuthor
    Graduate
    January 22, 2024

    I found a post from you (see below). So basically, to switch between modes we need to manually use a pin to determine what mode we want and uninitialize/initialize the mode we need.

    I am new to USB. I guess I was thinking the automatic switchover would take care of doing this.

    USB otg automatic role switching device cdc - host... - Page 2 - STMicroelectronics Community

    You are right, but there is no magic in switching between the two modes on one port, either - simply uninitialize the mode you don't need and initialize the one which you need. The stimulus upon which such role switch occurs may be any upon your choice; the "official" one is the ID pin on the USB-microAB receptacle (there's some support for it in the OTG modules but it's basically just a pin interrupt) so that the role is given by the cable/plug wiring; but it may be also switched for example from a software menu.

    JW