Making informed USB host design decisions eases implementation
BY KIM OTTEN
Microchip Technology
Chandler, AZ
http://www.microchip.com
USB has become the standard way for devices to communicate with a PC. From general-purpose devices, such as flash drives and mice, to special-purpose devices for specific applications, this standard has almost totally replaced other serial communication protocols.
USB peripheral devices cannot communicate with each other. They may only communicate with a USB Host, which controls the bus. Until recently, only PCs could act as the host. USB Embedded Host capability is now available on microcontrollers, allowing embedded applications to use the wide variety of USB peripheral devices.
The USB flash drive is one key USB peripheral device, providing inexpensive media for transferring or storing large amounts of data. Various datalogging applications are particularly conducive to this type of arrangement. Long-term data can be gathered at a remote location and stored on a flash drive, which can be brought back to a more convenient location for analysis.
Flash drives can also be used for transferring high-speed time-dependent data to a PC. While PCs are excellent data-analysis tools, their real-time capability is limited. An embedded application is great for real-time data capture, but is often limited in its analysis capabilities. An embedded real-time datalogger can store data on a flash drive, and then transfer the data to a PC for analysis, combining the strengths of both.
A USB Embedded Host app
One of the first tasks of a new embedded design is to select the microcontroller. To use a flash drive, the MCU must have USB Embedded Host capability. If an MCU, such as the Microchip PIC24FJ256GB1, supports USB On-The-Go (OTG) or USB Dual Role functionality, it will also support USB Embedded Host functionality. USB Peripheral capability alone, sometimes referred to as USB Device Mode, is not sufficient; this would allow an application to be a flash drive, not to communicate with one.
Next, a designer should be sure that a full line of development tools is available. At a minimum, you will need a device programmer (preferably a debugger) and a C compiler, as USB Embedded Host applications and the microcontrollers that run them tend to be programmed in C rather than assembly language.
Fig. 1. Microcontrollers with USB Embedded Host functionality, such as the PIC24FJ256GB1, enable embedded applications to communicate with flash drives.
Finally, the designer should determine what software libraries are available, as a range of USB, FAT32, and other libraries are required to make an application talk to a flash drive. Implementing USB Embedded Host support from the ground up requires several months, while a certified stack solution will save countless hours.
To use a flash drive, the application will also require a Mass Storage Class client driver, a hardware command interface, and a file system interface. Typically, flash drives with 2 Gbytes or less of memory use the FAT16 file system, while larger drives require the FAT32 file system.
Fig. 2. Layers of a USB Embedded Host application using a flash drive.
Design requirements
Once the MCU has been selected, the hardware design begins. There are a few requirements to keep in mind when designing USB hardware (for details see www.microchip.com/USB):
1. If an Embedded Host supports a class, it must support a 500-mA load.
2. If an Embedded Host supports any device that requires more than 100 mA, it must support 500 mA.
3. If an Embedded Host supports 100 mA or less of current, then the VBUS voltage limits are reduced to 4.4 V. However, if an Embedded Host supports any device that requires more than 100 mA, then the VBUS voltage limit is 4.75 V, just like a full host.
4. There must be resettable overcurrent protection that resets without user intervention.
5. The USB connector must be within 8 ns of propagation delay from the transceiver (~50 in., depending on the layout).
6. USB Embedded Host devices must have greater than 120 µF on VBUS , whereas USB OTG devices must have 1.0 to 6.8 µF on VBUS .
Give careful consideration to the user interface of any application that uses USB Embedded Host capability. USB peripherals are typically used with PCs, which provide verbose error messages in case of failure. Users have come to expect this and will be frustrated if the only sign of an error is a blinking LED. The USB specification mandates that certified USB Embedded Hosts can have no silent failures. In other words, the application layer must be explicitly informed of all failures and the nature of those failures. Therefore, that information is available for presentation to the user.
USB certification
USB certification is a guarantee that a product meets the USB specification. Certification is performed by various independent test houses for a negotiated fee.
Once a product passes certification, the manufacturer is granted the right to use the USB logo. There are additional licensing requirements for using the USB logo. (Refer to the USB Implementers Forum at www.usb.org/developers/logo_license.)
A product can be manufactured and sold without passing USB certification. Without USB certification, a manufacturer can state that the device supports USB, but it cannot use the USB logos (neither the USB trident nor any “Certified USB” version) anywhere on the device or its packaging. In general, certification of USB Embedded Hosts is not too difficult.
Communicating via USB
One of the most challenging aspects of implementing a USB Embedded Host is communicating with the wide variety of USB peripherals. Although flash drives are not always certified, users will not be happy if one flash drive functions correctly, but another fails for no apparent reason.
It will not matter if it is due to the flash drive requiring two and a half times the maximum allowed time to power up, or because the flash drive locks up if the host polls at the maximum allowed rate, or because the flash drive requires a different sequence of SCSI commands to establish communications. Customers will blame your equipment, especially because, “the flash drive works when I plug it into a PC.” So be sure to extensively test your application with any target peripheral that is typically not certified, even if it is “just” a thumb drive or a cable.
Although USB Embedded Hosts can provide class-level support, you may want to seriously consider limiting support to specific peripherals, identified by VID and PID (Vendor ID/Product ID), to ensure that your application functions in the field exactly as you designed and tested it. This list, referred to by the USB Implementers Forum as a Targeted Peripheral List (TPL), must be submitted along with checklists to achieve Embedded Host certification. Full OTG certification actually requires that interoperability be restricted only to the specific, VID/PID-identified products on the TPL. ■
Advertisement
Learn more about Microchip Technology