cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Marcus1
Associate II

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.

4 REPLIES 4
TDK
Guru

> 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".

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
Associate II

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?

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