Learn USB Protocol

8.Basic Protocol

Unlike RS-232 and similar serial interfaces where the format of data being sent is not defined, USB is made up of several layers of protocols. While this sounds complicated, don’t give up now. Once you understand what is going on, you really only have to worry about the higher level layers. In fact most USB controller I.C.s will take care of the lower layer, thus making it almost invisible to the end designer.

Each USB transaction consists of a

    • Token Packet (Header defining what it expects to follow), an
    • Optional Data Packet, (Containing the payload) and a
    • Status Packet (Used to acknowledge transactions and to provide a means of error correction)

As we have already discussed, USB is a host centric bus. The host initiates all transactions. The first packet, also called a token is generated by the host to describe what is to follow and whether the data transaction will be a read or write and what the device’s address and designated endpoint is. The next packet is generally a data packet carrying the payload and is followed by an handshaking packet, reporting if the data or token was received successfully, or if the endpoint is stalled or not available to accept data.

The USB protocol is a packet based architecture with start frame, transactions, and handshaking with ack and nak controls. These will be covered later. Within the host there is the USB controller and the root hub. The Host controller formats the data for the OS on read and write as well as manages communications on the bus. The Root Hub provides the connection point to the host for peripheral devices as well as detects attach/removal events, carries out requests from the host and is the means to pass data. USB is a half duplex protocol where all data is passed via a two wire interface called D+ (D plus) and D- (D minus). The host processor is responsible for all communications on the bus
including device addressing and bus bandwidth. It is also responsible for determining and conserving the power requirements for the bus. If devices do not meet the requirements for all of the above conditions then the host can refuse to enumerate. When we discuss data transfer across the USB we always use the vantage point of the host for reference. For example, if there is an IN transfer that means the host is going to receive the data. An OUT transfer means the host is going to transmit data.

Before proceeding let’s quickly discuss the data transfer hierarchy. The term “pipe” is used to define a logical association between the host and the endpoint device and is the connection point for the host software and the device. There are two types of pipes identified in the USB specification. The stream pipe is used for unidirectional communications and comprises most of the transfer types defined. The Message pipe is a bidirectional pipe and is typically used only for control transfers or the transfers that the USB uses for configuring devices and the bus. The control transfer is a transfer using endpoint 0 which is the only bidirectional transfer and therefore a message pipe. There are IN/OUT transfers, however each endpoint is either an IN or an OUT transfer. This is where the unidirectional stream pipes come into play. The transfer is the highest level of the USB protocol and is used to define the structure of the information that is sent across the wires. The transfer is broken up into a set of transactions. These transactions are then subdivided into a set of packets that are the lowest level defined in the USB specification. The following slides build the data from when we plug in the cable all the way up to the transfer format. This will become more evident as we progress through the course.

Suggest Edit


Please enter your comment!
Please enter your name here