WIPIVERSE All articles

USB communications

USB communications refers to the signaling, protocol, and transaction mechanisms by which devices exchange data over the Universal Serial Bus (USB). USB is an industry standard that specifies cables, connectors, and communication protocols used to connect electronic devices such as printers, scanners, keyboards, mice, flash drives, external hard drives, cameras, and monitors to computers. It supports signaling rates ranging from 1.5 Mbit/s (Low Speed) to 80 Gbit/s (USB4 Gen 4), depending on the version of the standard.

Signaling

USB signals are transmitted using differential signaling over a twisted-pair data cable with a characteristic impedance of 90 Ω ± 15%. Electrical conventions vary by operating mode:

  • Low Speed (LS) and Full Speed (FS) use a single data pair, labeled D+ and D−, in half-duplex. Transmitted levels are 0.0–0.3 V for logical low and 2.8–3.6 V for logical high, with unterminated lines.
  • High Speed (HS) uses the same wire pair with different electrical conventions: −10 to 10 mV for low and 360–440 mV for high, with 45 Ω termination to ground (or 90 Ω differential) to match cable impedance.
  • SuperSpeed (SS) adds two additional shielded twisted pairs dedicated to full-duplex operation. Logic levels are defined in terms of voltage transitions rather than absolute levels, varying between ±500 mV in normal mode and ±200–600 mV in low-power mode.
  • SuperSpeed+ (SS+) uses an increased signaling rate (Gen 2×1) and/or the additional lane of the Type-C connector (Gen 1×2 and Gen 2×2).

Signaling rates

Operation mode Signaling rate Introduced in
Low-Speed 1.5 Mbit/s USB 1.0
Full-Speed 12 Mbit/s USB 1.0
High-Speed 480 Mbit/s USB 2.0
USB 3.2 Gen 1×1 5 Gbit/s USB 3.0
USB 3.2 Gen 2×1 10 Gbit/s USB 3.1
USB 3.2 Gen 2×2 20 Gbit/s USB 3.2
USB4 Gen 3×2 40 Gbit/s USB4
USB4 Gen 4×2 80 Gbit/s USB4 Version 2.0

The maximum signaling rate in USB 2.0 is 480 Mbit/s per controller, shared among all attached devices. In practice, including protocol overhead, data rates of about 320 Mbit/s (38 MB/s) are sustainable over a high-speed bulk endpoint. For isochronous devices such as audio streams, bandwidth is constant and reserved exclusively for a given device.

The host controller divides bus time into 1 ms frames at low and full speed, or 125 μs microframes at high speed, during which several transactions may take place.

Line coding

USB data is transmitted by toggling the data lines between the J state and the opposite K state, using NRZI line coding: a 0 bit is transmitted by toggling the lines, and a 1 bit by leaving them unchanged. To ensure sufficient signal transitions for clock recovery, bit stuffing is applied—an extra 0 bit is inserted after any six consecutive 1 bits. The host places 15 kΩ pull-down resistors on each data line; a connected device pulls one line high with a 1.5 kΩ resistor to signal its presence and speed capability.

A special protocol during reset, called chirping, is used to negotiate high-speed mode. Because SuperSpeed and later modes use separate, additional wiring, such bandwidth negotiation is not required for them.

Protocol

During USB communication, data is transmitted as packets. Initially, all packets are sent from the host via the root hub, and possibly additional hubs, to devices; some packets direct a device to send packets in reply. After the synchronization field, packets are made of 8-bit bytes transmitted least-significant bit first. The first byte is a packet identifier (PID), consisting of a 4-bit PID followed by its bitwise complement for error detection.

Packets fall into three basic types:

  • Token packets — PID followed by payload and a five-bit CRC; sent only by the host. These include IN and OUT (containing a seven-bit device number and four-bit endpoint number), SETUP (for initial device setup), SOF (start of frame, sent every millisecond), and, since USB 2.0, PING and SPLIT.
  • Data packets — PID followed by 0–1,024 bytes of payload and a 16-bit CRC. Forms include DATA0 and DATA1, which provide the 1-bit sequence number required by stop-and-wait ARQ, and (since USB 2.0) DATA2 and MDATA for high-bandwidth isochronous transfers.
  • Handshake packets — a single PID byte. The basic types are ACK (data successfully received), NAK (data cannot be received and should be retried), and STALL (device error condition). USB 2.0 added NYET and ERR.

A PRE packet tells hubs to temporarily switch to low-speed mode, allowing a hub to support low-bandwidth devices mixed with higher-speed devices without misinterpretation of signals.

Transactions

Packets are organized into transactions consisting of a token packet, a conditional data packet, and a handshake packet:

  • OUT transaction — the host directs a device to receive a data packet, and the device acknowledges it.
  • IN transaction — the host requests data from a device's endpoint buffer, and the device responds with data.
  • SETUP transaction — transfers an 8-byte setup packet (encoding direction, request, and length) to the device; used for device enumeration and connection management.

Control transfer exchange

A control transfer exchange consists of three distinct stages:

  1. Setup stage — a SETUP token, a DATA packet containing the setup packet structure, and a handshake from the device.
  2. Data stage (optional) — carries information to or from the device; may consist of multiple transactions, terminated by a zero-length packet, a short packet, or transmission of the exact length specified by the wLength field.
  3. Status stage — a zero-length transaction of opposite direction to the data stage, indicating completion of the transfer and checking that it completed without error.

This mechanism allows the host to enumerate new USB devices by retrieving their descriptors, which determine the USB Class, VID, and PID used to select the correct driver, and to set a device's address.

See also

  • USB
  • USB hardware
  • USB hub
  • USB communications on Wikipedia
Browse

More topics to explore

    Browse all articles