Is there a difference between Hi-Speed USB and USB 2.0? Which is the correct nomenclature?
There is a difference between the terms Hi-Speed USB and USB 2.0. USB 2.0 is the specification, while "Hi-Speed USB" refers to just the 480 Mbps portion of the USB 2.0 specification. A device can still be USB 2.0 compliant and be full speed or low speed.
How fast can a USB device communicate with a computer using USB?
What is a USB host?
The host is the root of the USB tiered star network. It controls the bus and initiates communication. The USB protocol mandates a single host in any USB system.
I have heard the terms USB device, peripheral and function. What are the differences and what is the correct usage of terms?
In general, a USB peripheral or device is something that connects to the USB host and uses some USB function such as data transfer or power transfer. Note that a “function” is some action enabled by the USB specification, such as Hi-Speed data transfer. Examples of devices and peripherals are physical items such as keyboards, storage devices, or portable electronics like mobile phones or portable game consoles. A USB hub is both a device and peripheral to the host.
How many devices can be connected to one host?
Each host controller can support up to 127 devices. A host may contain multiple host controllers. The presence of root hubs and/or compound devices may change the total number of available physical devices, based on their implementation. Hubs also count as a device on the bus, so each hub will also reduce the number of available USB device/peripheral slots.
Who owns and controls the USB specification?
The USB Implementers Forum. also known as USB-IF, owns the USB specification. You can download latest specification for USB for free from their website, www.usb.org.
How is data transferred in the USB protocol?
The USB Specification defines four different types of data transfers:
The USB host sends commands and queries to a USB device using a control transfer. The control transfer uses endpoint 0 (EP0) while the USB device is being enumerated. Therefore, it is mandatory that all USB devices support EP0 regardless of the supported speed. The maximum size for a control packet is 8 bytes for low-speed devices; 64 bytes for full-speed devices; and 16, 32 or 64 bytes for high-speed devices.
Interrupt transfers enable a USB device to request a polling rate from the USB host during the enumeration process. The maximum polling rate for a full-speed device is once per millisecond and once per every 10 milliseconds on low-speed devices. The maximum data payload size for a low-speed USB device is 8 bytes with a maximum throughput of 800 bps. For a full-speed USB device, the maximum payload size is 64 bytes with a maximum throughput of 64 Kbps. Interrupt transfers are acknowledged so they guarantee the delivery of a packet. If a packet fails to arrive, the transfer is tried again.
Bulk transfers are a way for devices to transfer large amounts of data. Because they have the lowest priority when being scheduled on the bus, they do not guarantee a timely delivery. After all other transfers are complete, the remaining bandwidth is given to bulk transfers. Just like interrupt transfers, bulk transfers are acknowledged to guarantee their delivery. Bulk transfers are only supported by full-speed and high-speed devices. For full-speed USB device endpoints, the maximum packet size can either be 8, 16, 32 or 64 bytes long. For high-speed USB device endpoints, the maximum packet size can be up to 512 bytes long.
A full-speed isochronous transaction can send 1023 bytes per frame at a maximum transfer rate of 1023 Kbps. While isochronous transfers offer a guaranteed data transfer rate, their delivery is not acknowledged, and some packets may not arrive. Audio/video streaming is a typical application for isochronous transfers because it is more important to keep the video and audio up to date at the expense of dropping packets.
What is a token packet?
The USB protocol defines four types of packets:
There are three different types of token packets:
How does the USB protocol detect an error in communication?
The USB protocol uses the Serial Interface Engine (SIE) to perform a Cyclic Redundancy Check (CRC) to detect errors. This eliminates the need to implement CRC in software, reducing software overhead. Token packets have a 5-bit CRC and data packets have a 16-bit CRC.
What happens if the SIE receives corrupted data?
The SIE discards the corrupt packet if the packet fails the CRC check without requiring any software intervention. An error flag is set indicating that a corrupted packet was received. The SIE will not acknowledge (ACK) packets that have incorrect CRC values. For interrupt, bulk, and control transfers, the host will try to retransmit the packet if it fails to receive the ACK. This means that these transmissions will not lose data due to a corrupted packet, but they may encounter lower application bandwidth.
What is difference between transfer and transaction in the USB protocol?
Transfers are groups of transactions, and transactions are groups of packets.
What is the largest data packet that I can send?
This depends on the type of transfer you use. Interrupt and bulk transfers have a maximum payload size of 64 bytes for full-speed USB devices. Isochronous transfers can send up to 1023 bytes for full-speed USB devices.
What is the enumeration process?
This is how a USB host learns about a USB device that has just been connected to the bus. Before the application can start running, the host queries the device for information to determine what type of device has been connected, what device driver it needs to load for the device, what power requirements the device has and other details. During the enumeration process, the USB host also assigns an address to the connected device. After the address is set, the USB host will communicate to the device at that address from that point forward. One of the final enumeration tasks is to set the device into a specific operational configuration. A detailed description of the enumeration process is given in Section 9.1.2 of the USB specification.
How does the USB host identify the speed of a USB device?
The USB host has weak pull-down resistors on both the communication lines (D+ and D-). A device will pull up D+ with a stronger pull-up resistor if it is going to run in full-speed mode. If a device is going to run in low-speed mode, then D- is pulled up instead. The value of the pull-up resistor in each case is nominally 1K5.
How does the USB host reset the USB device?
The USB host sends a reset to the device by setting D+ and D– low for at least 10 milliseconds. A USB device determines that a reset has occurred if it sees that D+ and D- are low for more than 2.5 microseconds. After the USB device detects the reset, it goes into default state as soon as the USB host removes the reset. This resets the USB device only and does not reset the controller.
If the USB host issues a reset command for a specific USB device, will it also reset other connected USB devices?
No. The USB host will request that a hub reset the specific connected USB device, and only that device will be reset. If the USB host resets the hub itself, then all the devices attached to the hub will be reset.
How does the USB host find out the name of a connected USB device?
There are several strings located in the device descriptor of the USB device, one of which is the manufacturer string. These strings, if implemented, can be read by the USB host during the enumeration process.
Can there be contention when two USB devices are connected simultaneously to a USB host?
No. The host resets one device at a time and then completes the enumeration of one device before it starts investigating the next device.
How does a USB hub slow down devices?
A USB hub must calculate the time left before the end of each frame. The small extra delay added by the hub will decrease the available bandwidth. If several devices are connected on the hub and working in parallel (for example, a webcam, a USB Flash drive and a mouse), then the USB bandwidth is shared among the devices.
What device classes are supported by Microchip’s MCUs?
Currently Microchip supports evaluation USB device versions of Human Interface Device (HID), Communication Device (CDC), Mass Storage Device (MSD) and Custom device classes. Examples of HIDs include keyboards, joysticks and computer mice. Examples of CDCs include modems and Ethernet adapters, Examples of MSDs include thumb drives and external hard disks. The Custom device class allows users to develop unique drivers for their devices. Please refer to the notes for the specific software release for more information about device class support.
What is the maximum cable length that can be used between two hubs or two USB devices?
The maximum length of a USB 2.0 cable is 5 meters. The USB 3.x specification does not specify a maximum cable length but there is a recommended length of 3 meters. The biggest limitation to the length of a USB 3.x cable is the quality of the cable. If you use a high-quality cable, you should be able to go beyond 3 meters. An active or repeater cable must be used if you need to go a longer distance.
What is difference between a composite USB device and a compound USB device?
A compound USB device has a built-in hub in addition to one or more USB peripheral devices, all consolidated into a single product with only one USB cable connecting it to the host.
A composite USB device does not use hub silicon. It uses more than one interface in a single peripheral device. Currently, our full-speed USB MCUs can be used to develop composite USB devices but not compound devices. A compound device can be built using our line of USB hubs.
What is the maximum capacitance across the VBUS pin of a USB device and why?
The maximum capacitance as seen by the VBUS pin of the USB connector must be less than 10 uF. This is to limit the inrush current that goes into the device when it is plugged into the device. The purpose of limiting the inrush current is to limit the drop in the VBUS voltage due to the charging of the capacitors on the newly attached device. Without limiting the inrush current of hot-plugged devices, a newly attached device may cause other devices to stop working.
If an application requires more capacitance than the specifcation allows, a soft-start circuit is required to limit the inrush current to the specified limits.
What care should be taken when a USB device is self-powered?
If the device is self-powered, an I/O pin must be used to detect a cable attachment. The D+ or D- line must not be pulled up until the USB host drives the VBUS high. A self-powered device must also consistently specify that it is self-powered. If the configuration descriptor says that it is self-powered, then any GET_STATUS requests to the device must also return self powered.
What should I specify in my configuration descriptor if I want my device to be either bus powered or self powered?
If the device is going to be bus powered at all, even if it is self-powered some of the time, then it must declare itself as a bus-powered device. The GET_STATUS request should accurately reflect to the host if the USB device is currently running on self power or bus power.
Why do I need an INF file while using the CDC class, even though I do not need anything on the PC side while using the HID class?
The CDC class has many other sub-class specifications. The host needs to know which of these device drivers to load for the attached device. This information is contained in the .INF file. This means that the host will need to run some type of installation/setup process when a new CDC device is attached for the first time.
What is the difference between a host, embedded host, limited host and mini-host?
Hosts are almost always referred to in a PC or laptop context, where any USB peripheral can be plugged into a USB port. A full host must source 500 mA of current on the VBUS to power the peripheral devices connected to it.
Embedded hosts are often called mini-hosts or limited hosts, but they all refer to the same type of devices. They are small-form-factor and portable devices like a set-top box or a cellphone. An embedded host must source a minimum 8 mA current on the VBUS. It has limited memory space to store drivers, thus the connectivity to the peripheral is also limited. Unlike a full host, the embedded host is not required to load device drivers for a device it does not support. However, the embedded host is required to notify the user that an unsupported device has been attached.
Note that the terms embedded host, mini-host and limited host are not referred to in the USB specification or the OTG supplement. The certification procedural walkthrough refers to these devices as embedded hosts.
Does Microchip supply all the stacks required for developing a complete thumb drive application?
Yes. Microchip provides the USB mass storage class drivers, the SCSI interface, the FAT16/32 format software, and an example file management application.
What are the device classes supported by Microchip MCUs?
Currently the embedded host stack supports the Mass Storage Device (MSD) and Custom device classes.
Can a high-speed peripheral, like a hard drive, be connected to a full-speed host?
Yes. The USB protocol requires all full-speed (12 Mbps) and high-speed (480 Mbps) communication to initiate as full speed and then scale up to high speed if both devices support it. If only one of the devices supports full speed, the communication will be limited to full speed.
Will any hard drive work with any host?
No. Hard drives are mass storage devices and, as such, have some form of data format provisions. For the devices to work, as opposed to just recognize each other, the file and interface protocols must also match. For example, a thumb drive is a basic mass storage application, but the USB class drivers, the SCSI interface and the FAT16 format must all be present for it to function.
Currently both the FAT16 and FAT32 file formats are supported in the USB embedded host firmware release versions.
If my device is an embedded host then does it need to support Session Request Protocol (SRP) and Host Negotiation Protocol (HNP)?
SRP is an optional feature for an embedded host, but it is not required and probably not desired in most cases. Since an embedded host is only capable of being a host and never a USB device, HNP should not be supported. See the USB On-The-Go section of this FAQ for more information about SRP and HNP.
What is USB On-The-Go (OTG) and why was it developed?
The USB OTG specification is an addendum to the original USB specification. It defines a way for portable devices, offering only one connector per device, to connect to supported USB products in addition to the PC. This allows mobile devices to connect to each other. One device will assume the role of an embedded host and the other will assume the role of a USB device, eliminating the need to have a PC for specific USB applications.
If I only want my device to connect to USB devices (peripherals), does it need to be a USB OTG product?
If a device only needs to connect to USB devices and never attach to another USB host, then the device can be an embedded host instead of a USB OTG product (please refer to the embedded host section above). If a device needs to connect to USB devices and USB hosts then it needs to be a USB OTG product.
Does USB OTG have to be in both products for them to connect and operate?
No, USB OTG products will connect to all PCs and will also have host functionality to connect to the specific USB peripherals it supports.
What is the Host Negotiation Protocol (HNP)?
USB OTG devices determine which device is the host and which device is the peripheral based on which end of the cable is attached to the device. If operation requires that the roles be switched, HNP provides a mechanism for switching that role without having to remove and switch ends of the cable.
What is the Session Request Protocol (SRP)?
Unlike other USB hosts, USB OTG devices can remove power from the VBUS line when they are not using it. The period when VBUS is powered is referred to as a session. SRP allows a device that is attached to a USB OTG product to request that a new session be started. After a device signals an SRP, the USB OTG product acting as the host will power up VBUS and start communicating with the device.
What happens when you plug two USB OTG devices together?
When two dual-role devices are connected via a cable, the cable sets a default host and default peripheral. If the application requires that the roles be reversed, then the HNP can provide a handshake that performs that function. If HNP is not supported in either device, then the cable may need to be reversed if a specific role is required.
What connectors are used for USB OTG?
Previously, USB OTG devices used a micro-A/B connector. This allowed either the A end or B end of a micro cable to be attached. Many devices can and will use the USB Type-C® connector, which supports many additional features via USB.
I want my product to be either an embedded host or a USB device (peripheral), but I don’t need/want to dynamically switch between the two. Is this possible and what connectors should I use?
Yes, this is possible.
One solution is to use the micro-A/B connector and program the device as a USB OTG device. Because SRP and HNP are optional, these features can be disabled. The limitation here is that USB devices with full-size A connectors will need an adapter to connect to the micro-A/B port on the device.
As an alternate solution, the device can have two USB connectors. Each will have to have its own separate circuitry for VBUS but share D+ and D-. The limitation to this solution is that the USB test specifications state that any connectors that are accessible to the user must all be functional at the same time. Since the current USB devices only support one USB port, it is not possible to have both connectors functional at the same time. This means that some sort of mechanical feature must be implemented so that only one of the two ports is accessible for use at any time.
This capability can also be implemented using the USB-C® connector. Two devices will negotiate the host-device relationship at startup. The cable will need to be disconnected and reconnected to force renegotiation of the status.
What is the device descriptor?
The device descriptor is data table that describes various information about the attached device, such as the Vender ID (VID) and Product ID (PID) of the manufacturer. The complete contents of the device descriptor can be found in Table 9-8 of the USB specification.
How can I acquire a VID and PID?
The USB-IF mandates that each vendor has its own unique VID in order to market its products. The VID is issued by the USB-IF after you pay the required fee. Go to the Getting a Vendor ID page on the USB-IF’s website to learn more about obtaining a VID.
After a VID has been purchased, the manufacturer determines how the PIDs are used within that VID.
There are possibly both legal and technical complications involved when using a VID/PID that is not unique.
Do I have to purchase my own VID or does Microchip sublicense their VID?
Microchip does have a sublicensing program for its VID. Please complete this form to apply for a PID with Microchip’s VID for your prototypes.
Do I need a new PID for each device that I produce?
A new PID is required for each product line produced. Each identical product in that product line should have the same PID. If each device in a product line requires a unique identifier, then the iSerialNumber field of the device descriptor can be used to uniquely identify each device.