Hello @NIX AIR SOLUTIONS ,
Based on the USB specification, a USB device must use VBUS sensing detection. When host connection is detected by the device, device connects pull-up resistor either to D+ or to D- data signal, allowing host to detect device presence on the bus.
1. Solution with a dedicated VBUS pin (PA9)
In order to reduce the voltage on PA9 below 4V, the usage of a voltage divider is recommended, so that AMR cannot be violated.
Recommended resistor bridge is "vbus-- R1=4.7k -- R2=10k -- gnd" and then VBUS detection (PA9) can be taken between R1 and R2.
2. Solution without usage of a dedicated VBUS pin
Any 5V tolerant pin with external interrupt functionality can be used with an external resistor divider, to fulfill AMR conditions. In this case, recommended values are 2x100 kOhms .
However the disadvantage of this solution is that the software handling of VBUS presence event needs to be implemented by the customer, since this is not managed within our STM32 USB library for the time being.
It is recommended to use a physical pull-up resistor.
For more information about how VBUS sensing shall be managed, I recommend you to take a look to Management of VBUS sensing for USB device design FAQ.
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.