Universal Serial Bus
USB The host schedules the packets
Use USB when a device must connect through a computer’s host stack. Descriptors describe its functions and endpoints, and the host schedules transfers. This adds discovery and software setup, but provides a standard connection beyond a board-level byte link. These examples use USB 2.0 full-speed bulk.

USB wiring, timing and transaction
Wiring
The host PHY and device PHY are connected by two continuous wires, D+ and D−, forming one differential data pair used in either direction. VBUS supplies power from the host to the device body outside the PHY. Ground connects the bodies separately and has no direction.
Each PHY converts packet bits to electrical signaling on D+ and D−, one differential data pair. Host and device take turns transmitting on that same pair; VBUS supplies power through a separate connection.
The PHY is the electrical interface; VBUS and ground connect separately from the continuous D+ / D− pair.
USB transaction
Time flows down. The host starts both IN and OUT transactions.
Host sends IN. The payload will travel device → host.
Timing and model details
USB 2.0 full-speed bulk; 12 Mbit/s is raw signaling, not payload throughput. D+ and D− form one shared differential pair. The fixture begins with DATA0 expected. Packet encoding, error retries, enumeration and setup traffic are omitted. NAK does not advance the data toggle. Low-speed USB has no bulk transfers. Packet spacing is not a duration scale.
The host configures the device first
Plugging in a cable does not immediately create a data stream. Enumeration lets the host discover what the device offers.
An endpoint is a numbered data channel. Its type determines scheduling and delivery behavior; the lab follows a configured bulk endpoint.
USB packets and UART frames differ
USB addresses device endpoints and defines transactions and transfer types. UART frames bytes; an application defines how those bytes form messages.
The successful bulk handshake above is one USB case. NAK, errors, and other transfer types follow different paths.
Explore UART byte framing →Follow a transaction
Advance here or in the transfer above. The highlighted operation and wire state stay on the same step.
send_token(IN, address, endpoint)
reply = receive_packet()
if reply == NAK:
return DEFER
accept_data_and_toggle(reply)
send_ack()
return ACCEPTED- Who drives
- Host drives the D+/D− pair; device listens
- Sent so far
- IN token
- Response so far
- Device has not replied yet
Bulk transaction in progress
Why this step mattersStep 1 of 3, IN token. The host schedules IN; the token selects both the device and its endpoint.
Implementation notes
This pseudocode expands host-controller packet handling; application firmware normally submits a USB transfer to a stack. The device is already configured, the expected PID starts at DATA0, and CRC is valid. The receiver advances its expectation when it accepts the expected DATA; the transmitter advances only after receiving ACK. NAK is temporary backpressure, not a hard failure. Bound the overall request by a deadline or cancellation policy. Real stacks also handle STALL, timeouts, retry rules, and duplicate data packets.
Common mistakes
Reversing IN and OUT
Both names use the host’s perspective: IN brings payload to the host.
Treating NAK as permanent failure
The endpoint may be temporarily unready; the host can request again.
Applying bulk rules to every endpoint
Other transfer types have different timing and handshake rules. Low-speed USB does not support bulk.
Check enumeration, endpoint type, token direction, payload, and handshake. Test NAK followed by a later retry, and a lost ACK without duplicate application delivery. Electrical compliance needs PHY-level measurements too.
Further details and primary sources
- Enumerate before transferring
- The host discovers and configures a device using control transfers and descriptors. Endpoints then provide defined data paths. An address identifies the device; endpoint number and direction identify the destination within it.
- Follow token, data, handshake
- For bulk OUT, the host sends both the OUT token and data; the device acknowledges accepted data. For bulk IN, a device with nothing ready may return NAK instead of data. There is no ACK after that NAK.
- Retry without delivering twice
- DATA0/DATA1 toggles help the receiver recognize a repeated packet after a lost acknowledgment. Successful progress advances the sequence; NAK does not. Bulk provides retry-based delivery without a guaranteed bandwidth or completion deadline.
Example scope
USB 2.0 full-speed bulk after configuration. Packet fields, CRC, encoding, bit stuffing, hub timing, and electrical compliance are not simulated. USB-C describes connector/power capabilities, not the bulk transaction drawn here; USB 3.x uses additional signaling.
Primary sources
Updated
