USB communications


This article provides information about the communications aspects of Universal Serial Bus : Signaling, Protocols, Transactions. USB is an industry-standard used to specify cables, connectors, and protocols that are used for communication between electronic devices. USB ports and cables are used to connect hardware such as printers, scanners, keyboards, mice, flash drives, external hard drives, joysticks, cameras, monitors, and more to computers of all kinds. USB also supports signaling rates from 1.5 Mbit/s to 80 Gbit/s depending on the version of the standard. The article explains how USB devices transmit and receive data using electrical signals over the physical layer, how they identify themselves and negotiate parameters such as speed and power with the host or other devices using standard protocols such as USB Device Framework and USB Power Delivery, and how they exchange data using packets of different types and formats such as token, data, handshake, and special packets.

Signaling (USB PHY)

Signaling rate (transmission rate)

The maximum signaling rate in USB 2.0 is 480 Mbit/s per controller and is shared amongst all attached devices. Some personal computer chipset manufacturers overcome this bottleneck by providing multiple USB 2.0 controllers within the southbridge.
In practice and including USB protocol overhead, data rates of 320 Mbit/s are sustainable over a high-speed bulk endpoint. Throughput can be affected by additional bottlenecks, such as a hard disk drive as seen a in routine testing performed by CNet, where write operations to typical high-speed hard drives sustain rates of 25–30 MB/s, and read operations at 30–42 MB/s; this is 70% of the total available bus bandwidth. For USB 3.0, typical write speed is 70–90 MB/s, while read speed is 90–110 MB/s. Mask tests, also known as eye diagram tests, are used to determine the quality of a signal in the time domain. They are defined in the referenced document as part of the electrical test description for the high speed mode at 480 Mbit/s.
According to a USB-IF chairman, "at least 10 to 15 percent of the stated peak 60 MB/s of Hi-speed USB goes to overhead—the communication protocol between the card and the peripheral. Overhead is a component of all connectivity standards". Tables illustrating the transfer limits are shown in Chapter 5 of the USB spec.
For isochronous devices like audio streams, the bandwidth is constant and reserved exclusively for a given device. The bus bandwidth therefore only has an effect on the number of channels that can be sent at a time, not the speed or latency of the transmission.
  • Low speed rate of 1.5 Mbit/s is defined by USB 1.0. It is very similar to full-bandwidth operation except each bit takes 8 times as long to transmit. It is intended primarily to save cost in low-bandwidth human interface devices such as keyboards, mice, and joysticks.
  • Full speed rate of 12 Mbit/s is the basic USB signaling rate defined by USB 1.0. All USB hubs can operate at this rate.
  • High speed rate of 480 Mbit/s was introduced in 2001 by USB 2.0. High-speed devices must also be capable of falling back to full-speed as well, making high-speed devices backward compatible with USB 1.1 hosts. Connectors are identical for USB 2.0 and USB 1.x.
  • SuperSpeed rate of 5.0 Gbit/s. The written USB 3.0 specification was released by Intel and its partners in August 2008. The first USB 3.0 controller chips were sampled by NEC in May 2009, and the first products using the USB 3.0 specification arrived in January 2010. USB 3.0 connectors are generally backward compatible, but include new wiring and full-duplex operation.
  • SuperSpeed+ rate of 10 Gbit/s is defined by USB 3.1, and 20 Gbit/s using two lanes is defined by USB 3.2.

    Framing

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

Electrical specification

USB signals are transmitted using differential signaling on a twisted-pair data cable with characteristic impedance.
  • Low speed and Full speed modes use a single data pair, labelled D+ and D−, in half-duplex. Transmitted signal levels are for logical low, and for logical high level. The signal lines are not terminated.
  • High speed mode uses the same wire pair, but with different electrical conventions. Lower signal voltages of for low and for logical high level, and termination of 45 Ω to ground or 90 Ω differential to match the data cable impedance.
  • SuperSpeed adds two additional pairs of shielded twisted wire. These are dedicated to full-duplex SuperSpeed operation. The half-duplex lines are still used for configuration.
  • SuperSpeed+ uses increased signaling rate and/or the additional lane in the Type-C connector.
A USB connection is always between a host or hub at the A connector end, and a device or hub's upstream port at the other end.

Signaling state

The host includes 15 kΩ pull-down resistors on each data line. When no device is connected, this pulls both data lines low into the so-called single-ended zero state, and indicates a reset or disconnection.

Line transition state

The following terminology is used to assist in the technical discussion regarding USB PHY signaling.
  • The idle line state is when the device is connected to the host with a pull-up on either D+ or D−, with transmitter output on both host and device is set to high impedance .
  • A USB device pulls one of the data lines high with a 1.5 kΩ resistor. This overpowers one of the 15 kΩ pull-down resistors in the host and leaves the data lines in an idle state called J.
  • For USB 1.x, the choice of data line indicates what signal rates the device is capable of:
  • * full-bandwidth devices pull D+ high,
  • * low-bandwidth devices pull D− high.
  • The K state has opposite polarity to the J state.

    Line state (covering USB 1.x and 2.x)

Transmission

USB data is transmitted by toggling the data lines between the J state and the opposite K state. USB encodes data using the NRZI line coding:
  • 0 bit is transmitted by toggling the data lines from J to K or vice versa.
  • 1 bit is transmitted by leaving the data lines as-is.
To ensure that there are enough signal transitions for clock recovery to occur in the bitstream, a bit stuffing technique is applied to the data stream: an extra 0 bit is inserted into the data stream after any occurrence of six consecutive 1 bits. Seven consecutively received 1 bits are always an error. For USB 3.0, additional data transmission encoding is used to handle the higher signaling rates required.

Transmission example on a full-speed device

; Synchronization Pattern: A USB packet begins with an 8-bit synchronization sequence, 00000001₂. That is, after the initial idle state J, the data lines toggle KJKJKJKK. The final 1 bit marks the end of the sync pattern and the beginning of the USB frame. For high-bandwidth USB, the packet begins with a 32-bit synchronization sequence.
; End of Packet : EOP is indicated by the transmitter driving 2 bit times of SE0 and 1 bit time of J state. After this, the transmitter ceases to drive the D+/D− lines and the aforementioned pull-up resistors hold it in the J state. Sometimes skew due to hubs can add as much as one bit time before the SE0 of the end of packet. This extra bit can also result in a bit stuff violation if the six bits before it in the CRC are 1s. This bit should be ignored by receiver.
; Bus Reset: A USB bus is reset using a prolonged SE0 signal.

High speed negotiation

A special protocol during reset, called chirping, is used to negotiate the high speed mode with a host or hub. A device that is high speed capable first connects as a full speed device, but upon receiving a USB RESET it pulls the D− line high, known as chirp K. This indicates to the host that the device is high bandwidth. If the host/hub is also HS capable, it chirps letting the device know that the hub operates at high bandwidth. The device has to receive at least three sets of KJ chirps before it changes to high speed terminations and begins high speed signaling. Because SuperSpeed and beyond uses wiring that is separate and additional to that used by earlier modes, such bandwidth negotiation is not required.
Clock tolerance is 480.00±0.24 Mbit/s, 12.00±0.03 Mbit/s, and 1.50±0.0225 Mbit/s.

USB 3.0

USB 3 uses tinned copper stranded AWG-28 cables with impedance for its high-speed differential pairs. Electrical signalling uses a linear feedback shift register and 8b/10b encoding with spread spectrum clocking, sent at a nominal 1 Volt with a 100 mV receiver threshold; the receiver uses equalization training. Packet headers are protected with CRC-16, while data payload is protected with CRC-32. Power up to 3.6 W may be used. One unit load in Super Speed mode is equal to 150 mA.

Protocol layer

During USB communication, data is transmitted as packets. Initially, all packets are sent from the host via the root hub, and possibly more hubs, to devices. Some of those packets direct a device to send some packets in reply.
After the sync field, all packets are made of 8-bit bytes, transmitted least-significant bit first. The first byte is a packet identifier byte. The PID is actually 4 bits; the byte consists of the 4-bit PID followed by its bitwise complement. This redundancy helps detect errors.
TypePID value
Transmitted byte
NameDescription
00000000 1111
Token10000001 1110SPLITHigh-bandwidth split transaction
Token01000010 1101PINGCheck if endpoint can accept data
Special11000011 1100PRELow-bandwidth USB preamble
Handshake11000011 1100ERRSplit transaction error
Handshake00100100 1011ACKData packet accepted
Handshake10100101 1010NAKData packet not accepted; please retransmit
Handshake01100110 1001NYETData not ready yet
Handshake11100111 1000STALLTransfer impossible; do error recovery
Token00011000 0111OUTAddress for host-to-device transfer
Token10011001 0110INAddress for device-to-host transfer
Token01011010 0101SOFStart of frame marker
Token11011011 0100SETUPAddress for host-to-device control transfer
Data00111100 0011DATA0Even-numbered data packet
Data10111101 0010DATA1Odd-numbered data packet
Data01111110 0001DATA2Data packet for high-bandwidth isochronous transfer
Data11111111 0000MDATAData packet for high-bandwidth isochronous transfer

Packets come in three basic types, each with a different format and CRC :