USB Basics
Enumeration, endpoints, pipes.
USB (Universal Serial Bus) is the most widely used serial interface standard for connecting peripherals to computers and embedded hosts. It replaced older interfaces like RS-232 and parallel ports by offering hot-plug capability, self-identification of devices, and power delivery over the same cable. Understanding USB enumeration, endpoints, and pipes is fundamental for embedded systems designers and is increasingly tested in advanced GATE and university examinations.
Core Concept: USB Enumeration
USB enumeration is the process by which the host discovers, identifies, and configures a newly connected device. When a USB device is plugged in, the host detects the connection through a voltage change on D+ or D- caused by the device's pull-up resistor. A full-speed device pulls D+ high; a low-speed device pulls D- high. High-speed devices start as full-speed and negotiate higher speed after reset.
The host then issues a USB reset by driving both D+ and D- low for at least 10 ms. After reset, the device is addressed as address 0. The host sends a GET_DESCRIPTOR request to address 0 to read the device descriptor, which reveals the device class, vendor ID, product ID, and maximum packet size for the default control endpoint (EP0). The host then assigns a unique address (1 to 127) and continues reading configuration and interface descriptors.
Once enumeration is complete, the host loads the appropriate device driver based on the class code. From this point, communication uses the endpoints described in the endpoint descriptors. All USB communication is host-initiated; the device can never send data unless the host first requests it.
Endpoints and Pipes
An endpoint is a logical data buffer inside the USB device, identified by an endpoint number and a direction (IN for device-to-host, OUT for host-to-device). Endpoint 0 is always the default control endpoint used during enumeration and for control transfers throughout the device lifetime. All devices must implement EP0.
A pipe is the logical association between a host-side software buffer and a device endpoint. There are two types of pipes: stream pipes (for bulk, isochronous, and interrupt transfers) and message pipes (for control transfers through EP0). The four USB transfer types are Control, Bulk, Interrupt, and Isochronous. Control transfers handle configuration commands. Bulk transfers move large data volumes without timing guarantees (used for mass storage). Interrupt transfers poll at a fixed interval for small data like keyboard keystrokes. Isochronous transfers provide guaranteed bandwidth with no error correction, used for audio and video streaming.
Mathematical Expression: USB Bandwidth
The maximum theoretical data rate of USB is defined by its version: USB 1.1 Full Speed is 12 Mbps, USB 2.0 High Speed is 480 Mbps, USB 3.0 is 5 Gbps. In practice, protocol overhead reduces effective throughput. For USB 2.0 High Speed bulk transfers, the efficiency is approximately 53% due to packet headers, handshake packets, and SOF (Start of Frame) tokens consuming bandwidth.
The maximum data payload per bulk transaction at High Speed is 512 bytes. The number of transactions per second at 480 Mbps can be estimated by dividing the bus bandwidth by the bits per transaction.
Given:
USB 2.0 High Speed bus rate = 480 Mbps
Bulk packet payload = 512 bytes = 512 x 8 = 4096 bits
Overhead per transaction = approximately 20 bytes = 160 bits
Total bits per transaction = 4096 + 160 = 4256 bits
Why this formula applies:
Effective throughput requires accounting for protocol overhead beyond raw bus speed.
Formula:
Max transactions/sec = Bus Rate / Total bits per transaction
Effective throughput = Max transactions/sec x Payload bits
Substitution:
Max transactions/sec = 480,000,000 / 4256 = 112,782 transactions/sec
Effective throughput = 112,782 x 4096 bits/sec
Calculation:
Effective throughput = 461,920,000 bits/sec
Final Answer: Effective USB 2.0 bulk throughput ≈ 462 Mbps (approximately 96% of theoretical 480 Mbps at ideal conditions)Exam Tip: Remember that USB is always host-centric. The host initiates all transactions. A device cannot spontaneously send data. Isochronous endpoints have no ACK handshake, meaning errors are not retransmitted, which makes them suitable for real-time audio/video where latency matters more than perfect accuracy.
- Control transfers use EP0 and are bidirectional. They carry setup packets for enumeration and class-specific commands throughout device lifetime.
- Bulk transfers guarantee data integrity via error detection and retry but offer no timing guarantees. Bandwidth is used only when bus is free.
- Interrupt transfers poll the device at a declared interval (1 ms to 255 ms). Despite the name, the device does not actually interrupt the host; the host polls.
- Isochronous transfers reserve guaranteed bandwidth each frame (every 1 ms) but have no ACK or retry, accepting occasional data loss for real-time streaming.
- Each endpoint in a device has a dedicated FIFO buffer. The host alternates between IN tokens (requesting data) and OUT tokens (sending data) based on the pipe direction.
Quick Revision
- USB uses a tiered star topology: host at center, up to 5 levels of hubs, up to 127 devices per bus.
- Enumeration assigns a unique address (1-127) and discovers descriptors (device, configuration, interface, endpoint).
- Endpoint 0 (EP0) is mandatory and always used for control transfers.
- Four transfer types: Control (configuration), Bulk (mass storage), Interrupt (HID), Isochronous (audio/video).
- Full Speed D+ pulled high by device. Low Speed D- pulled high. High Speed negotiated after reset.
- USB speeds: Low Speed 1.5 Mbps, Full Speed 12 Mbps, High Speed 480 Mbps, SuperSpeed 5 Gbps.
- Common trap: Isochronous transfers have no handshake (no ACK), so data errors are never retransmitted.
USB Basics Quiz
Test your grasp of USB enumeration, endpoints, and transfer types.
Q1.During USB enumeration, which request does the host send first to a newly connected device before assigning it an address?
Related Articles
UART
Asynchronous serial protocol, baud rate, framing.
9 min read
SPI
Synchronous serial, master-slave, clock polarity/phase.
9 min read
I2C
Two-wire interface, addressing, acknowledgement.
10 min read
Embedded Systems Overview
Definition, constraints, design metrics.
9 min read
Inter-Task Communication
Queues, Semaphores, Mutexes.
8 min read