Skip to main content
Visitor II
January 25, 2021
Question

Confused about F407 USB OTG FS

  • January 25, 2021
  • 3 replies
  • 3036 views

I wanted to implement a simple USB device only on a STM32F407. When I enable it in CubeMX under USB_OTG_FS I get a DP and DM line and there is an option to activate the VBUS line. Is activate VBUS absolutely necessary? It is after a simple device only mode. Also what is Activate SOF?

Also I tried implementing this on a custom board with just the DM and DP lines but I did not see any comms happening. The board is not powered from the USB. So I guess this is a self-powered device only mode. What am I missing?

    This topic has been closed for replies.

    3 replies

    Graduate II
    January 25, 2021

    If your board has its own power supply, you do not need VBUS and you should declare in your descriptor that you need 0mA.

    If you are taking your power from the USB cable, you need VBUS and you should declare in your descriptor how much power that you need.

    A self-powered device does not draw current from the bus.

    Visitor II
    January 25, 2021

    Where exactly should I add that? I see that the USBD_SELF_POWERED is enabled. Here are the settings as they are now.

    0693W000007CSjaQAG.png 

    0693W000007CSjfQAG.png

    Graduate II
    January 25, 2021

    It's a descriptor called USBD_CDC_CfgFSDesc in usbd_cdc.c.

    If you're going to be writing code for USB in more than a hobby project, you should probably get a copy of USB Complete by Jan Axelson.

    Visitor II
    January 26, 2021

    Thanks. It seems according to this document (sec 2.6, page 10) VBUS sensing is mandatory if the device is self-powered.

    Visitor II
    January 25, 2021

    Hi Hrishikesh,

    For more details, please refer to the STM32CubeF4 under Applications directory for CDC_Standalone applications.

    You can also refer to STM32 USB trainings for CDC.

    Best Regards,

    Ons.

    Visitor II
    January 26, 2021

    Thanks.

    Visitor II
    April 2, 2021

    Hi Hrishikesh,

    Can you please mark this question as answered by checking Select as best for the best answer ?

    Best Regards,

    Ons.