An4879 Introduction To Usb Hardware and PCB Guidelines Using Stm32 Mcus Stmicroelectronics
An4879 Introduction To Usb Hardware and PCB Guidelines Using Stm32 Mcus Stmicroelectronics
Application note
Introduction
STM32 microcontrollers include a group of products embedding a USB (universal serial bus) peripheral (see the table below
for applicable products). Full-speed and high-speed operations are provided through embedded and/or external PHYs (physical
layers of the open system interconnection model).
This application note gives an overview of the USB peripherals implemented on STM32 MCUs. It also provides hardware
guidelines for PCB design, to ensure electrical compliance with the USB standards.
For more details, refer to the USB or OTG sections in the product reference manual.
1 General information
This document applies to STM32 microcontrollers which are based on Arm® cores.
Note: Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
Acronym Description
References
• System Level ESD-expanded, JEDEC, September 2013.
• Improve System ESD Protection While Lowering On-Chip ESD Protection, www.mobiledevdesign.com,
February 2009.
• USB 2.0 specification, revision 2.0, April 2000, available at www.usb.org.
• On The Go and Embedded Host Supplement to the USB revision 2.0 specification, revision 2.0, July 2012
available at www.usb.org.
• High Speed USB Platform Design Guidelines, available at www.usb.org.
Each device with USB support embeds at least one of the following interfaces:
• A: USB 2.0 FS device interface
• B: USB 2.0 OTG_FS, that is, USB 2.0 FS device/host/OTG controller with on-chip FS PHY
• C: USB 2.0 OTG_HS, that is, USB 2.0 FS/HS device/host/OTG controller, integrating the transceivers for
full-speed operation, and featuring an ULPI for high-speed operation: an external PHY device connected to
the ULPI is required.
• D: USB 2.0 OTG_HS controller with embedded on-chip HS PHYs
• E: USB 2.0 FS host/device interface
The table below lists the STM32 devices supporting a USB, and describes which USB peripheral is implemented
in each of them.
STM32F446 line,
- X - - - 1.25 Kbytes Yes Yes
STM32F469/479
line,
STM32F412 line,
- - X - - 4 Kbytes Yes Yes
STM32F413/423 line
1. X: supported.
2. To be compliant with the USB 2.0 full-speed electrical specification, the USB_DP (D+) pin must be pulled up to a voltage in the 3.0 to 3.6 V
range with a 1.5 kΩ resistor.
3. STM32F401/411/412/413/423 devices support only FS mode.
4. USB 2.0 OTG_HS device/host/OTG peripheral, supporting only full-speed operations.
5. Available through VDD50USB and VDD33USB pins.
USB 2.0 FS device interface USB OTG_FS USB 2.0 FS device interface
Crystal-less USB - X - - -
1. X: supported.
2. Bidirectional, including EP0.
3. When the CAN peripheral is used, only the first 768 bytes are available to the USB. The last 256 bytes are used by the CAN.
4. The USB and CAN share a dedicated 512 bytes SRAM. They can then be used in the same application but not at the same time.
5. The dedicated SRAM is used exclusively by the USB endpoints (not shared with any other peripheral).
STM32F2x5 STM32F446
STM32F2x7 STM32F469
STM32F405 STM32F479
STM32F415 STM32F74x STM32H503
STM32F412 STM32H743
STM32F401 STM32F407 STM32F756 STM32F7x3 STM32H563
STM32F413 STM32H753
STM32F411 STM32F417 STM32F76x STM32F730Z/I STM32H573
Feature(1) STM32F423 STM32H750
STM32F427 STM32F77x STM32H562
STM32F437 STM32F7x2
STM32F429 STM32F730R/V
STM32F439 STM32F750
USB 2.0 FS
OTG_FS OTG_HS OTG_FS OTG_HS OTG_FS OTG_HS OTG_FS OTG_HS OTG_FS OTG_HS OTG_FS OTG_HS host/device
interface
Crystal-less USB - - - - - - - - - - X X -
Bidirectional endpoints
4 - 4 6 6 - 6 9 6 9 9 9 8
(including EP0)
Host mode channels 8 - 8 12 12 - 12 16 12 16 16 16 12
Size of dedicated
packet buffer SRAM 1.25 - 1.25 4 1.25 - 1.25 4 1.25 4 4 4 2
(Kbytes)(2)
ULPI available to
primary I/Os via - - - X - - - X - - - X -
multiplexing
Integrated PHY FS(3) - FS(3) FS(3) FS(3) - FS(3) FS(3) FS(3) HS(4) FS(3) FS(3) -
LPM - - - - X - X X X X X X X
1. X: supported.
2. The dedicated SRAM is used exclusively by the USB endpoints (not shared with any other peripheral).
3. Internal FS OTG PHY support.
4. Internal HS OTG PHY support.
AN4879
page 7/26
Table 6. USB implementation on STM32 ultra-low-power products
AN4879 - Rev 6
STM32L4x5
STM32U59x
STM32L0x2 STM32L4x2 STM32L4x6 STM32U575 STM32U535
STM32L1xx STM32U5Ax
STM32L0x3 STM32L4x3 STM32L4Rx STM32U585 STM32U545
Feature(1) STM32U5Gx
STM32L4Sx
pull up resistor on
X X X X X
USB_DP line
LPM X X X X X
BCD X X X X X
ADP - X - - -
1. X: supported.
2. Except for STM32L47x/L48x devices.
3. The dedicated SRAM is used exclusively by the USB endpoints (not shared with any other peripheral).
Host X X
Device X -
1. X: supported.
In Host mode, the USB OTG_HS supports high-, full-, and low-speed transfers, while in device mode, it only
supports high- and full-speed transfers.
Host X X X
Device X X -
1. X: supported.
Ipsmax
Ipa
Ips Ir Current through a shorting wire
90% Ips
10% Ips
0
tmax 40 ns
tr 50 nanoseconds
5 nanoseconds per division ta
per division
The system must also comply with the IEC 61000-4-2 standard on USB lines when they are connected to a
receptacle. This standard is fairly different from the HBM standard. Refer to the image and the table below for IEC
61000-4-2 standard test waveform and class levels.
Contact Air
Level Peak current (A)
Indicated voltage (kV)
1 2 3 7.5
2 4 4 15
3 6 8 22.5
4 8 15 30
To see the difference between the current pulses applied in the two tests, compare the two figures presented
above.
To improve the protection against high ESD surges (and then to meet the conditions requested by the standards),
dedicated components have to be placed as close as possible to the receptacle (see the table below).
Protection
Interface
Low price Low area on PCB
USBLC6-2SC6 USBLC6-2P6
USB FS
(+ ESDA7P60-1U1M for VBUS) (+ ESDA7P60-1U1M for VBUS)
USB FS OTG USBLC6-4SC6 DSILC6-4P6
USB HS ECMF02-2AMX6 (+ ESDA7P60-1U1M for 5 V VBUS)
USB HS OTG ECMF02 ECMF02-2AMX6 (+ ESDA7P60-1U1M for 5 V VBUS + ESDALC6V1-1U2 for ID)
2.4 Clock
The FS USB device/OTG requires a precise 48 MHz clock. This frequency can be generated from the internal
main PLL, or by the internal 48 MHz oscillator.
In the first case, the clock source must use an HSE crystal oscillator, in the second case, the synchronization for
the oscillator can be taken from:
• The USB data stream itself (SOF signalization), no external resonator/ crystal is needed (this feature is
only available for devices embedding a crystal-less USB 2.0 FS device interface), or
• The internal 48 MHz oscillator trimmed on LSE (not accurate enough for a USB host).
• MSI and LSE only for STM32L47x/L48x devices.
If HS operation is required, the OTG PHY is connected to the microcontroller ULPI port through 12 signals. It can
be clocked using the 60 MHz output (provided from the HS PHY: HSE is not mandatory in this case).
As stated on the following figure, for STM32F7x3xx devices the USB HS PHY includes two embedded PLLs:
• PLL1: has as clock source the HSE clock. The supported values are: 12, 12.5, 16, 24 and 25 MHz. The
PLL1 outputs the 60 MHz used as input for the PLL2.
• PLL2: outputs the high speed (480 MHz) clock.
Note: The AHB frequency has to be higher than 14.2 MHz to guarantee a correct operation for the USB OTG_FS
peripheral, and higher than 30 MHz for the USB OTG_HS peripheral.
2.5 Power
For USB transceivers, the operating voltage ranges between 3.0 and 3.6 V. This voltage is obtained from one of
the following:
• VDD: standard external power supply for the STM32MCU I/Os
• VDDUSB: a dedicated independent power supply for USB. This power supply can be connected either to
VDD or to an external independent power supply for USB transceivers.
Consequently, the microcontroller can be powered with the minimum specified supply voltage, while an
independent power supply 3.3 V can be connected to VDDUSB.
When the VDDUSB is connected to a separated power supply, it is independent from VDD or VDDA, but it must be
the last supply to be provided and the first to be removed.
Some important points to notice are listed below:
• The USB full-speed transceiver functionality is ensured down to 2.7 V. The USB full-speed electrical
characteristics are degraded when VDD ranges between 2.7 and 3.0 V
• VDDUSB is not available on all STM32 devices. Refer to the "Dedicated VDDUSB" column in Table 3. USB
implementation in STM32 devices to check whether this feature is available on a specific MCU.
• The VDDUSB pin must be connected to two external decoupling capacitors (100 nF ceramic + 1 μF tantalum
or ceramic)
• Some devices, when in high-pin-count packages, feature a dedicated VDDUSB pin. When assembled in
low‑pin‑count packages, these devices have only the VDD pin to ensure the USB functionality.
• On STM32F7x3xx devices, the USB HS PHY subsystem uses an additional power supply pin:
VDD12OTGHS pin is the output of the HS PHY regulator (1.2 V). An external capacitor (2.2 μF) must
be connected to the VDD12OTGHS pin.
• On STM32H7x3 devices, VDD50USB can be supplied through the USB cable to generate the VDD33USB via a
USB internal regulator. This is used to support a VDD supply different from 3.3 V. The USB regulator can be
bypassed to supply VDD33USB directly when VDD = 3.3 V.
This section describes the hardware requirements for correct operation of the USB peripheral.
Figure 4. USB FS upstream port with embedded pull-up resistor in self-powered applications
3.3 V
STM32 USB Type-B
Power
connector
VBUS
R1
GPIO
R2
DM DM
DP DP
OSC_IN
OSC_OUT
Figure 5. USB FS upstream port without embedded pull-up resistor in self-powered applications
3.3 V
STM32 USB Type-B
Power
connector
VBUS
R1
GPIO
R2
DM DM
DP DP
1.5 kΩ ± 1%
3.3 V
GPIO
OSC_IN
DT61121V2
OSC_OUT
A DP pull-up must be connected only when VBUS is plugged. A GPIO from the MCU is used to drive it after the
VBUS detection.
Figure 6. USB FS upstream port with embedded pull-up resistor in bus-powered applications
3.3 V
STM32 USB Type-B
connector
5 V to VDD/VDDUSB
Power VBUS
voltage regulator
DM DM
DP DP
OSC_IN
OSC_OUT
Figure 7. USB FS upstream port without embedded pull-up resistor in bus-powered applications
3.3 V
STM32 USB Type-B
connector
5 V to VDD/VDDUSB
Power VBUS
voltage regulator
1.5 kΩ ± 1%
DM DM
DP DP
OSC_IN
GND
OSC_OUT shield
3.3 V
STM32 USB Type-A
connector
Power
EN 5 V power supply
GPIO Current limiter power switch VBUS
GPIO + IRQ
Overcurrent
DM DM
DP DP
OSC_IN
OSC_OUT
R2 R1
DM DM
DP DP
ID ID
OSC_IN
OSC_OUT
Additional considerations:
• An external voltage regulator is only needed when building a VBUS powered device.
• The current limiter is required only if the application has to support a VBUS powered device. A basic power
switch can be used if 5 V supply is available on the application board.
• The ID pin is required in dual role only.
• The same application can be developed using the OTG_HS in FS mode to achieve enhanced performance
thanks to the large Rx/Tx FIFO and to a dedicated DMA controller.
Recommendations:
• Because the ULPI PHY is the master of an ULPI CLK, a crystal oscillator is required to guarantee clock
precision for the ULPI sampling and for the USB HS data sampling.
• The OTG specification requires a capacitor (maximum value 4.7 μF) on VBUS.
• The ESD protection chip, if used, has to be placed as close as possible to the USB connector.
3.3 V
STM32
Power
Tested on
USB HS PHY
Board MCU
STM3240G-EVAL STM32F407
STM3241G-Eval STM32F417
ISP1705AET
STM3221G-Eval STM32F207
STM3220G-EVAL STM32F217
STM32779I-Eval STM32F777
STM32769I-Eval STM32F769
STM32756G-EVAL STM32F756
STM32746G-Eval STM32F746
USB3300-EZK
STM32479I-Eval STM32F479
STM32F446E-Eval STM32F446
STM32F439I-Eval STM32F439
STM32F429I-Eval STM32F429
STM32H753I-EVAL STM32H753
STM32H743I-EVAL STM32H743
USB3320C-EZK
STM32F769I-DISCO STM32F769
STM32F746G-DISCO STM32F746
Q: The datasheet says that the USB transceiver functionality is ensured down to 2.7 V, but the full-speed
electrical characteristics are degraded in 2.7 to 3.0 V voltage range. What is the meaning of this sentence?
A: When the USB operating voltage is below 3.0 V, STMicroelectronics guarantees that the PLL generates
correctly the 48 MHz, and that the analog transceivers are functional: the USB is correctly operating.
However, the electrical signals are not compliant with the USB2.0 full-speed specification, and, consequently,
some tests needed to get the USB certification (such as the eye diagram test) do not pass. In other words, the
USB is operational, but the customer cannot get the USB certification.
Refer to www.usb.org for more details about the electrical requirements needed to be compliant with the USB
specification.
Q: The pull-up resistor on a D+ line must always be added for the STM32 acting as a full speed device?
A: A full-speed device uses a pull-up resistor attached to D+ to specify itself as a full-speed device (and to
indicate its speed). The pull-up resistor at the device end is also used by the host or hub to detect the presence of
a device connected to its port. Without a pull-up resistor, the USB assumes that there is nothing connected to the
bus.
On some STM32 microcontrollers, the pull-up resistor is already embedded. Otherwise, the customer needs to
add it. Refer to Embedded pull-up resistor on USB_DP line in Table 3 to know if this resistor is integrated on the
used STM32 MCU.
Q: In order to manage the VBUS sensing for USB device, are there any recommendations for the resistor bridge
values?
A: Resistor bridge values must be chosen with respect to the following conditions:
• Voltage must be lower than 4 V.
• Voltage must be higher than 0.7×VDD.
• A 200 μA typical current consumption is tolerated.
Refer to "Management of VBUS sensing for USB device design" shared on http://community.st.com.
Q: Can the external clock source (HSE bypass mode) be used for the USB clock source?
A: Yes, this is possible. HSE ON with an external crystal or HSE in bypass mode are required, but HSI cannot be
used.
Q: Can we use two USB ports simultaneously (when they are available)?
A: Yes, this is feasible.
Q: Is it possible to connect more than one device to the same USB port configured as a host?
A: No, hub operation is not supported.
Q: According to the USB specification (FS driver characteristics), when the full-speed driver is/is not part of a
high‑speed capable transceiver, the impedance of each of the drivers must be in the range 40.5 to 49.5 Ω/28 to
44 Ω, respectively. Are the STM32 devices embedding these matching resistors?
A: Yes. On the internal USB PHYs, the matching output impedance is already embedded in the pad transceiver
and is in line with the USB specification. No external resistors are needed.
Q: Is it possible to use the USB peripheral when the operating voltage VDD on the MCU is below 2.7 V?
A: This is possible only if a VDDUSB pin is available to power the USB block. In this case, the microcontroller
can be powered with the minimum specified supply voltage, while an independent 3.3 V power supply can be
connected to VDDUSB.
5 Conclusion
This application note helps STM32 MCUs users to correctly design their USB applications.
All aspects described inside this document, and specifically the requirements described in Section 3, are
mandatory for correct operation of the USB peripheral on STM32 MCUs, and for ensuring its electrical compliance
with the USB standard.
Revision history
Table 14. Document revision history
Contents
1 General information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 USB on STM32 products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1 USB implementation on STM32 products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Supported USB speeds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 Protection against ESD and EMI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Clock. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.5 Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.6 VBUS sensing detection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3 Hardware guidelines for USB implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13
3.1 USB FS upstream port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.1.1 USB FS upstream port in self-powered applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.1.2 USB FS upstream port in bus-powered applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2 USB FS downstream port. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.3 OTG applications through embedded PHY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.4 OTG_HS PHY connected through ULPI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.4.1 External USB HS PHYs compatible via ULPI interface . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.5 USB applications through the embedded OTG_HS PHY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.6 STM32 on USB-IF integrators list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4 FAQs (frequently asked questions). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
List of tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
List of figures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
List of tables
Table 1. Applicable products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Table 2. Abbreviations and acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Table 3. USB implementation in STM32 devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Table 4. USB implementation on STM32 mainstream products. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Table 5. USB implementation on STM32 high-performance products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Table 6. USB implementation on STM32 ultra-low-power products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Table 7. Supported OTG_FS speeds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Table 8. Supported OTG_FS speeds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Table 9. JESD22-A114D standard class levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Table 10. IEC 61000-4-2 standard class levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Table 11. ESD protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Table 12. Compatible USB HS PHY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Table 13. Certified USB peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Table 14. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
List of figures
Figure 1. JESD22-A114D standard test waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 2. IEC 61000-4-2 standard waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 3. HS PHY PLLs on STM32F7x3 devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 4. USB FS upstream port with embedded pull-up resistor in self-powered applications . . . . . . . . . . . . . . . . . . . 13
Figure 5. USB FS upstream port without embedded pull-up resistor in self-powered applications . . . . . . . . . . . . . . . . . 14
Figure 6. USB FS upstream port with embedded pull-up resistor in bus-powered applications . . . . . . . . . . . . . . . . . . . 14
Figure 7. USB FS upstream port without embedded pull-up resistor in bus-powered applications . . . . . . . . . . . . . . . . . 15
Figure 8. USB FS downstream implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Figure 9. OTG schematic implementation (dual-mode) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Figure 10. USB HS via ULPI interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17