Hello,
i couldn't find on any ESP32-S3 documents the position of the USB OTG ID pin on the pinout, is it managed by the USB OTG controller or can i use any pins managing the USB_CONIDSTS bit in the USB_GOTGCTL_REG by firmware?
Any help is appreciated.
Leo
ESP32-S3 USB ID pin
Re: ESP32-S3 USB ID pin
On the ESP32-S3, D- and D+ should be tied to GPIO19 and GPIO20. See section "2.2 Pin Description" of the S3 datasheet for more details.
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: ESP32-S3 USB ID pin
Do you actually need the ID pin? If you simply want to use the chip in host or device mode, it's not needed, you can simply leave it open. If you need it anyway, I think you can route it to any GPIO pin using the GPIO matrix; it doesn't have a dedicated pin.
Re: ESP32-S3 USB ID pin
The esp32-s2/s3 usb phy does not appear to handle the ID and VBUS pins like you'd normally expect from an integrated phy. It seems that most of the control signals of the usb core's phy interface are instead just hooked up to the gpio matrix:
(See e.g. the UTMI+ specification for a description of these signals.)
The outputs are simply ignored and the inputs get muxed to constant-0 or constant-1 by software, which also manually controls the D+/D− pullups via phy registers, see:
Code: Select all
~/.../esp-idf/components$ grep -P 'USB_(OTG|SRP)_' soc/esp32s3/include/soc/gpio_sig_map.h
#define USB_OTG_IDDIG_IN_IDX 58
#define USB_OTG_AVALID_IN_IDX 59
#define USB_SRP_BVALID_IN_IDX 60
#define USB_OTG_IDPULLUP_IDX 60
#define USB_OTG_VBUSVALID_IN_IDX 61
#define USB_OTG_DPPULLDOWN_IDX 61
#define USB_SRP_SESSEND_IN_IDX 62
#define USB_OTG_DMPULLDOWN_IDX 62
#define USB_OTG_DRVVBUS_IDX 63
#define USB_SRP_CHRGVBUS_IDX 64
#define USB_SRP_DISCHRGVBUS_IDX 65
The outputs are simply ignored and the inputs get muxed to constant-0 or constant-1 by software, which also manually controls the D+/D− pullups via phy registers, see:
- esp-idf/components/usb/usb_phy.c
- esp-idf/components/hal/usb_phy_hal.c
- esp-idf/components/hal/esp32s3/include/hal/usb_phy_ll.h
- "The voltage source on the pull-up resistor must be derived from or controlled by the power supplied on the USB cable such that when VBUS is removed, the pull-up resistor does not supply current on the data line to which it is attached."
—USB 2.0 Specification, section 7.1.5 - "No device shall supply (source) current on VBUS at its upstream facing port at any time. From VBUS on its upstream facing port, a device may only draw (sink) current. They may not provide power to the pull-up resistor on D+/D− unless VBUS is present. When VBUS is removed, the device must remove power from the D+/D− pull-up resistor within 10 seconds."
—USB 2.0 Specification, section 7.2.1
-
- Posts: 1
- Joined: Sun Mar 19, 2023 6:33 pm
Re: ESP32-S3 USB ID pin
How do I do that?"The voltage source on the pull-up resistor must be derived from or controlled by the power supplied on the USB cable such that when VBUS is removed, the pull-up resistor does not supply current on the data line to which it is attached."
—USB 2.0 Specification, section 7.1.5
The ESP32-S3 datasheet shows following What should be the values of those registers and capacitors?
For this can I just add a diode like this."No device shall supply (source) current on VBUS at its upstream facing port at any time. From VBUS on its upstream facing port, a device may only draw (sink) current. They may not provide power to the pull-up resistor on D+/D− unless VBUS is present. When VBUS is removed, the device must remove power from the D+/D− pull-up resistor within 10 seconds."
Re: ESP32-S3 USB ID pin
If your device is solely powered via usb then this is automatically satisfied. If your device is (or can be) powered by some means other than via usb then to comply with that requirement you'd need to monitor the usb VBUS voltage and keep the data line pull-ups disabled if VBUS is not present. I don't remember the appropriate threshold voltage, I'd need to look that up.
The data line pull-up/down resistors are integrated in the ESP32 and, like I mentioned in my previous post, controlled by software. Last time I checked (which was a year ago) the usb-phy code in esp-idf didn't implement a mode for usb devices to keep the D+/D- resistors disabled (aka a "soft-disconnect" mode). Maybe that has changed since then, or otherwise it's probably not hard to patch in.
That just looks like placeholders designed in to keep options open for tweaking the pcb if necessary for signal integrity issues. It has nothing to do with the issue I commented about.dejavu1987 wrote: ↑ The ESP32-S3 datasheet shows following
Screenshot 2023-03-19 at 19.31.18.png
What should be the values of those registers and capacitors?
A diode will indeed prevent backfeeding power to USB VBUS (whenever your device is powered via alternate means). Of course do be mindful of the voltage drop across the diode when USB is being used to power your device.
Who is online
Users browsing this forum: No registered users and 179 guests