Universal serial bus. USB bus organization USB bus description


USB 1.1 and 2.0 standards

The Universal Serial Bus is another serial interface. Since this is the most popular serial interface, it deserves its own chapter.

The USB bus allows daisy-chaining of up to 127 devices (you can connect device to device if the device manufacturer provides this feature). As with IEEE, hot plugging/plugging of devices is supported, meaning you don't have to turn off the computer's power to plug/unplug a device. Moreover, as in the case of IEEE, devices can be powered via the USB bus, which eliminates the need for additional power supplies.

The USB bus appeared in January 1996 - then USB 1.0 was announced. Two years later, in 1998, USB 1.1 appeared. Almost all devices version 1.0 are compatible with USB 1.1, and vice versa - there were just minor changes.

USB 2.0 appeared in 2003. It is backwards compatible with versions 1.0 and 1.1. This means that devices of version 1.0 and 1.1 can be connected to the USB 2.0 bus. It is very easy to determine the device version - by the USB logo. In Fig. 10.1 shows the logo of USB versions 1.0 and 1.1 (device version 1.1 is now more common), and in Fig. 10.2 – USB 2.0 logo.

Rice. 10.1. USB 1.1 logo: old (left) and new (right)

Rice. 10.2. USB 2.0 logo

Technical characteristics of the USB 1.1 bus are given in table. 10.1.
//-- Table 10.1. USB1.1 bus specifications --//


Please note that the USB 1.1 bus can operate in two modes: low-speed and high-speed. In the first, the exchange speed is 1.5 Mbit/s, in the second – 12 Mbit/s.
The technical characteristics of the USB 2.0 bus are almost the same, but USB 2.0 has three speed modes:
Low-speed (speed 10–1500 Kbps) – for input devices (keyboard, mouse, joysticks);
Full-speed (0.5–12 Mbit/s) – various medium-speed devices;
Hi-speed (5–480 Mbit/s) – data storage media, video devices.

Connecting USB devices

On the back wall of the system unit you can usually find four USB ports (sometimes 6 or even 8). These ports (Fig. 10.3) belong to USB root hubs. Each root hub has two USB ports. Therefore, if you have four USB ports on the motherboard, then there are two root hubs in the system; if there are eight ports, there are four root hubs in the system.

//-- Rice. 10.3. USB ports --//
Open Device Manager (to do this, go to Start, Settings, Control Panel, System, go to the Hardware tab and click Device Manager). In the Device Manager window, expand the Universal Serial Bus Controllers group (Fig. 10.4).

//-- Rice. 10.4. Device Manager --//
Right-click any root hub and select Properties. In the window that appears, go to the Power tab. You will see the following information (Fig. 10.5):
hub power type – our hub is root, so it has its own power supply;
information about the devices connected to the hub ports and their power supply - in our case, one device is connected and it requires a power supply of 100 mA. At most, our hub can deliver up to 500 mA per port;
number of free ports - the root hub has only two ports, one of them is occupied (a storage device is connected - a USB drive), so one port is free.

//-- Rice. 10.5. Detailed information about the hub --//
If you only have two hubs and you can only connect two devices to each, then how on earth can you connect up to 127 USB devices to your computer? First, you can connect additional USB hubs to the root hub ports (Figure 10.6). A USB hub plugs into a USB port, but in return provides at least three free USB ports. There are two types of USB hubs: self-powered and parent-powered. It is better to buy hubs with their own power supply. Why? As we know, a maximum current of 500 mA is transmitted to one port; 100 mA will be required to power the hub itself, leaving 400 mA for the devices. It turns out that you will no longer be able to connect any powerful USB device to each port of such a hub, but you will be able to connect devices like USB drives that only need 100 mA.

//-- Rice. 10.6. USB hub --//
If the hub has its own power supply, then it will be possible to provide 500 mA for each port, that is, the USB ports will be full-fledged, like on root hubs.
In addition, some devices, such as a keyboard, can act as a USB hub (these devices must be USB devices). You plug the keyboard into a USB port, and you can connect several other devices to it. Typically, USB mice and sometimes USB drives are connected to the keyboard. It is clear that these devices should not be “gluttonous”, since only 500 mA is supplied to the port; 100 mA goes to power the keyboard, and the rest is divided between devices connected to the keyboard. Given this hierarchical connection of devices, it is easy to imagine a total of 127 devices connected to the computer. This is not 63,000, as is the case with IEEE-1394!
Now about the USB connectors. The connectors available on the back wall of the system unit (the most common USB connectors) are called USB type A. The cable for the type A connector is shown in Fig. 10.7.

//-- Rice. 10.7. Type A cable --//
The Type B connector and cable are shown in Fig. 10.8. Typically, the Type B connector is used on peripheral devices (printers, scanners). The USB cable for connecting a peripheral device to a computer (Fig. 10.9) is equipped with a type B connector (for connecting to a printer/scanner) and a type A connector (for connecting to a computer).

//-- Rice. 10.8. Type B connector and cable --//
//-- Rice. 10.9. Cable for connecting a USB printer --//
In addition to type A and B connectors, there is also a mini-connector, which is called mini-USB (Fig. 10.10). It is usually used to connect the USB cable to digital camera, mobile phone. In this case, one end of the cable is mini-USB, and the other is type A.

//-- Rice. 10.10. mini-USB cable --//

Upgrading Old Computers

Old computers do not have USB ports, but you can install a USB controller made in the form of a PCI expansion card (Fig. 10.11) or in the form of a PC card (for laptops). When purchasing a controller, make sure that it supports USB 2.0 (Fig. 10.12) - if installed, then the newest one.

//-- Rice. 10.11. USB controller in the form of a PCI card (4 USB ports) --//

//-- Rice. 10.12. Dual-port PC card (adds USB support to an old laptop) --//
Sometimes the computer is not very old - there is USB support, but version 1.1, but you need to connect a USB 2.0 device. In this case, a PCI controller will also help. I repeat once again: when purchasing, you need to make sure that you are buying a USB 2.0 controller.

Currently, the USB 3.0 standard has not yet been adopted, but is already under development. It is expected to transmit signals using fiber optic cable. USB 3.0 will be backwards compatible with versions 2.0 and 1.1.
The following companies are currently working on USB 3.0: Intel, Microsoft, Hewlett-Packard, Texas Instruments, NEC and NXP Semiconductors. The planned data transfer rate (peak) is 4.8 Gbit/s.

Does your system support USB

It would seem that if there are USB ports, then there should also be USB support. But it is not always the case. For example, Windows 2000 and Windows XP SP1 do not have a driver for USB 2.0. Even if you have a USB 2.0 controller, without installing a USB 2.0 driver, the USB bus will work as USB 1.1.
Download the USB Ready program from http://www.usb.org/about/faq/ans3/usbready.exe, which will test your system for USB support (Figure 10.13).

//-- Rice. 10.13. USB ready program --//
What should those who have a new USB controller do? There are several options:
install a new version of the OS - Windows Vista, but it is not cheap;
update the OS version to Windows XP SP2; install USB 2.0 driver.

You don't always want to reinstall a well-functioning system. Then we will look for a driver. Sometimes it comes with the motherboard - then you're in luck. But if it is not included in the kit, then we will look for it on the Internet. The most interesting thing is that it is no longer on the Microsoft website. I found the required driver on the website softodrom.ru:
http://soft.softodrom.ru/ap/p4515.shtml.
If by the time the book comes out of print it is no longer there, contact me - I will share it with you.

The first specification (version 1.0) of USB was published in early 1996, and in the fall of 1998 the 1.1 specification appeared, correcting problems found in the first edition. In the spring of 2000, version 2.0 was published, which provided a 40-fold increase in bus throughput. Thus, specification 1.0 and 1.1 provide operation at speeds of 12 Mbit/s and 1.5 Mbit/s, and specification 2.0 - at speeds of 480 Mbit/s. At the same time, USB 2.0 is backward compatible with USB 1.x.

The final USB 3.0 specification appeared in 2008. The creation of USB 3.0 was carried out by Intel, Microsoft, Hewlett-Packard, Texas Instruments, NEC, etc. NXP Semiconductors In the USB 3.0 specification, the updated standard's connectors and cables are physically and functionally compatible with USB 2.0. In addition to the four lines of USB 2.0, USB 3.0 adds four more communication lines (two twisted pairs). The new contacts in the USB 3.0 connectors are located separately from the old ones on a different contact row. The USB 3.0 specification increases the maximum information transfer speed to 4.8 Gbit/s, thus, the transfer speed increases from 60 MB/s to 600 MB/s and allows you to transfer 1 TB not in 8-10 hours, but in 40 minutes-1 hour. Version 3.0 also boasts an increased current from 500 mA to 900 mA, so the user can not only power more devices from one hub, but in many cases the devices themselves will be able to get rid of separate power supplies.

Common USB architecture

The physical architecture of USB is defined by the following rules:

  • devices connect to the host;
  • the physical connection of devices to each other is carried out according to the topology of a multi-tiered star, the top of which is the root hub;
  • the center of each star is a hub;
  • each cable segment connects two points: a host with a hub or function , a hub with a function or another hub;
  • a USB peripheral device or another hub can be connected to each port of the hub, and up to 5 levels of cascading hubs are allowed, not counting the root one.

The topmost level is the root hub, which is usually combined with a USB controller.

Either devices or more hubs can be connected to the root hub to increase the number of available ports. The hub can be made as a separate device, or be built into some other device, i.e. USB connected devices can be classified into functional devices, i.e. those that perform a specific function (for example, mice), hub devices that perform only a fan-out function, and combined devices that include a hub that expand the set of ports (for example, monitors, with ports for connecting others).


At level five, the combination device cannot be used. In addition, it is worth mentioning separately about the host, which is more of a software and hardware complex than just a device.


The details of the physical architecture are hidden from application programs in the system software (software), so the logical architecture looks like a simple star with the application software at its center and a set of endpoints at its vertices. The application communicates with each endpoint.

Components of USB

The USB bus consists of the following elements:


USB Device Properties

  • addressing - the device must respond to the unique address assigned to it and only to it;
  • configuration - after power-up or reset, the device must provide a zero address to be able to configure its ports;
  • data transfer - the device has a set of endpoints for exchanging data with the host. For endpoints that allow different types of transfers, only one of them is available after configuration;
  • energy management - any device when connected should not consume a current exceeding 100 mA from the bus. When configured, the device declares its current requirements, but not more than 500 mA. If the hub cannot supply the device with the stated current, the device will not be used;
  • suspension - The USB device must support suspended mode, in which its current consumption does not exceed 500 µA. The USB device should automatically suspend when bus activity ceases;
  • Remote Wakeup - The remote wakeup capability allows a suspended USB device to signal the host, which may also be in a suspended state. The remote wake-up feature is described in the USB device configuration. This function may be disabled during configuration.

Logical levels of data exchange

The USB specification defines three logic level with certain rules of interaction. A USB device contains interface, logical and functional parts. The host is also divided into three parts - interface, system and software. Each part is responsible only for a certain range of tasks.

Thus, the communication operation between the application program and the USB bus is performed by passing memory buffers through the following layers:

  • client software level in the host:
    • usually represented by a USB device driver;
    • ensures user interaction with the operating system on the one hand and the system driver on the other;
  • USB system driver level in the host (USB, Universal Serial Bus Driver):
    • controls the numbering of devices on the bus;
    • controls the distribution of bus bandwidth and power supply;
    • processes user driver requests;
  • USB bus interface host controller level (HCD, Host Controller Driver):
    • converts I/O requests into data structures on which physical transactions are performed;
    • works with host registers.

Relationship between client software and USB devices: USB provides a software interface for interaction and only that, allowing client software to exist in isolation from the specific device connected to the bus and its configuration. For a client program, USB is just a set of functions.

The interaction of USB components is shown in the diagram below:

The structure under consideration includes the following elements:

USB physical device- a device on the bus that performs functions of interest to the end user.

Client SW— Software corresponding to a specific device, executed on the host computer. It can be part of the OS or a special product.

USB System SW— USB system support, independent of specific devices and client software.

USB Host Controller— hardware and software for connecting USB devices to the host computer.

Data transfer principles

The data transfer mechanism is asynchronous and block-based. The block of transmitted data is called USB frame or USB frame and is transmitted over a fixed time interval. Operating commands and data blocks is implemented using a logical abstraction called channel. A channel is a logical connection between a host and an external device endpoint.

The default channel is used to transmit commands (and data included in the commands), and either streaming channels, or message channels.

The stream delivers data from one end of the channel to the other, it is always unidirectional. The same endpoint number can be used for two flow channels, input and output. A thread can implement the following types of communication: continuous, isochronous, and interrupts. Delivery is always on a first-in, first-out (FIFO) basis; From a USB perspective, the stream data is unstructured. The messages are in a format defined by the USB specification. The host sends a request to the endpoint, after which a message packet is sent (received), followed by a packet containing the endpoint's status information. The next message cannot normally be sent before the previous one is processed, but when handling errors, it is possible to reset unhandled messages. Two-way messaging is addressed to the same endpoint. Only control type exchanges are used to deliver messages.

Channels have characteristics associated with the endpoint. Channels are created when configuring USB devices. For each enabled device, there is a message channel (Control Pipe 0) through which configuration, control and status information is transmitted.

Any communication on the USB bus is initiated by the host controller. It organizes exchanges with devices according to its resource allocation plan.

The controller cyclically (with a period of 1.0 ± 0.0005 ms) generates frames into which all scheduled transmissions fit.

Each frame begins with sending a SOF (Start Of Frame) marker packet, which is a synchronization signal for all devices, including hubs. At the end of each frame, an EOF (End Of Frame) time interval is allocated, during which the hubs prohibit transmission towards the controller. If the hub detects that data is being transmitted from a certain port at this time, this port is disabled.

In high-speed transmission mode, SOF packets are transmitted at the beginning of each microframe (period 125 ± 0.0625 μs).

The host schedules the load of frames so that there is always room for the highest priority transfers, and free frame space is filled with low-priority transfers of large amounts of data. The USB specification allows periodic transactions (isochronous and interrupts) to occupy up to 90% of the bus bandwidth.

Each frame has its own number. The host controller operates a 32-bit counter, but only transmits the lower 11 bits in the SOF token. The frame number is incremented cyclically during EOF.

For isochronous transmission, synchronization of devices and controller is important. There are three synchronization options:

  • synchronization of the device’s internal generator with SOF markers;
  • adjusting the frame rate to the device frequency;
  • matching the transmission (reception) speed of the device with the frame rate.

Several transactions can be performed in each frame, the number of transactions allowed depends on the speed, the length of the data field of each of them, as well as on the delays introduced by cables, hubs and devices. All frame transactions must be completed before the EOF time. The frame rate can be slightly varied using a special host controller register, allowing the rate to be adjusted for isochronous transfers. Adjustment of the controller frame rate is possible to the internal synchronization frequency of only one device.

Information over the channel is transmitted in the form of packets. Each packet begins with a SYNC (SYNChronization) field followed by a PID (Packet IDentifier). The Check field is the bitwise inversion of the PID.

The data structure of a package depends on the group to which it belongs.

1. The client software sends IPR requests to the USBD layer.

2. The USBD driver splits transaction requests according to the following rules:

  • execution of a request is considered complete when all transactions that comprise it are successfully completed;
  • all details of processing transactions (such as waiting for readiness, repeating a transaction in case of an error, unavailability of the receiver, etc.) are not communicated to the client software;
  • The software can only start a request and wait either for the request to complete or to time out;
  • The device may signal serious errors that cause the request to abort and the source of the request is notified.

3. The host controller driver receives a list of transactions from the system bus driver and performs the following actions:

  • schedules the execution of received transactions, adding them to the list of transactions;
  • retrieves the next transaction from the list and transfers it to the host controller level of the USB bus interface;

4. The USB bus interface host controller generates frames;

5. Frames are transmitted by serial bit transmission using the NRZI method

Thus, the following simplified diagram can be formed:

1. each frame consists of the highest priority parcels, the composition of which is formed by the host driver;

2. each transfer consists of one or more transactions;

3. each transaction consists of batches;

4. Each packet consists of a packet identifier, data (if any) and a checksum.

Types of messages in USB

The bus specification defines four different transfer types for endpoints:

  • control gears (Control Transfers) - used by the host to configure the device during connection, to control the device and obtain status information during operation. The protocol ensures guaranteed delivery of such parcels. The length of the control message data field cannot exceed 64 bytes at full speed and 8 bytes at low speed. For such parcels, the host is guaranteed to allocate 10% of the bandwidth;
  • transfer of data arrays (Bulk Data Transfers) - used when it is necessary to ensure guaranteed delivery of data from a host to a function or from a function to a host, but the delivery time is not limited. This transfer takes up all the available bus bandwidth. Packets have a data field of 8, 16, 32 or 64 bytes. Such gears have the lowest priority; they can be suspended when the tire is heavily loaded. Allowed only at full transmission speed. Such parcels are used, for example, by printers or scanners;
  • interrupt transmissions (Interrupt Transfers) - used when it is necessary to transmit single data packets of small size. Each packet must be transmitted within a limited time. Transfer operations are spontaneous and must be serviced no slower than required by the device. The data field can contain up to 64 bytes at full speed and up to 8 bytes at low speed. The service time limit is set in the range of 1-255 ms for full speed and 10-255 ms for low speed. Such transfers are used in input devices such as the mouse and keyboard;
  • isochronous transmissions (Isochronous Transfers) - used for data exchange in “real time”, when at each time interval it is necessary to transmit a strictly defined amount of data, but the delivery of information is not guaranteed (data transmission is carried out without repetition in case of failures, packet loss is allowed). Such transfers occupy a pre-negotiated portion of the bus bandwidth and have a specified delivery delay. Isochronous transfers are commonly used in multimedia devices to transmit audio and video data, such as digital voice. Isochronous transfers are divided according to the method of synchronizing endpoints - sources or recipients of data - with the system: they distinguish between asynchronous, synchronous and adaptive classes of devices, each of which has its own type of USB channel.

Interrupt mechanism

There is no real interrupt mechanism for the USB bus. Instead, the host polls connected devices for interrupt data. Polling occurs at fixed time intervals, typically every 1 - 32 ms. The device is allowed to send up to 64 bytes of data.

From the driver's point of view, the ability to handle interrupts is actually determined by the host, which provides support for the physical implementation of the USB interface.

Data transfer modes

The USB bus has three data transfer modes:

  • low-speed (LS, Low-speed) 1.5 Mbit/s;
  • full-speed (LF, Full-speed) 12 Mbit/s;
  • high-speed (HS, High-speed, only for USB 2.0) 480 Mbit/s.

Connecting peripheral devices to the USB bus

To connect peripheral devices to the USB bus, a four-wire cable is used, with two wires (twisted pair) in a differential connection used to receive and transmit data, and two wires to power the peripheral device.

Specification 1.0 regulated two types of connectors:


Subsequently, miniature connectors were developed for the use of USB in portable and mobile devices, called Mini-USB.

There are also Mini AB and Micro AB connectors, to which the corresponding connectors of both type A and type B are connected.

There are also miniature connectors - Micro USB.

Type USB 2.0Meaning of contactsWire color

Connecting a Full Speed ​​Device

Connecting a Low Speed ​​Device

Synchronization signals are encoded along with data using the NRZI (Non Return to Zero Invert) method. Each packet is preceded by a SYNC field that allows the receiver to tune to the transmitter frequency.

The cable also has VBus and GND lines to transmit the 5V supply voltage to the devices. The cross-section of the conductors is selected in accordance with the length of the segment to ensure a guaranteed signal level and supply voltage.

USB bus ( U universal S erial B us - universal serial bus) appeared by computer standards quite a long time ago - the version of the first approved version of the standard appeared on January 15, 1996. The development of the standard was initiated by very reputable companies - Intel, DEC, IBM, NEC, Northen Telecom and Compaq.

The main goal of the standard set for its developers is to create a real opportunity for users to work in Plug&Play mode with peripheral devices. This means that it must be possible to connect the device to a running computer, automatically recognize it immediately after connection and then install the appropriate drivers. In addition, it is advisable to supply power to low-power devices from the bus itself. The bus speed should be sufficient for the vast majority of peripheral devices. At the same time, the historical problem of lack of resources on the internal buses of an IBM PC compatible computer is solved - the USB controller takes up only one interrupt, regardless of the number of devices connected to the bus.

Almost all the assigned tasks were solved in the USB standard, and in the spring of 1997, computers equipped with connectors for connecting USB devices began to appear (see photo on the left), but peripherals with USB connections practically never appeared until mid-1998. What's the matter? Why was it only by the end of 1998 that equipment manufacturers began to offer devices with a USB interface significantly more actively on the market? There are several explanations for this:

    no urgent need for desktop computer users to have devices with full Plug&Play support. Peripherals are usually connected to a desktop computer seriously and for a long time, and the vast majority of users do not have any particular need for frequent changes of peripherals.

    higher cost of devices with USB compared to similar devices with standard interfaces

    lack of support from software manufacturers and, mainly, Microsoft, although it was one of the authors of the standard. It wasn't until Windows 98 that full USB support appeared, and Windows NT wasn't supposed to have it until 1999.

Now USB has begun to be actively implemented by computer peripheral manufacturers. The presence of only USB as an external bus in the iMAC computer from Apple Computers became a sensation.

Specifications

USB capabilities follow from its technical characteristics:

    High transfer speed (full-speed signaling bit rate) - 12 Mb/s

    Maximum cable length for high transfer speed - 5 m

    Low-speed signaling bit rate - 1.5 Mb/s

    Maximum cable length for low transfer speed - 3 m

    Maximum number of connected devices (including multipliers) - 127

    It is possible to connect devices with different baud rates

    No need for the user to install additional elements such as SCSI terminators

    Supply voltage for peripheral devices - 5 V

    The maximum current consumption per device is 500 mA (this does not mean that devices with a total current consumption of 127 x 500 mA = 63.5 A can be powered via USB)

Therefore, it is advisable to connect almost any peripheral devices to USB, except digital video cameras and high-speed hard drives. This interface is especially convenient for connecting frequently connected/disconnected devices, such as digital cameras. The USB connectors are designed to withstand multiple mating/unplugging.
The ability to use only two data rates limits the usability of the bus, but significantly reduces the number of interface lines and simplifies the hardware implementation.
Power directly from USB is only possible for low power devices such as keyboards, mice, joysticks, etc.

Topology

This icon officially denotes the USB bus both in Windows 98 and on the back walls of computers (unfortunately, not all), as well as on all USB connectors. This icon actually correctly represents the idea of ​​USB topology. The USB topology is practically no different from the topology of a conventional twisted-pair local network, usually called a star. Even the terminology is similar - bus multipliers are also called HUBs.

Conventionally, the tree for connecting USB devices to a computer can be depicted as follows (the numbers indicate peripheral devices with a USB interface):

Instead of any of the devices there can also be a HUB. The main difference from the topology of a regular local network is that there can only be one computer (or host device). The HUB can be either a separate device with its own power supply or built into a peripheral device. Most often, HUBs are built into monitors and keyboards

The figure above shows an example of the correct connection of peripheral devices to a conditional USB network. Since data exchange via USB occurs only between the computer and the peripheral device (there is no exchange between devices), devices with large volumes of data reception and/or transmission must be connected either to the computer itself or to the nearest free node. In this case, the highest traffic is on the speakers (~1.3 Mb/s), followed by the modem and scanner connected to the HUB in the monitor, and the chain is completed by the keyboard, joystick and mouse, whose traffic is close to zero.
The question may arise - why do speakers have such high traffic? The fact is that speakers with a USB interface are significantly different from regular ones. A sound card is NOT REQUIRED to use these speakers. The speaker driver sends the digitized sound directly to the speakers, where it is converted into an analog signal using an ADC and sent to the speakers.

Cables and connectors

USB signals are transmitted via a 4-wire cable, shown schematically in the figure below:

Here GND is the “case” circuit for powering peripheral devices, VBus is +5V also for power supply circuits. The D+ bus is for transmitting data on the bus, and the D- bus is for receiving data.
The full-speed bus cable is a twisted-pair cable, protected by a shield, and can also be used for low-speed operation. A cable for operation only at minimum speed (for example, to connect a mouse) can be any and unshielded.
The connectors used to connect peripheral devices are shown in the figure below.

"A" series connectors

B series connectors

    are intended ONLY for connection to a source, i.e. computer or HUB.

    intended for connection to a peripheral device ONLY

Type "A" plug.

"B" type plug.

Type A socket

Type B socket

As can be seen from the figure, it is impossible to connect the device incorrectly, since the “A” series connector can only be connected to an active device on a USB HUB or computer, and the “B” series connector only to the peripheral device itself.

USB connectors have the following pin numbering:

Contact number

Purpose

Wire color

USB connector pinout

USB development

In 1999, the same consortium of computer companies that initiated the development of the first version of the USB bus standard began actively developing version 2.0 of USB, which is distinguished by the fact that the bus bandwidth has been increased by 20 (!) times, up to 250 Mbits/s, which makes allows video data transfer via USB and makes it a direct competitor to IEEE-1394 (FireWire).
The compatibility of all previously released peripherals and high-speed cables is fully preserved and one of the most important advantages of USB is preserved - the low cost of the controller. A 2.0 standard controller is also expected to be integrated into the chipset.
Everything is good, but there is one thing: the IEEE-1394 bus is already very actively used even in household digital video cameras, there are video editing boards for it, and with the constant fall in prices for digital video cameras, it will be used more and more widely. The new version of USB should only be finally developed by mid-2000, and the first devices supporting the new USB version should appear no earlier than the end of 2000. This is a very long time frame for the computer industry. Already in July 1999, for example, ASUSTeK Computers released the first motherboard (P3B-1394) with a built-in IEEE-1394 controller. Surely this will not go unnoticed and other manufacturers will also begin to produce similar boards. Therefore, by the time USB 2.0 devices come out, their place in the sun may already be taken.

The USB serial bus (Universal Serial Bus) has been around for a long time by computer standards - the first approved version of the standard appeared on January 15, 1996. The development of the standard was initiated by very reputable companies - Intel, DEC, IBM, NEC, Northen Telecom and Compaq.

The main goal of the standard set for its developers is to create a real opportunity for users to work in Plug&Play mode with peripheral devices. This means that it must be possible to connect the device to a running computer, automatically recognize it immediately after connection and then install the appropriate drivers. In addition, it is advisable to supply power to low-power devices from the bus itself. The bus speed should be sufficient for the vast majority of peripheral devices. At the same time, the historical problem of lack of resources on the internal buses of an IBM PC compatible computer is solved - the USB controller takes up only one interrupt, regardless of the number of devices connected to the bus.

The capabilities of the USB serial bus follow from its technical characteristics:

High transfer speed (full-speed signaling bit rate) – 12 Mb/s

Maximum cable length for high transfer speed – 5 m

Low-speed signaling bit rate – 1.5 Mb/s

Maximum cable length for low transfer speed – 3 m

The maximum number of connected devices (including multipliers) is 127.

It is possible to connect devices with different baud rates

No need for the user to install additional elements such as SCSI terminators

Supply voltage for peripheral devices – 5 V

The maximum current consumption per device is 500 mA.

Therefore, it is advisable to connect almost any peripheral devices to USB, except digital video cameras and high-speed hard drives. The USB connectors are designed to withstand multiple mating/unplugging.

The ability to use only two data rates limits the usability of the bus, but significantly reduces the number of interface lines and simplifies the hardware implementation.

Power directly from USB is only possible for low power devices such as keyboards, mice, joysticks, etc.

USB signals are transmitted via a 4-wire cable.

The full-speed bus cable is a twisted-pair cable, protected by a shield, and can also be used for low-speed operation. A cable for operation only at minimum speed (for example, to connect a mouse) can be any and unshielded.

The USB system is divided into three levels with certain rules of interaction. A USB device contains an interface part, a device part and a functional part. The host is also divided into three parts - interface, system and device software. Each part is responsible only for a certain range of tasks; the logical and real interaction between them is illustrated in Fig. 69.

The structure under consideration includes the following elements:

A physical USB device is a device on the bus that performs functions of interest to the end user.

Client SW – software corresponding to a specific device, executed on the host computer. It can be part of the OS or a special product.

USB System SW – system support for USB, independent of specific devices and client software.

USB Host Controller – hardware and software for connecting USB devices to a host computer.

Rice. 69 Interaction of USB components

Physical interface

Information signals and 5V supply voltage are transmitted via a four-wire cable. A differential method of transmitting D+ and D– signals over two wires is used. Transmitter signal levels in static mode must be below 0.3 V (low level) or above 2.8 V (high level). Receivers can withstand input voltage within the range of -0.5...+3.8 V. Transmitters must be able to switch to a high-impedance state for bidirectional half-duplex transmission over one pair of wires.

Two-wire transmission in USB is not limited to differential signals. In addition to the differential receiver, each device has linear receivers for D+ and D– signals, and the transmitters of these lines are individually controlled. This makes it possible to distinguish between more than two line states used to establish a hardware interface. The DiffO and Diff1 states are determined by the potential difference on the D+ and D – lines of more than 200 mV, provided that on one of them the potential is higher than the VSE response threshold. A condition in which a low level is present at both inputs D+ and D– is called linear zero (SEO – Single-Ended Zero). The interface defines the following states:

DataJ State and Data K State – states of the transmitted bit (or simply J and K), are determined through the states DiffO and Diff1.

Idle State – pause on the bus.

Resume State – “wake-up” signal to wake up the device from “sleep” mode.

Start of Packet (SOP) – the beginning of the packet (transition from Idle State to K).

End of Packet (EOP) – end of the packet.

Disconnect – the device is disconnected from the port.

Connect – the device is connected to the port.

Reset – reset the device.

States are determined by combinations of differential and linear signals; for full and low speeds, the DiffO and Diff1 states have opposite purposes. When decoding the Disconnect, Connect and Reset states, the time the lines are in certain states (more than 2.5 ms) is taken into account.

The bus has two transmission modes. Full USB signaling speed is 12 Mbps, low speed is 1.5 Mbps. For full speed, shielded twisted pair cable with an impedance of 90 Ohms and a segment length of up to 5 m is used, for low speed, untwisted unshielded cable is used up to 3 m.

Synchronization signals are encoded along with data using the NRZI (Non Return to Zero Invert) method, its operation is illustrated in Fig. 72. Each packet is preceded by a SYNC field that allows the receiver to tune to the transmitter frequency.

The cable also has VBus and GND lines to transmit the 5V supply voltage to the devices. The cross-section of the conductors is selected in accordance with the length of the segment to ensure a guaranteed signal level and supply voltage.

Rice. 70 Connecting a full speed device

Rice. 71 Connecting a low speed device

Rice. 72. Data coding using the NRZI method

The standard defines two types of connectors (Table 7 and Fig. 73).

Table 7

Type "A" connectors are used to connect to hubs (Upstream Connector). Plugs are installed on cables that are not detachable from devices (for example, keyboard, mouse, etc.). The sockets are installed on the Downstream Ports of the hubs.

Type B connectors (Downstream Connectors) are installed on devices from which the connecting cable can be disconnected (printers and scanners). The mating part (plug) is installed on the connecting cable, the opposite end of which has a type “A” plug.

Connectors of types “A” and “B” are mechanically different (Fig. 73), which eliminates unacceptable loop connections of hub ports. The four-pin connectors are keyed to prevent incorrect connection. The design of the connectors ensures late connection and early disconnection of signal circuits compared to power supply circuits. To recognize the USB connector, a standard symbolic designation is placed on the device body.

Rice. 73. USB sockets: a – type “A”, b – type “B”, c – symbolic designation

Data transfer model

Each USB device is a set of independent endpoints with which the host controller exchanges information. Endpoints are described by the following parameters:

required bus access frequency and acceptable service delays;

required channel bandwidth;

point number;

error handling requirements;

maximum sizes of transmitted and received packets;

type of exchange;

direction of exchange (for continuous and isochronous exchanges).

Each device must have an endpoint numbered 0, which is used for initialization, general management, and polling of its status. This point is always configured when power is turned on and the device is connected to the bus. It supports control type transfers.

In addition to the zero point, function devices may have additional points that implement useful data exchange. Low-speed devices can have up to two additional points, full-speed devices can have up to 16 input points and 16 output points (protocol limitation). Points cannot be used until they are configured (the channel associated with them is established).

A channel (Pipe) in USB is a data transfer model between the host controller and the endpoint (Endpoint) of the device. There are two types of channels: streams (Stream) and messages (Message). The stream delivers data from one end of the channel to the other, it is always unidirectional. The same endpoint number can be used for two flow channels - input and output. A thread can implement the following types of communication: continuous, isochronous, and interrupts. Delivery is always on a first-in, first-out (FIFO) basis; From a USB perspective, the stream data is unstructured. The messages are in a format defined by the USB specification. The host sends a request to the endpoint, after which a message packet is sent (received), followed by a packet containing the endpoint's status information. The next message cannot normally be sent before the previous one is processed, but when handling errors, it is possible to reset unhandled messages. Two-way messaging is addressed to the same endpoint. Only control type exchanges are used to deliver messages.

Channels have characteristics associated with the endpoint (bandwidth, service type, buffer size, etc.). Channels are created when configuring USB devices. For each enabled device, there is a message channel (Control Pipe 0) through which configuration, control and status information is transmitted.

Data transfer types

USB supports both unidirectional and bidirectional communication modes. Data transfer occurs between the host software and the device endpoint. A device can have several endpoints, and communication with each of them (channel) is established independently.

The USB architecture allows for four basic types of data transfer:

Control Transfers used for configuration during connection and during operation to control devices. The protocol provides guaranteed data delivery. The length of the control message data field does not exceed 64 bytes at full speed and 8 bytes at low speed.

Bulk Data Transfers of relatively large packages without strict delivery time requirements. Transmissions occupy the entire free bandwidth of the bus. Packets have a data field of 8, 16, 32 or 64 bytes. These gears have the lowest priority and may be suspended when the bus is heavily loaded. Allowed only at full transmission speed.

Interrupts are short (up to 64 bytes at full speed, up to 8 bytes at low speed) transmissions such as input characters or coordinates. Interrupts are spontaneous in nature and must be serviced no slower than required by the device. The service time limit is set in the range of 1–255 ms for full speed and 10–255 ms for low speed.

Isochronous Transfers are continuous real-time transfers that occupy a pre-agreed portion of the bus bandwidth and have a specified delivery delay. If an error is detected, isochronous data is transmitted without repetition - invalid packets are ignored. An example is digital voice transmission. Bandwidth is determined by transmission quality requirements, and delivery delay can be critical, for example, when implementing teleconferencing.

The bus bandwidth is divided among all installed channels. The allocated bandwidth is assigned to a channel, and if the establishment of a new channel requires a bandwidth that does not fit into the existing allocation, the request for channel allocation is rejected.

The USB architecture provides for internal buffering of all devices, and the more bandwidth the device requires, the larger its buffer should be. USB must provide data transfer at such a speed that the data delay in the device caused by buffering does not exceed a few milliseconds.

Isochronous transfers are classified according to the method of synchronizing endpoints - sources or recipients of data - with the system: they distinguish between asynchronous, synchronous and adaptive classes of devices, each of which has its own type of USB channel.

Protocol

All exchanges (transactions) via USB consist of three packages. Each transaction is scheduled and initiated by the controller, which sends a Token Packet. It describes the transfer type and direction, USB device address and endpoint number. In each transaction, exchange is possible only between the addressed device (its endpoint) and the host. The device addressed by the marker recognizes its address and prepares for exchange. The data source (identified by the token) transmits a packet of data (or a notification that there is no data to transmit). After successfully receiving the packet, the data receiver sends a confirmation packet (Handshake Packet).

Transaction scheduling provides control over flow channels. At the hardware level, using transaction aversion (NAck) when the transfer rate is unacceptable prevents buffers from overflowing at the top and bottom. Tokens of rejected transactions are retransmitted when the bus is free. Flow management allows you to flexibly schedule servicing of simultaneous heterogeneous data streams.

The following USB properties provide error resistance:

High signal quality achieved through differential receivers/transmitters and shielded cables.

Protection of control fields and data with CRC codes.

Detects the connection and disconnection of devices and configures resources at the system level.

Self-healing protocol with timeout when packets are lost.

Flow control for isochrony and hardware buffer management.

Independence of functions from unsuccessful exchanges with other functions.

To detect transmission errors, each packet has CRC control fields to detect all single and double bit errors. The hardware detects transmission errors and the controller automatically attempts transmission three times. If retries are unsuccessful, an error message is reported to the client software.

Package formats

Bytes are transferred across the bus sequentially, starting with the least significant bit. All parcels are organized in packages. Each packet begins with a Sync field, which is represented by the state sequence KJKJKJKK (NRZI encoded) following the Idle state. The last two bits (CC) are the start of the SOP packet marker, used to identify the first bit of the PID packet identifier. The packet identifier is a 4-bit PID field identifying the type of packet (Table 8), followed by the same 4 bits, but inverted, as control bits.

The address fields in the IN, SETUP, and OUT marker packets are a 7-bit function address and a 4-bit endpoint address. They allow up to 127 USB functions to be addressed (address zero is used for configuration) and 16 endpoints per function.

The SOF packet has an 11-bit Frame Number Field, which is incremented sequentially (cyclically) for each frame.

The data field can be from 0 to 1023 whole bytes in size. The size of the field depends on the type of transmission and is negotiated when the channel is established.

The SCS-col field is present in all tokens and data packets; it protects all fields of the packet, excluding PID. CRCs for tokens (5 bits) and data (11 bits) are calculated using different formulas.

Table 8

Contents and purpose

Function address and endpoint number – function transaction token

Function address and endpoint number - host transaction token

Start of frame marker

Function address and endpoint number - transaction token with control point

Even and odd PID data packets are interleaved to accurately identify acknowledgments

Confirmation of error-free packet reception

The receiver failed to receive or the transmitter failed to transmit data. Can be used for data flow control (unready). In interrupt transactions, it is an indication that there are no unserviced interrupts

Endpoint requires host intervention

Low speed transmission preamble

Each transaction is initiated by the host controller by sending a token and ends with a handshake packet. The sequence of packets in transactions is illustrated in Fig. 7.7.

The host controller organizes exchanges with devices according to its resource allocation plan. The controller cyclically (with a period of 1 ms) generates frames into which all scheduled transactions fit. Each frame begins with sending a SOF (Start Of Frame) marker, which is a synchronization signal for all devices, including hubs. At the end of each frame, an EOF (End Of Frame) time interval is allocated, during which the hubs prohibit transmission towards the controller. Each frame has its own number. The host controller operates a 32-bit counter, but only transmits the lower 11 bits in the SOF token. The frame number increases (cyclically) during EOF. The host schedules the loading of frames so that there is always room for control and interrupt transactions. Free time of frames can be filled with continuous transfers (Bulk Transfers).

Task to complete the work

1. Describe bus and port management functions

a) forming a port address

b) organization of an end-to-end channel in the system interface for data transfer between the port of the I/O device and the MP.

2. Structure of microprocessor memory.

3. USB serial bus. Data transmission modes.

4. Chipset. Its purpose. Chipset diagram.

5. Microprocessor memory. Registers and their purpose.

6. Standard interfaces and data transfer formats.

7. Provide diagrams for connecting modems, printers, plotters to the COM port.

8. Draw a diagram of the interaction of the \USB components.

USB bus

Look at the back of your device. You will see a lot of different connectors there: serial and parallel ports, connectors for connecting a joystick, speakers, keyboard, mouse and many others. Such abundance is not very good, since, firstly, it does not have a positive effect on the cost of the motherboard (insignificantly, of course, but still), and, secondly (more importantly) it creates some difficulties for connecting external peripherals . In fact, if a person has never seen a computer, and then he needs to connect a mouse, then he simply will not know where to insert it. In addition, the software must support all these standards, and this only unnecessarily complicates it (providing), and creates additional difficulties for installing drivers, configuration, etc. Of course, for a knowledgeable user all these are trifles, but the entire computer world strives to make “easy PC”, that is, when you arrive, install it, plug it in, turn it on, load it and play Unreal Tournament, and everything else will be done by itself. And, as already mentioned, not everyone knows where to push the mouse, and without a mouse, you understand, Unreal is not Unreal. By the way, here I completely share the position of hardware manufacturers - the user should use the computer, and not bother with all sorts of interruptions, connectors, etc., because even if all this is not particularly difficult, it is still very unpleasant. And all these problems, as you probably already guessed, “should be solved by the USB bus.” So let's get straight to the point.

USB bus ( Universal Serial Bus) is a universal bus designed for easy and quick connection of peripheral devices. The standard was developed by seven companies: Compaq, Digital Equipment, IBM, Intel, Microsoft, NEC and Northern Telecom. The USB cable consists of two twisted pairs: one pair transmits data in each direction (differential connection), and the other is the power line (+5 V). With built-in power lines that provide up to 500 mA of current, USB often allows devices to be used without their own power supply (as long as the devices draw less than 500 mA of current).

Up to 127 devices can be connected to one computer through a chain of hubs (they use a star topology). Moreover, these devices can be very different - from a keyboard with a mouse to scanners and digital cameras. Imagine a printer, scanner, keyboard, speakers, joystick and a dozen more mice connected to one port at once and still working at the same time! True, we need to make a small clarification: in order for all these devices to work effectively, they must have at their disposal the bandwidth they need, and it is limited to 12 megabits, which USB can provide, that is, one scanner with a good printer will eat up more, and then there’s speakers, and a modem, and whatever. In other words, it will work, but the situation will turn out like in that joke: “Now let’s try to take off with all this.” I would not recommend hanging too many high-speed devices that are supposed to be used simultaneously on one USB connector (motherboards have two or more connectors). By the way, all these mice and modems consume a certain current, which is supplied by the bus (if the device does not have its own power supply), and it should not exceed the maximum value, which also reduces 127 to some other, much smaller number.

Data transmission over the bus can be carried out in both asynchronous and synchronous modes. In USB, information is exchanged with fast devices at a speed of 12 Mbits/s, and with slow ones - 1.5 Mbits/s. All devices connected to USB are configured automatically (PnP) and allow Hot-Swap to be turned on/off (without rebooting or shutting down the computer). This is achieved as follows. When the cable is connected to the USB connector, the USB controller senses a voltage surge and sends a corresponding signal to the operating system, and it loads the driver, which ensures the operation of the device at the software level. Or, if the driver has not been installed, the system, seeing this disgrace, recognizes the device and installs the necessary drivers independently or with the help of the user. When you further turn this device on/off, initialization occurs as described in the first case. During recognition, a corresponding message appears on the screen, and changes in Device Manager occur automatically. The device also reports information about its type, manufacturer, purpose and required bandwidth. It is assigned a unique identification number. That's all you need, no questions asked There will be no more IRQ, port addresses and DMA, although one interrupt is still needed - for the USB controller itself.

To interact between devices, the above-mentioned cable is used, which has connectors at the ends that resemble telephone ones. There are two types of connectors: type "A" connector and type "B" connector. Typically, the device is connected to the cable with one connector (B), and the other to the USB port (A). Devices can be connected in a chain; for this purpose, they may have an additional port for connecting a cable going to the next device. However it is not always so. Therefore, there are special USB hubs that connect to a USB port and divide it into several. There are hubs with a power supply; they allow you to somewhat bypass the limitation on the electrical load. The figure on the left shows an internal hub that is inserted into a 5" bay and connected to a USB port with an external cable coming out of the back wall of the PC. The hub is a regular USB device, so there can be more than one of them; they can also be included in a chain. Old computers that do not have USB (now the USB controller is built directly into the chipset) can be equipped with a PCI to USB card.

Unlike almost the entire computer industry, when the standard is still far from being adopted, and devices that support it are already being sold on the market with all their might, with the USB bus everything turned out the other way around. The standard was adopted already in 1995, and in 1997 no one could really explain what USB is. The reason is support (or rather the lack thereof) from the software. Here, device manufacturers waited for Microsoft to release an OS with USB support, and Microsoft, in turn, said: why make a new system when USB devices can be counted on one hand. In addition, Windows 95 can still work with USB, albeit poorly. It turned out to be a vicious circle of sorts. But in 1998, Microsoft tensed up and finally made an operating system with more or less full USB support (meaning Windows 98). Naturally, this support was retained in subsequent versions of Uncle Billy's systems. And then USB devices began to appear like mushrooms after rain. So now almost all peripherals have USB options, and a very large number of devices are made only for this bus. More information about what can be connected to USB can be found at http://www.allusb.com/.

Theoretically, you can connect anything to the USB bus - even a hard drive or a video editing system. Such devices even exist (see, for example, the photo of the converter below) and are purchased. But this, as they say, is an attempt to combine the incompatible. It all comes down to the maximum throughput of the bus. It is only enough to transmit video of very mediocre quality. The hard drive will also slow down greatly, since 12 megabits for a hard drive, you understand, is not speed. The only area where it can be used is the role of a “large floppy disk” or used as a second high-capacity disk in a laptop computer, but there is no way to write a high-quality AVI file in real time on such a device. True, USB 2.0 is coming, where the speed will be much increased.

Lately, Microsoft, along with Intel and other companies, have been promoting the idea of ​​a computer that doesn't have anything. And if in 1999 the ISA came under the hot hand, now the computer “should not have any serial, parallel or PS/2 ports.” All this equipment should be replaced by USB. It is quite possible that this will happen soon - after all, ISA support has already been practically removed from the PC. Well, okay, God bless her, in general, with the ISA, it’s not a big loss. Now all modern devices come in a PCI version, and for ISA there is little good left, and if someone still has something they love, then you can find a modern board with ISA slots and work in Windows 98, and if very if you want something more modern, then you can spend money and replace the devices with new ones, but the money will be enough, because to work with modern applications (otherwise why modern hardware?) you don’t need the cheapest computer, and if it’s enough for a computer, then it’s enough for the same FM tuner for PCI. We are discussing USB. The situation here is the same as with ISA at one time, but only now it is more relevant. Well, why on earth would anyone want to change their expensive and beloved mouse from PS/2 to USB, even if it crawls more smoothly? And what about the modem, which has already downloaded how many gigabytes from the Internet and can download the same amount with no less success? Well, the printers are okay, all normal modern printers can work with both LPT and USB. But few people want to pay extra money for purely alternative devices for USB, since the same keyboards and mice cost 10-20 dollars more than exactly the same ones, but “not USB”.

But, nevertheless, in my opinion, if you are buying something new, then you should pay attention to USB first. Firstly, for some devices (printers, scanners, and the price of the latter, by the way, is often even lower in the USB version), USB gives an increase in productivity due to higher bandwidth. On the other hand, you will get ease of use and perhaps some additional features. Thirdly, become the owner of a modern device, and not just any antique. I completely agree with the concept of the need for a complete USB transition, proposed by some companies - we need to get rid of stone age technologies.