USB protocol
USB protocol in Embedded systems

USB protocol

Introduction

Universal Serial Bus (USB) is a widely-used protocol in most devices Its a industry standard way to connect multiple peripheral devices to a host .

USB has some unique advantages of ease of use (such as plug and play, hot swapping without rebooting, and no power supply required), low cost, low power consumption, and fast data transfer.

USB speed

Since the USB protocol has been released , devolped the protocol to support the increasing in storage speed for faster transfer

- USB 1.0    Low speed         1.5 Mbs

-USB 1.0.   Full speed.         12 Mbs

- USB 2.0    High speed        480 Mbs

- USB 3.0    Super speed      4.8 Gbs

- USB 3.1    Super speed+   10 Gbs

USB advantage

- Hot pluggable

- Low cost

- No external power supply (takes power from host )

- Error detection

USB disadvantage

- Complex protocol

- Hardware problems in legacy devices

USB cables

All standard usb has four shielded wires: ground, Vbus (5 volts), data plus (D+) and data minus (D-). The Vbus can provide power supply to USB devices. The D+ and D- wires are physically twisted to avoid external electromagnetic interference. When voltage under 0.3V on a wire is considered low, and voltage over 2.8V is high. It also works in Asynchronous mode , so no needs for clock wires

No alt text provided for this image


Most usb cables have different ends to avoid confusion between the host and device

USB Data transfer types

- Interrupt transfer ex. keyboard or mouse

- Bulk (large amount of data at one time ex. Printers )

- Control (host sends commands to confg something )

- Isochronous (by time critical devices ex. Speekers and video camera)

Bus topology

It's Tiered star , a hub is the center of each star The maximum devices that could be connected to host is 127 devices , because each USB has 7 bit for addressing , address 0 is reserved for not enumerated devices

The maximum cable length is 5m , The maximum of hubs could connected in series is 5

No alt text provided for this image

Physical layer flow

No alt text provided for this image

First thing we do to the data we want to transfer is Bit stuffing , A bit stuffing is inserting a '0' after each 6 sequential '1' in data bits

No alt text provided for this image


Then Non-return-to-zero inverted (NRZI) is used to encode a sequence of binary bits. Data are transmitted via the D+ and D- wires using differential signals. One of them must be high, and the other must be low. For example, for a full-speed connection, the wires are either in the "J" state (D+ = high and D- = low) or the "K" state (D+ = low and D- = high). When no data is transferred (i.e. , idle state), the wires are in the J state. The states for low-speed are the opposite of the states for full-speed.

No alt text provided for this image

A binary 0 is represented by switching from the J state to the K state or from the K state to the J state (also called change-on-zero), simply when 0 is exist the data inverted till next 0 .

USB modes

No alt text provided for this image


The USB speed is determined by pulling up the D+ or D- wire.

• When neither of them is pulled up, the host assumes no devices are connected.

• If the D+ wire is pulled up via a 1.5KO resistor to 3.3V, the host assumes a full speed USB device is connected.

• The same pull-up on the D- wire indicates a low-speed device.

• A high-speed USB device is identified by initially pulling up the D+ wire. The host attempts to send or receive packets at high speed. If the communication is successful, the host assumes the device operates at high speed, and the device should remove the pull-up afterward. If the communication fails, the host assumes the device runs at full speed.

______________________________________________

In next article we will talk about the USB device layer



To view or add a comment, sign in

More articles by Eslam Shahin

  • Interrupt Handling Techniques

    Hello all Today we will talk about Interrupt Handling techniques , 1 . Frist type is The Fixed Priority Interrupt…

    1 Comment
  • STM32 Start-up code explore

    If you an Embedded Software engineer, you should know what is start-up code and what it’s job It’s a .c or .

    2 Comments
  • Boot Sequence in ARM Cortex-M4

    what happens when you press the reset button? your main code does not start immediately as you think , lets know how…

    2 Comments

Others also viewed

Explore content categories