« What Is Flash Memory | Home | USB - Error Handling »
USB - Bus Protocol
By admin | April 27, 2007
Information transfers over the bus are called transactions. At any time the host controller may have a list of transactions that are waiting to be actioned. A transaction begins when the controller sends a packet describing the type and direction of the transaction, the 7-bit USB device address and the endpoint number. This packet is called the Token Packet.
The source of the data – either the controller or a device depending on the direction – then sends a Data Packet. In most cases the transaction is completed by the destination of the data sending a Handshake Packet which is either an ACK, indicating the data was accepted, a NAK, indicating that the data was not accepted, or a STALL, which signals that the endpoint is stalled.
Traffic on the USB is regulated using time. The unit of time is the frame. The length of each frame is governed by the bus clock, which runs at a rate of 1KHz, so there are 1,000 frames per second: one per millisecond. At the start of each frame a Start Of Frame (SOF) packet is sent over the bus, allowing isochronous devices to synchronise with the bus.
The concept of frames is central to how the bus shares out bus bandwidth among the various competing devices. The USB designers felt that it would not be possible to support several concurrent isochronous communication flows with fast sample rates using a system where each device must interrupt the host for each sample of data to be transferred. Consequently they designed the system so that isochronous devices are given guaranteed bandwidth by allocating them a proportion of the time in each frame.
At least 10 per cent of every frame is reserved for use by control transfers. This proportion can be increased by the system software if performance is found to be suffering through control packets being unduly delayed. The maximum continuous throughput over USB must therefore be less than 90 per cent of the signalling rate.
Part or all of the remaining time in each frame can be reserved by pipes serving isochronous devices. The actual portion allocated to each pipe is pre-negotiated when the pipe is set up. This ensures that a specific amount of data can be transferred every millisecond. Any bandwidth remaining is available for other types of transfer.
Isochronous devices must buffer data one frame’s worth at a time, and send each block over the bus as a single transaction. At the receiving end the data is unbuffered and restored to real time. For example, an audio device operating at a CD-quality 44.1KHz sampling rate would send nine frames with 44 samples per frame, followed by one frame with 45 samples. After buffering at the source and unbuffering at the destination there will be a delay of a couple of milliseconds in delivering the data, but the rate of delivery – which is what is important to preserve quality – will be preserved.
Interrupt transfers are also to an extent time critical. When a pipe is created for an interrupt endpoint, a desired bus access period of between 1 and 255ms (10 and 255ms in the case of low speed devices) is specified. The system software polls the interrupt endpoint at an interval which ensures that if an interrupt transaction is pending it is dealt with within the desired time-frame.
Source: http://www.tech-pro.net/intro_usb.html
Topics: Computers & Software |
