While USB came from the PC world, it is not just a PC phenomenon. Cell phones, cameras, recorders, players, display devices, tuners, and more all use USB connectivity, either as a peripheral, or even as a host. Even picture frames have USB ports.
Additionally, USB is not just for average consumers. Commercial, industrial, automotive, and even military systems take advantage of USB because of its flexibility, small size, high data rates, and ease of use, especially in commercial off-the-shelf (COTS) systems.
As embedded systems designers, we see this ubiquitous technology creep into our own worlds. Take, for example, modern day data loggers, oscilloscopes, logic analyzers, waveform recorders, meters, spectrum analyzers, diagnostic equipment, and more. Especially when it comes to embedded systems development, USB connectivity allows re-flashing, emulation, and access to JTAG directly through our compilers and debuggers. Does anyone remember the large, delicate, and intrusive in-circuit emulators (ICE) of the past?
This article describes options available to embedded systems designers for adding USB functionality. It examines architectural approaches and key factors when deciding how and to what level to implement USB. All parts, development kits, and training modules referenced here are available from Hotenda.
Do what you do best
Many companies have core competencies that make them special – a unique algorithm, a patented solution, or a proprietary architecture. Their engineers are experts in their disciplines, though they may not have the time or bandwidth to become experts in every standard, especially when those standards are constantly being updated, changed, and superseded by later versions.
This can also be the case with USB. The specifications are long and intricate, and being aware of all the subtleties is a full-time job. This is where encapsulated expertise in a higher-level form comes in to play.
Device makers are often the experts as to what is in a standard specification and what is to come. They are the ones on the standards committees and are often steering the standards. They are the ones who will be responsible for their parts conformance to the standards so that you will not have to worry about every little detail.
Yes, packaged solutions may cost a little more, but they enable your design to get to market quicker. Also, as the standards update, so will the parts. It is the chipmaker’s responsibility to stay current, and both their survival and yours is at stake.
That being said, there are two major approaches to supporting USB in your embedded design. One involves using a dedicated USB chip that handles all the USB interactions and acts as a transparent data port to your embedded microcontroller. The other approach involves implementing the USB protocol on your embedded micro and in your firmware. We will explore both options.
The simplest approach
Not every embedded systems design runs at blazing speeds and uses multi-million transistor processors. As a matter of fact, more 8-bit processors are still sold than all the 16- and 32-bit processors combined. Simple applications such as kitchen appliances have relatively simple displays and perform relatively simple functions. Unless you are designing an AI-based “Talky Toaster”, an 8-bit processor has more than enough horsepower.
While USB connectivity may seem silly for a toaster, there are 8-bit applications that will want PC connectivity, and since COM ports of the past have yielded to USB, a USB link will be needed. Fortunately the COM port has not disappeared in the world of the microcontroller. As a matter of fact, despite the popularity of I²C, SPI, and CAN, a typical microcontroller has more UART-style COM ports now than ever before.
You would need to re-spin (and possible re-certify) new PC boards to add USB functionality to a legacy design that uses a standard UART-based COM port – that is, if it were not for the family of DB9-based USB conversion modules from Future Technology Devices International (FTDI) (see Figure 1). Available as male or female (DTE or DCE) interfaces, these USB-to-RS-232 conversion devices replace the DB-pin side of the connector with a USB MINI-B receptacle.
Figure 1: The complete USB-to-RS-232 conversion takes place within the DB9-style RS-232 connector.
Since they emulate a standard DB9 connector on the PCB side, the FTDI chips drop right in, requiring no PCB redesign. Additionally, they emulate a COM port, so the FTDI free driver is needed to either allow software to use standard COM port calls over USB or to allow application software to connect through an API.
There are a couple of things to keep in mind with this approach. RS-232 levels can transit hundreds of feet on low-cost cabling; USB cannot. If equipment needs to be far away from the driving host, then a converter board or cable would be a better choice, since it allows the longer distance RS-232 signals to do the heavy lifting. Note that RS-232 cabling may not allow the target board to be USB powered as if it were a pure USB link.
This approach works very well for keeping older designs alive, but it may not be the technique of choice for new designs. First, the DB9 connector is much larger than the USB connectors and may impose too many size constraints. Second, as previously eluded to, the RS-232 signal levels are not logic levels. Instead, RS-232 uses non-to-zero (NRZ) signaling which can swing as high as +15 volts to –15 volts. This will destroy standard logic chips, so a level shifter will be needed to safely interface to a target microcontroller.
To eliminate the level shifter on new boards, several USB to UART converters exist. A nice compact solution comes from Exar Corporation with its small 16-pin QFN XR21V1410IL16-F USB- to-UART chips. These featured parts support the 12 Mbit/sec high-speed rate of USB 2.0 and are aimed at half-duplex and RS-485 type multi-drop applications. Details of the part’s functionality are discussed in Exar’s UART product overview. The company also offers larger parts with more channels.
Microchip Technology provides USB to UART functionality with their featured MCP2200-I/SS. The two-pin parts also support the 12 Mbit/sec data rates and use standard virtual Com Port drivers for Windows® applications. These bus- or self-powered parts support UART data rates up to 1 Mbit/sec and can use hardware flow control. On-chip 256 bytes of EEPROM allow storage of configuration data. These parts work at 5 and 3.3 volts.
A well-engineered solution comes from Silicon Labs with parts like the CP2110-F01-GM USB-to-UART bridge. Supporting a 12 Mbit/sec data rate, hardware flow control, general purpose I/O, and on-chip regulators, these parts also have a 343-byte block of one-time programmable (OTP) memory. This is useful for serial number, unique addressing, and part number revision information for automatic software version tracking. A training module describes how to design using these parts as well as the features and benefits.
FTDI offers a popular line of USB-to-UART converters, featuring parts with up to four UARTs. For example, the 64-pin QFN FT4232HQ-REEL houses four separate UARTs and achieves the full data rate of 480 Mbits/sec that USB 2.0 can support. The multi-function UARTs can not only operate as UARTs, but also emulate JTAG, SPI, I²C, and other bit-banged serial protocols. The auto-transmit feature supports half-duplex-style 485 emulation. An online training overview provides a helpful introduction.
Several factors make this a part to consider when designing a sophisticated USB-based project. First is the achievable data rate. Most designs function adequately with the 12 Mbit/sec high-speed modes of USB 2.0, where implementing a full 480 Mbit/sec link would be overkill. However, high-end applications such as high-bandwidth instrumentation, high-end video, multimedia, and medical devices may require the higher data rates.
Also, the ability to have multiple UARTs and serial ports on the equipment end opens the door for non-intrusive control over design elements. For example, while a high-end microcontroller is screaming away doing a real-time and intensive application, other chips on the board can be manipulated without interrupting the host. This includes analog control and biasing elements for self- and auto-calibration, parameter updates in NVRAM, updating digital I/O states for control and LED status, and independent monitoring of pushbuttons.
USB-to-UART converter chips are very specific with their functionality, so several design and evaluation modules are available to test them out quickly and easily for prototyping purposes. An example is the DLP Design Inc. family of USB evaluation modules based around both FTDI parts as well as FPGA implementations.
It’s in there
Higher end microcontrollers have the hardware for USB built in. Like any other on-chip peripheral, I/O pins are dedicated to the USB differential data lines and special registers are used to enable and control these functions.
Like all peripherals, different levels of performance and functionality exist from vendor to vendor and even part to part. On the high-end are parts like STMicroelectronics’ ARM11™ processor-based Cartesio™ STA2064N, a high performance 533 MHz ‘infotainment application processor’ with embedded GPS. The combined on-chip low-power ARM11™, TFT controller, GPS, USB, USB OTG, Bluetooth, and audio make this a part to consider for high-end functionality in a small and low-power part (see Figure 2).
Figure 2: The Cartesio devices are high-end ARM11™ processor-based engines with many advanced and high speed and data intensive peripherals like full-speed USB 2.0, TFT control, GPS, streaming audio, Bluetooth, and more. (Courtesy STMicroelectronics)
The Fujitsu Semiconductor America MB86R01PB-GSE1 is a high performance ARM9™ with TFT control, USB, HDD, and LAN functionality to name a few features. The on-chip dynamically switchable host- and peripheral-side USB 2.0 high-speed (HS) and full-speed (FS) interfaces enable this part to take the full-speed of a USB connected link. It also features a full contingent of communications and video capture capabilities, A/D’s, and a graphics display controller with built-in 2D and 3D rendering engines. The bus architecture and the selection of peripherals in each bus group are interesting (see Figure 3).
Figure 3: The MB86R01PB also can handle the full-speed USB 2.0 data rates and is a versatile collection of resources and high performance peripherals, including 2D and 3D graphics rendering engines (Courtesy of Fujitsu Semiconductor America).
Similar high-performance parts are also available from Cortina Systems, Texas Instruments, and Micrel Inc. to name a few.
General purpose versus application specific
It is hard to draw the line as to what is application specific and what is general purpose. We are the ones that take our resources and use them to achieve our goals. Someone’s arbitrary assignment of the term ‘application specific’ may not apply because a totally different application may require the same resources and features. If a stock part fits your design perfectly, does that make it application specific?
Many complex stock processors are available for your designs. Take, for example, the NXP Semiconductors LPC11U24FHI33/301. This 50 MHz ARM® Cortex™-M0-based processor includes 10-bit A/D converters; I²C; I2S; 54 I/Os; UARTs and USARTs; and EEPROM, as well as a USB 2.0 interface.
Even a well-targeted part like AKM Semiconductor, Inc.’s AK5371A has peripherals and resources that make it effective outside its application specific target (see Figure 4). It is clearly aimed at audio applications with its standard audio frequency PLL sample-rate controller; programmable gain amplifier; and dual channel 16-bit A/D controller with mute and volume control. However, instrumentation, data acquisition, and medical designs can take advantage of this mix of features very well. So is it really an ASIC?
Figure 4: Even though the AK5371A specifically targets audio recording applications, it is well- suited for many types of data acquisition and waveform recording application such as data logging and medical applications (Courtesy of AKM Semiconductor, Inc.).
The point is, don’t discount parts that are touted as being application specific for your designs. Look at the mix of peripherals and resources instead and you will have more viable choices.
Stacked in your favor
The biggest benefit of a vendor-supplied design solution for USB is the IP they make available. Often times well documented APIs and reference programs are free or very low cost to users of the chips. They are in the business of selling silicon, not software, so to entice you to use their chips, they offer free reference software.
The availability of free software can enable you to lower system costs and achieve relatively quick time-to-market because you can just cut and paste the software into your application. This also puts the burden of support for adherence to USB standards on the backs of the chip suppliers.
Note that source code is not always provided by the chipmakers, just the binary and API documentation. Check to see if the level of control and functional granularity suits your needs before committing to a silicon solution.
If third-party solutions are bundled by a chipmaker, check to see whether the chipmaker licensed or purchased their software IP. If licensed, is the price per design, per company, per product, or per application? You don’t want to pay multiple times for the same block of code used in different iterations of a product.
Also, since USB is a standard communications link, most chipmakers’ development systems provide intrinsic support. This means that you do not need a specific USB development kit, per se. Instead, several chipmakers’ design environments support USB development in some way. Since the interface is on many of the chips, it is brought out to connectors on the boards, and the firmware is documented and supported by the chip makers as well.
Around the corner
The success of USB 1.1 and USB 2.0 is paving the way for the newer USB 3.0 flavors soon to invade our lives. While still too early to see it in action, the new USB standard will use 8b/10b encoding, the same approach some of the higher-end fiber telecom systems are using. USB 3.0 also raises the data rate to the envelope limit of 5 Gbits/sec. This is a greater than ten times improvement over the present 480 Mbits/sec that most applications still do not use, even today.
The need for bigger files, more interaction, and higher resolutions have created a need for USB 3.0, and the new capabilities made possible by these rates is sure to emerge.
Keep an eye on companies like Intel, AMD, Cypress Semiconductor, and Texas Instruments, among others, who have already committed to supporting USB 3.0. Some USB 3.0 compatible chips are beginning to emerge, but it may be a little while until support and the knowledge base is built up and the “killer applications” start to appear. In the meantime, there are still many uses for today’s and tomorrow’s USB 2.0 compatible devices.