0
\$\begingroup\$

I am thinking about a relatively cheap and simple protection against USB reverse connection/reverse polarity. At the moment I am thinking about P-channel MOSFET, with the drain directed towards the USB socket. I heard that TVS diodes can also, in addition to protection against esd, prevent reverse polarity, but I would not be able to choose them exactly. Pins D + and D- are connected via resistors to the STM microcontroller.

As it is a Type P mosfet, the gate being low will cause the transistor to conduct from the drain to the source. I predict that when the usb plug is plugged inversely, the mosfet gate will be high and the mosfet will shut off, preventing damage to the receiving circuit.

But these are only my modest theoretical considerations, and I would like to ask if I have not made a logical error here or if something is not ok from a practical point of view. I saw some Regards!:)

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ This will work fine. In practice reverse polarity protection is provided by the connector itself (i.e. you can't plug it in wrong). If you're only using your device with commercial products (i.e. not hobbyist parts) then I wouldn't worry about reverse polarity protection. Have never seen it in the wild, even with the cheap cables. \$\endgroup\$ – Jon Feb 1 at 23:12
  • \$\begingroup\$ Agree - Unless somebody makes their own USB cable, you can be very sure the VCC will be VCC and GND is GND. 2A fuse is possibly also somewhat redundant as USB ports are internally current limited to about that value (or alot less). \$\endgroup\$ – Kyle B Feb 2 at 1:07
1
\$\begingroup\$

It looks like the FET protects from inverse polarity, but it is not needed as it is not possible to have wrong polarity out of an USB cable.

I would also like to point out that tying the D+ pin via resistor directly to 3.3V will not allow the MCU to control when it is ready to enumerate, so depending on what the MCU program does, it may fail to enumerate if it is not immediately ready with the USB peripheral at boot.

Another thing is, by grounding the ID pin, you are signaling that this device is an OTG master, not a USB device, so that won't work.

Also the connector shield is directly connected to ground, that may not be what you want either.

\$\endgroup\$
3
  • \$\begingroup\$ Believe or not, but I had an experience with factory confused wires inside the usb cable :) I am trying to read a bit about ID and shield connection, but I do not understand the D + connection issue yet. Is it voltage value of 3.3V or just D + should be left without this connection? \$\endgroup\$ – bodzio_stawski Feb 2 at 13:57
  • \$\begingroup\$ The problem is permanent connection to 3.3V. Even if MCU is in reset or booting or otherwise not ready yet for enumeration, the resistor signals to PC that device is ready for enumeration. PC may determine that the enumeration fails and stop communicating with the device. There is also chance that the pull-up resistor is internal to the MCU so it may not be necessary. \$\endgroup\$ – Justme Feb 2 at 14:57
  • \$\begingroup\$ Hmm, I use STM32F103C8 (datasheet says "To be compliant with the USB 2.0 full-speed electrical specification, the USBDP (D+) pin should be pulled up with a 1.5 kΩ resistor to a 3.0-to-3.6 V voltage range"). I think you mean this variant with control through a bipolar transistor controlled by a microcontroller at the end of the base. To be honest, I did not see, for example, in Bluepill there was such a solution (there was also only a permanently connected resistor). If the pull-up control in such a way is the best way, would you recommend me where to read about how to program it correctly? \$\endgroup\$ – bodzio_stawski Feb 3 at 22:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.