VBUS sensing detection
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.
- 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. 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.








