USB interface

USB interface is one of the interfaces often found in various devices, such as, USB memories. However, the data transfer mechanism of the USB interface is not well known. This article will provide plain explanation of USB interface, by examining the USB 2.0 overview.

System Using USB

System Using USB

USB is a very popular serial interface especially for PCs. A hierarchical structure is applied to USB interface. One “Host” dominates many “Devices” in the network. For example, a PC is a host, and the devices are apparatuses connected to the PC through USB cables, such as keyboards, mouse devices, printers, flash memories and speakers.

System Using USB

USB has a remarkable feature of plug-and-play. Switching off a PC is unnecessary when USB devices are connected or removed. This is one of the reasons USB has become so popular.

USB Interface in a Microcontroller

USB interface is used by other machines than PCs. The usage would be much simpler than that of a PC. One example is a multi-function printer’s USB interface. Multi-function printers are usually connected to PCs through network and print out the information in the PCs. However, some printers print out photograph data without using PC. In this case, those printers have embedded hosts of USB and control USB memories directly. It is enough for the host to store photograph data or document data from a USB device, and PC’s complicated function is not necessary.
In such usage a microcontroller with an embedded USB host is one of the best solutions for implementation of USB interface on the printer.

USB Interface in a Microcontroller

Toshiba 32-bit microcontrollers, TX03 series, support USB interface, either USB host interface or USB device. M360 group have either an embedded host or a device of USB 2.0 Full-Speed (12Mbps). M320 group integrate a host and a device of USB 2.0 High-Speed (480Mbps) as well as Full-Speed especially for Audio application.
Those microcontrollers will be introduced later.

Operation of USB

When a USB device is inserted to a USB terminal on a PC, the following operations are performed inside the PC.
The connection of the USB device is immediately detected by the USB host in the PC. Actually, the host is monitoring the connection of USB devices at all USB terminals. Once the host finds a new device, it requests the device to send the device information. The host select an appropriate driver, gives an address, and so on, to the device, which is called “enumeration”. The host can access correctly after the enumeration completion.

When the data in the USB memory (device) is transferred to the hard disc drive in the PC, the host commands the device to send the data to the host. The device transfers the data to the host, and the host returns an acknowledge to the device which shows the operation has completed successfully. On the other hand, when the direction of the pathway is reverse, the host announces its intention to send the data to the device, and transfers it. The device receives the data and return an acknowledge to the host.
When the device is going to be removed from the PC, the device, in some way, tells to the host about it. Then the host cuts off the connection to prepare the removal of the device. After that, the PC shows the sign on the monitor that the USB memory can be disconnected.

You probably know how to connect or disconnect a USB device to/from a PC.

Protocol of USB

USB 2.0 specifies three kinds of transfer rates, Low-Speed (1.5Mbps), Full-Speed (12Mbps), and High-Speed (480Mbps). The USB interface in Toshiba TX03 series microcontrollers mainly are compliant with the Full-speed.
The data formats and types of USB are explained from now as the following. First, the serial data format is introduced. Then, the four types of transfer modes are explained. Finally, the actual wave form in data transfer is described.

Format of USB

  1. Packet
    1. Token Packet
    2. Data Packet
    3. Handshake Packet
  2. Transaction
  3. Frame

Type of Transfer

  1. Control Type
  2. Bulk Type
  3. Interrupt Type
  4. Isochronous Type


Format of USB


The minimum unit of transfer data of USB is a packet. The packet consists of the SYNC field, a packet ID (PID) field, a field of a variety of data (DATA field), and the CRC (Cyclic Redundancy Check) field.


The SYNC field is 8bit, which synchronizes between the transmitter clock and the receiver one.
The PID field shows what kind of data will be transmitted.
The DATA field contains the actual transferred data.
And the CRC field has an error check code to check if there is no error in the data transfer.
The above figure illustrates a general format of a packet. The actual packet format is shown as follows.

1) Token Packet

Token Packet

The ADR (USB address) and the ENDP (End Pint) are the address of the transmission register or the receiving register of the ‘DATA Packet’.

2) Data Packet

Data Packet

3) Handshake Packet

Handshake Packet

The handshake packet has SYNC field and PID one, and neither DATA field nor CRC exists.


The packets, Token, Data, and Handshake packets have been introduced. A series of transfer data between USB host and device consist of several combinations of these packets. As an example, it is described how the host receives the DATA from the device.
The host begins to transmit a Token packet to the device. The packet includes the register address (ENDP) and the device address (ADR) which the transfer data will come from. And PID contains a data receiving (IN) code.
The device transfers the data from the addressed register (Data Packet).
The host returns an acknowledge (ACK) to the device to receive the data successively (Handshake Packet). This acknowledge is contained in the PID field.
Such combination of Token, Data, and Handshake packets is called a transaction.



The maximum length unit in USB Full-Speed is “Frame”. One frame time-length is 1ms fixed. The frame starts with SOF (Start of Frame) packet. After the SOF many transactions would follow.

SOF Packet

Type of Transfer

USB has four transfer types depending on the data. They are called Control, Bulk, Interrupt, and Isochronous types.

Control Type

This type is used when control data are transferred. When a host does enumeration of a device, the transfer data are divided into many short fragments and transmitted many times. This scheme will make sure each transfer would be successful.

Bulk Type

This type is convenient for transferring a big amount of data, for example, stored data in a USB memory, to a folder in a PC. The DATA field of the data packet should become as long as possible to save time for transfer. While transfer, if an urgent transmission requests its interrupt, the Bulk type transfer can stop and give place to the interrupt.

Interrupt Type

This type is convenient for transferring a big amount of data, for example, stored data in a USB memory, to a folder in a PC. The DATA field of the data packet should become as long as possible to save time for transfer. While transfer, if an urgent transmission requests its interrupt, the Bulk type transfer can stop and give place to the interrupt.

Isochronous Type

This type is used by transfer of real-time data, video clips and music data, as examples. Those data must be transferred seamlessly and fortunately no confirmation of correct arrival of the data. No handshake packet is issued by the receiver.

The most effective type can be selected, depending on what kind of data is transferred.

Signal Waveform

The cable of USB has 4 wires; VDD, GND, signal D+, and signal D-. D+ and D- are complementary values each other for one transferred data. In the case that D+ is high and D- is low, the data is called “Differential 1”. And D+ is low and D- is high, “Differential 0”. But the wave form of actual transferred data is neither “Differential 1” nor “Differential 0”.
The data format of USB is NRZI (non-return to zero inverted). This format defines data “1” when no change occurs in one clock interval, and data “0”, either high-to-low or low-to-high change occurs.

Signal Waveform
Signal Waveform

USB does not have any clock lines. So the Host and the Driver have to synchronize each other. 8 bit SYNC codes are transferred to synchronize a receiver to a transmitter in USB Full-Speed.


Technical inquiry

Contact us

Contact us

Frequently Asked Questions

A new window will open