2025-02-24 10:21 AM
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!
2025-02-24 11:39 AM
> Why can't we use PA9? It's much easier. We don't have to write our own code to detect VBUS, using gpio.
You can use PA9 if you want, provided you satisfy the requirement that PA9 remains in safe limits.
> Why do we need to minimize the DC current? My device has no current consumption limit.
You don't have to minimize current if you have no limit and don't care, provided you don't draw so much power that the board fails. Using resistors in the 100 kOhm range is safe.
2025-02-24 12:19 PM
Dear TDK,
Thank you for your answer, now a lot has become clearer in my understanding.
Let me ask you a couple more questions.
I suggest using the following scheme:
I have corrected the diagram according to the suggestions in application note AN4879.
1) Please tell me if my edits are correct?
2) How important is it to use the ESDA7P60? Is it possible to do without it?
Thanks!
Best regards,
Alex