cancel
Showing results for 
Search instead for 
Did you mean: 

Confused about F407 USB OTG FS

Hrishikesh
Senior

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?

7 REPLIES 7

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.

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

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.

Ons KOOLI
Senior III

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.

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

Thanks.

Hi Hrishikesh,

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

Best Regards,

Ons.