USB (Universal Serial Bus) has a lot of advantages in comparison to ISA and PCI buses:
- Add-in slots are limited on internal PC buses while USB allows up to 127 devices.
- Add-ins require opening PC, inviting new problems while USB has standard external connector.
- External peripheral connectors (printer,keyboard,mouse,etc.) vary, while USB has one type of connection.
- USB connector has just 4 signals - cost saving on board design and cables. For example parallel port uses 25 pins connector.
- Peripheral interrupts are limited - sharing required. USB is using polling mechanizm instead.
- USB has power line. Peripherals can be powered directly from USB cable in the range of 100 - 500mA.
- USB supports hot auto configuration while PCI devices can only get identified during boot time.
- USB supports data rates upto 12Mb/s (USB1 standard), newer USB2 standard extends it to 480 Mb/s.
1 - VCC=5V
2 - Data-
3 - Data+
4 - Gnd
USB bus is controlled by USB Host Controller (HC). Basically, HC is a set of registers residing on the PCI bus address space plus
some control logic.
Low speed devices support data rate 1.5Mb/s maximum (mouse,keyboard,game controller).
Full speed devices - upto 12Mb/s (audio devices),
high speed - 480Mb/s (video devices).
What is Hub? Hub provides extra USB extensions for attaching more USB devices.
Hub contains two major functional elements: hub controller and repeater.
The diagram below illustrates their operation.
So how can USB devices communicate with HC using just a pair of Data lines?
USB protocol is similar to networking. Data blocks in USB called transfer descriptors (TD) and
support the same communication model: token/data/handshake.
Token packet contains address and control information :
The selected USB device decodes it's address. Then the data is transferred either from host to device or
from device to the host. The direction is indicated in the token packet. The destination device, in general,
responds with a handshake packet, indicating whether the transfer was succesful.
- Address of the target USB device
- Read or Write transaction
- Size of the data packet
- Speed of transaction
- Location of the client's memory buffer
To ensure that all devices residing on USB bus get their share of the bus bandwidth , all USB transactions are groupped into timing
intervals - frames.
Frame is 1ms long for 12Mb/s rate and 0.125ms for 480Mb/s rate. Each USB device can use the bus
during the frame.
Here is an example of a frame.
A software (USB driver) builds frames depending on configuration and how many USB devices are attached.
A frame starts with a sequence of bits "SOF". Then TDs for particular devices follow. As you noticed, a frame also contains
some bus control information, such as polling if any new USB device attached .
Note that some devices such as USB digital speakers require bus access every frame, while others may require
use of the bus on a periodic basis (USB keyboard). Bulk transfers (large blocks of data to/from printer or scanner)
simply get the bandwidth that is left over after all of the currently scheduled transactions complete.
So far TDs are located in the main memory as a linked lists. HC is fetching and executing TDs every
1 mS, or 125 uS.
As we mentioned before, all USB devices are attached to hub ports. Hub has status bits that are used to report
the attachment or removal of a USB device to one of it's ports. The host queries the hub to retrieve these bits.
Then the host assigns a unique address to the device and send it to system software.
Now look at the drawing showing the interface between HUB and an attached device.
The pull-down resistors on the D+ and D- lines ensure that both data lines are near ground.
When no device is attached, the HUB's receiver detects an electrical low on both data lines.
USB devices have a pull-up resistor on either D+ or D- (depending on it's speed) to enable
Hubs may deliver all power from the upstream cable or may include their own power supply for powering
downstream ports. The current draw is programmable in the range of 100mA ... 500mA.
USB is a polled bus, no interrupts are present. Basically it means that if USB device has some
information to pass to HC, it has to wait till HC polles it.
- PC Platform Mindshare class (June 2001)
- Understanding PCI-Bus subtleties optimizes system performance, Paul Schreier,EE Feb 2000
- Quenching processor thirst , Patrick Gelsinger, Electronics World, May 2001
- USB architecture, www.usb.org