STM32F407 VBUS sensing detection
I am developing a device that implements the USB device class.
According to application note AN4879 "Introduction to USB Hardware and PCB Design Considerations Using STM32 Microcontrollers" it is written as follows:
Based on the USB specification, a USB device must use VBUS sensing detection. When the device detects the host presence, it connects its pull-up resistor to either a D+ or D- data signal. This allows the host to detect the device presence on the bus. There are two cases:
• The USB device is bus-powered. VBUS sensing is not mandatory (USB is always connected when the device is powered)
• The device is self-powered. VBUS sensing is mandatory. Pin PA9, a five volt-tolerant pin, which includes an additional function natively dedicated to VBUS sensing.
I have an option when the device is self-powered. Therefore, VBUS sensing is mandatory.
It is also written that the user must avoid the situation when the MCU is not powered, and a 5 V VBUS is connected to PA9.
The absolute maximum ratings table of the datasheet indicates that the five volt-tolerant pin voltage cannot exceed VDD + 4 V. The user must avoid the situation when the MCU is not powered, and a 5 V VBUS is connected to PA9: this violates the condition on absolute maximum ratings, and can result in permanent damage to the device. For this purpose, it is mandatory to reduce the voltage on PA9 below 4 V. For a reliable and safe VBUS detection, the use of a voltage divider is recommended to guarantee absolute maximum ratings.
The document suggests using a resistive divider. I can't understand the following:
To minimize the DC current, the total resistance between VBUS and GND must be high. The basic GPIO input levels (VIL, VIH) can now be used with the resistor divider. As this method uses the regular GPIO functionality, the VBUS sensing function (OTG_GCCFG.VBDEN), embedded in PA9, should not be enabled.
Why can't we use PA9? It's much easier. We don't have to write our own code to detect VBUS, using gpio.
Why do we need to minimize the DC current? My device has no current consumption limit.
I would be glad if someone could clarify these points.
Thanks!
