Skip to main content
Marcus1
Associate II
May 5, 2020
Question

I want to add a USB CDC driver to my application on a STM32F446 (self powered device). However, I had to use the dedicated VBUS pin for another function.

  • May 5, 2020
  • 4 replies
  • 1000 views

According to https://community.st.com/s/article/FAQ-Management-of-VBUS-sensing-for-USB-device-design the software handling of VBUS presence event needs to be implemented by the customer.

How can I implement VBUS sensing on another pin SW wise? VBUS is connected to a GPIO through a resistor divider.

This topic has been closed for replies.

4 replies

TDK
May 5, 2020

> How can I implement VBUS sensing on another pin SW wise?

In general, keep the USB disabled until the pin is high, and when the pin goes low, disable the USB. You could monitor the pin manually or using EXTI.

"If you feel a post has answered your question, please click ""Accept as Solution""."
waclawek.jan
Super User
May 5, 2020

VBUS in the OTG only throws an interrupt anyway (albeit based on a comparator), so you can use any pin in this quality.

JW

Marcus1
Marcus1Author
Associate II
May 5, 2020

Thanks for your answers. And who controls the pull up/down resistors on the DP/DM lines to indicate the host a device is connected? Do I have to take care of that separately or is it handled by the driver when I enable the USB?

waclawek.jan
Super User
May 5, 2020

I don't know what's your driver, but the DP pullup is controlled by OTG_DCTL.SDIS.

Pulldowns are for host operation. There's no pullup on DM, as the OTG module in device mode is FS only.

JW