Author Topic: usb 2.0 FS hardwired device implementation without VBUS sense  (Read 1358 times)

0 Members and 1 Guest are viewing this topic.

Online uer166Topic starter

  • Frequent Contributor
  • **
  • Posts: 927
  • Country: us
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.
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11474
  • Country: us
    • Personal site
Re: usb 2.0 FS hardwired device implementation without VBUS sense
« Reply #1 on: May 14, 2024, 07:59:32 pm »
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.
Alex
 
The following users thanked this post: uer166

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 3780
  • Country: gb
  • Doing electronics since the 1960s...
Re: usb 2.0 FS hardwired device implementation without VBUS sense
« Reply #2 on: May 15, 2024, 06:42:32 am »
IIRC, VBUS sense is handy for detecting a cable disconnect, for various reasons. But if you never disconnect the cable then probably not needed.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11474
  • Country: us
    • Personal site
Re: usb 2.0 FS hardwired device implementation without VBUS sense
« Reply #3 on: May 15, 2024, 01:54:18 pm »
You can detect cable disconnect by the lack of SOF interrupts.
Alex
 

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 3780
  • Country: gb
  • Doing electronics since the 1960s...
Re: usb 2.0 FS hardwired device implementation without VBUS sense
« Reply #4 on: May 15, 2024, 05:18:13 pm »
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=1644317667636
More here
https://community.st.com/s/article/FAQ-Management-of-VBUS-sensing-for-USB-device-design

My 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.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11474
  • Country: us
    • Personal site
Re: usb 2.0 FS hardwired device implementation without VBUS sense
« Reply #5 on: May 15, 2024, 06:40:54 pm »
No, OTG only uses ID pin. VBUS is never necessary.
Alex
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14893
  • Country: fr
Re: usb 2.0 FS hardwired device implementation without VBUS sense
« Reply #6 on: May 15, 2024, 08:53:59 pm »
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.
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11474
  • Country: us
    • Personal site
Re: usb 2.0 FS hardwired device implementation without VBUS sense
« Reply #7 on: May 15, 2024, 09:04:20 pm »
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.
Alex
 

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 3780
  • Country: gb
  • Doing electronics since the 1960s...
Re: usb 2.0 FS hardwired device implementation without VBUS sense
« Reply #8 on: May 15, 2024, 10:13:18 pm »
Quote
VBUS is never necessary

I 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.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Online uer166Topic starter

  • Frequent Contributor
  • **
  • Posts: 927
  • Country: us
Re: usb 2.0 FS hardwired device implementation without VBUS sense
« Reply #9 on: May 15, 2024, 10:55:23 pm »
Quote
VBUS is never necessary

I 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.

I'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.
 
The following users thanked this post: SiliconWizard

Online NorthGuy

  • Super Contributor
  • ***
  • Posts: 3204
  • Country: ca
Re: usb 2.0 FS hardwired device implementation without VBUS sense
« Reply #10 on: May 19, 2024, 12:50:44 pm »
You can detect cable disconnect by the lack of SOF interrupts.

But then you will detect suspend as disconnect.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf