usb 2.0 FS hardwired device implementation without VBUS sense - Page 1
Forum section: electronics / general

author: uer166
author_rank: Super Contributor
timestamp: May 14, 2024, 06:51:44 pm
content: I have a need to implement a USB device that is hardwired to a Linux MPU. For mechanical reasons, 3 wires would be ideal (D+, D-, and REF).The device is self-powered, and while both the Linux MPU and the device are powered from same PSU, the device will boot much faster.The device is hard-wired: no unplugging/plugging of cables when it's on. It is implemented via a mainstream STM32 with ST's libs.>Do I need to add a 4th wire for 5V VBUS from host to device?>What is the risk/danger if I don't?>What is the role of VBUS sense per USB standard spec for self-powered devices? From what I can tell it is to avoid having live pull-ups on USB DP/DM, but that seems like a lame reason and there must be more.

author: ataradov
author_rank: Super Contributor
timestamp: May 14, 2024, 07:59:32 pm
content: There is no need for VBUS sensing for any type of device. Self powered devices can just ignore it. A lot of MCUs have a way to fake VBUS state or provide control over the pull-up resistors though a register bit.

author: peter-h
author_rank: Super Contributor
timestamp: May 15, 2024, 06:42:32 am
content: IIRC, VBUS sense is handy for detecting a cable disconnect, for various reasons. But if you never disconnect the cable then probably not needed.

author: ataradov
author_rank: Super Contributor
timestamp: May 15, 2024, 01:54:18 pm
content: You can detect cable disconnect by the lack of SOF interrupts.

author: peter-h
author_rank: Super Contributor
timestamp: May 15, 2024, 05:18:13 pm
content: OK; sure. Probably VBUS is actually needed for the detection of OTG device attachment. It's a good point though. From my project notes:PA9 is used to sense incoming USB +5V.PA9 is actually used even as a USB Slave, to detect when a cable (from a Controller) has been plugged or unplugged. That event is used to re-init the USB Slave. This may help:https://community.st.com/s/question/0D53W00001LTzmGSAT/32f417-pa8-usable-as-gpio-if-usb-fs-non-otg-is-being-used?t=1644317667636More herehttps://community.st.com/s/article/FAQ-Management-of-VBUS-sensing-for-USB-device-designMy product does not support OTG mode. Reasons for not supporting OTG are (a) customers expect all slaves to work with it but most won't (b) available power is limited.

author: ataradov
author_rank: Super Contributor
timestamp: May 15, 2024, 06:40:54 pm
content: No, OTG only uses ID pin. VBUS is never necessary.

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 15, 2024, 08:53:59 pm
content: Speaking of OTG, note that if you use a USB-C connector, things become a bit more complicated to support dual-role. I have used a TUSB320 for this. There are probably cheaper solutions / maybe some MCUs that do handle the CC1 and CC2 pins now, but this still seems relatively rare.

author: ataradov
author_rank: Super Contributor
timestamp: May 15, 2024, 09:04:20 pm
content: I have not seen general purpose MCUs that can do that. I've seen people assemble TUSB320 equivalent (just the polling part) from transistors and resistors, which is cheaper, but takes up board space and I/O pins.I expect there to be some really cheap device from an unknown vendor on LCSC. But it is also possible that this is not something a lot of people need.

author: peter-h
author_rank: Super Contributor
timestamp: May 15, 2024, 10:13:18 pm
content: QuoteI think it is used by ST's USB code, as I described. And practically everybody will be using "somebody's" USB code because USB is so complicated that practically nobody understands it.

author: uer166
author_rank: Super Contributor
timestamp: May 15, 2024, 10:55:23 pm
content: Quote from: peter-h on May 15, 2024, 10:13:18 pmI'm using ST's code right now. It seems to work without the VBUS sense, though was trying to confirm I wasn't missing anything in hardware.

author: NorthGuy
author_rank: Super Contributor
timestamp: May 19, 2024, 12:50:44 pm
content: Quote from: ataradov on May 15, 2024, 01:54:18 pmBut then you will detect suspend as disconnect.