I have an STM32 board I am currently designing which is going to use the USB bus for communication and programming. The ground connector on the USB will be tied to the board ground, and the D+ and D- lines will go to the STM32's USB_DP and USB_DM with a pull up on the D+ line to signal full speed.

What I want to know is what to do with the USB VBUS line. I have no need for the board to be running off of the 5v USB power, it will always be connected to an external power supply. However I have read that the VBUS line may be important for communications, so I do not want to leave it floating, as that may make the communications inoperable.

What is the best thing to do with the VBUS line in a situation like this?

  • 1
    \$\begingroup\$ mention exact part number....whether it OTG/only peripheral.....Even for peripheral also few controllers will have 5V_VBUS sense pin to enable Pull up on D+/D- lines. Otherwise just put an LED to show USB connected. \$\endgroup\$ – user19579 Aug 5 '14 at 6:51
  • \$\begingroup\$ The part number is STM32F205, and it does have OTG capabilities but I do not plan on using OTG. I may or may not connect the board up as OTG though depending on if I have enough pins to spare. Do you have any examples of an STM32 OTG schematic? \$\endgroup\$ – Nick Aug 5 '14 at 13:26

According to the reference manual for the STM32F205, page 950, you want to do the following:

First, you want to disable the VBUS sensing option. This is done by setting the NOVBUSSENS bit in the OTG_FS_GCCFG register. In this case VBUS is considered internally to always be at VBUS valid level (5 V), so you don't need to run a trace from the VBUS pin on the USB connector over to the STM32F205 at all.

Note: you can also skip this step, and tie VBUS from the connector to the VBUS pin on the STM32F205, keeping the VBUS sensing capability (so, for example, you can tell if a USB cable has just been plugged in). Just don't implement the voltage regulator as shown in Figure 351 of the Reference Manual so your device doesn't try to power itself off the USB.

You can also disable the OTG capability and force a peripheral-only mode by setting the force device mode bit in the GlobalUSB configuration register (FDMOD in OTG_FS_GUSBCFG) to 1, forcing the OTG_FS core to work as a USB peripheral-only.

  • \$\begingroup\$ I always forget ST has the reference manuals which contain significantly more information than the regular datasheet. Thank you very much for the link, it contains everything I'll need. \$\endgroup\$ – Nick Aug 5 '14 at 15:48
  • \$\begingroup\$ Looks like this answer and the reference manual are seriously wrong. Disabling "VBUS sensing option" is not an option: it will violate USB specifications. See the correct answer on what to do with VBUS here, electronics.stackexchange.com/a/455854/117785 \$\endgroup\$ – Ale..chenski Sep 3 '19 at 4:25

Wonder if you already have a board and deciding which power plug to use or you are designing a new board yourself.

For first case, likely it is auto select.

For second case, you may find inspiration from Arduino on using MOSFET to automatically take power from multiple sources, USB or ext power connector.

Leave USB power pin open if you do not need to take power from the USB port. This will be same as if UNO has ext power and switch off the MOSFET

Arduino UNO circuit diagram

Some USB education info here

Hope it helps

  • 1
    \$\begingroup\$ I think he is designing the board and does not want to ever run it on USB power, so I don't see how your answer applies here. \$\endgroup\$ – Vladimir Cravero Aug 5 '14 at 8:31
  • \$\begingroup\$ now that's way better. the next time just leave a comment here tagging me, telling you edited the answer so that I can see the improoved version \$\endgroup\$ – Vladimir Cravero Aug 5 '14 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.