USB Packet Identifiers- Explained

USB



In this article, we explain what USB packet identifiers (PIDs) are and how they are used.

So USB data exchange between host and device occurs with USB transactions.

Each USB transaction is composed of either 2 or 3 packets, depending on the transfer type being used.

There are 4 possible packets that comprise a USB transaction.

These packets are the token packet, the data packet, the handshake packet, and the setup (or special) packet.

Each packet is responsible for transmitting data.

This data communicates with the host or the device what needs to be setup, or executed, or exchanged.

The token packet is the first packet in a USB transaction. It is responsible for the initialization process for the USB transaction. For example, the token packet determines whether the USB transaction will be outputting data from the host to the device or whether the host will be receiving data from the device.

The data packet is the second packet in a USB transaction. It is responsible for transmitting data. It is the actual data that is being transferred either from the host to the device or the device to the host, which again was determined in the token packet which way data will be transferred.

The handshake packet is the third packet in a USB transaction. In certain isosynchronous USB transfer type, this packet isn't part of the USB transaction, so it is absense. The isosynchronous USB transfer type only has 2 packets in a USB transaction. However, in all other transfer types, there is a handshake packet. This packet is responsible for error checking. If all is fine with the transfer, an ACK packet is sent from the receiving device to the transmitting device. If the data isn't received, then an NAK may be sent, giving evidence that the data was not received (this is for certain package types). If there is some error in the data process, then a STALL may be sent (again for certain package types).

The special packet is present when the control transfer type is being used. This helps to initialize the USB transaction when the USB is operating in control transfer type. This packet also has its unique packet identifiers that help to initialize the USB transfer.

Below is the table showing the USB Packet Identifiers (PIDs).


USB packet identifiers (PIDs)


Each packet identifier is represented by a 4-bit binary number.

You can see that for the token packet if we want the host to send data to the device, then we specify a value of 0b0001 in the token packet. If we want the host to receive data from the device, then we specify a value of 0b1001 in the token packet.

Receiving a value of 0b0010 in the handshake packet means that the data was received (this is an ACK value). Meanwhile receiving a value of 0b1110 means that there was an error (this is a STALL value).

Please note that in the image above, the packet identifiers highlighted in red are only used during high speed USB transactions.

So this was a brief summary of USB packet identifiers, and how they are used to give important information to packets during USB transactions.

You will need to use these values when programming USB transactions in embedded software applications.



Related Resources





HTML Comment Box is loading comments...