Editor’s Note: Silicon Labs’ Evan Shulz explains how to use the company’s CP2130 USB-to-SPI bridge controller to simplify and speed up implementation of a USB bus.
Currently, the most common method to enable communications between embedded applications and computers currently is the universal serial bus (USB), which is found on nearly every desktop computer, laptop computer, and tablet.
With the ubiquity of USB, embedded developers face the challenge of learning how to use the USB protocol and how to design it into their system. Unfortunately, the USB communications protocol is complex, and implementing a USB design using a general-purpose microcontroller (MCU) can be time-consuming and challenging. A handful of semiconductor vendors offer fixed-function communication bridges that are designed to simplify the addition of USB by eliminating the complexity associated with USB designs.
An example of this type of communication interface product is the Silicon Labs CP2130 USB-to-SPI bridge controller, which enables USB connectivity by interfacing through the serial peripheral interface (SPI) port on a general-purpose MCU. Figure 1 shows how a communication bridge interfaces with an embedded system. In addition to USB-to-SPI bridge devices, the following communication bridges supporting other interfaces are available:
- USB-to-UART, 2x UART, 4x UART
Embedded systems targeting USB communications can be divided into two categories: upgrading a legacy design to use USB or enhancing a new design by adding USB. For either category, even developers without USB expertise can follow three easy steps to quickly enable USB communications:
- Identify the desired communication peripheral on a host MCU
- Build a prototype using an evaluation kit and jumper wires
- Create a custom schematic and layout with a communication bridge
Additionally (to be discussed later), developers can create an application-customized part and driver.
Here’s a closer look at each specific step, with the pros and cons of several design choices along the way.
Step 1: Identify the target communication peripheral on the host MCU
Whether upgrading a legacy design or enhancing a new design, developers must identify the host MCU’s available communication peripheral(s). In the legacy design scenario, developers should look for any free peripherals on the host MCU. If there are none, the developer can use an addressable protocol such as SMBus/I2C. For new designs, developers can select a host MCU to match the desired communication protocol. For example, if SPI communication is the desired protocol, developers should select a host MCU that has an additional free SPI port. It is important to consider the maximum transfer rate requirements of the application when selecting a communication peripheral. If a large amount of data must be transferred at high speeds, SPI or UART are the best choices. If transfer speed is not important or multi-device bus connectivity with arbitration is important, SMBus/I2C is the best choice, only requiring two pins.
In addition to selecting the communication peripheral, it is also important to consider the various driver options that are available. The most user-friendly option is a Human Interface Device (HID)-class communication bridge that does not require a driver installation for use. Devices in the HID class use native drivers found on common operating systems. Simply plug the device into a USB port and begin using it. Other examples of driver options include virtual COM port (VCP) drivers, WinUSB/LibUSB drivers, and vendor-specific drivers. All of these options require a driver installation and can typically achieve higher throughput than HID-class products.
Step 2: Build a prototype using an evaluation kit and jumper wires
In the next step, the developer uses a communication bridge evaluation kit to build a prototype connecting the kit to a host MCU using jumper wires. The prototype is meant to verify communication between the two devices and serve as a starting point for the schematic. Generally, the evaluation board will be clearly labeled, which helps the developer determine where to connect jumper wires without having to consult documentation.
In the example shown in Figure 2 , we will connect a CP2130 USB-to-SPI evaluation board to a C8051F850 MCU card running SPI slave example code. A legacy design with SPI signal test points could be used in place of the C8051F850 MCU card in this example. In the figure below, the SPI header has been connected to the specific port pins of the MCU development board, which are connected to the internal SPI peripheral.
Now that the hardware is ready, you can begin to prepare your USB hostmachine by installing demonstration applications and a driver (ifnecessary). All required software can usually be found on themanufacturer’s website. This option is typically preferred, as it willinclude the most up-to-date software and documentation. The CP2130bridge device requires a driver installation before use and can use anevaluation application for USB communications, both of which areavailable in the CP2130 software package that comes with the evaluationkit. After finishing the installation, the evaluation application can beused to read and write SPI data to the C8051F850 MCU via USB. Now it’stime to run a few verification tests of reads and writes to verifyoperation.
Step 3: Create a custom schematic/layout with a communication bridge
Theprototype from Step 2 can help create the schematic for your finaldesign. First, locate the schematic for the communication bridgeevaluation kit. For the CP2130 USB-to-SPI bridge controller, thisschematic can be found in the CP2130-EK User Guide fromwww.silabs.com/USB-Bridge.
The evaluation kit schematic showswhich components are necessary for USB operation. It is important tomention that some communication bridges integrate functionality thateliminates external components, reduces BOM costs, and simplifies thedesign. Check to verify that your communication bridge supports thefollowing features:
- Crystal-less USB: Does the communication bridge support USB communications without requiring an external crystal?
- Internal 5V regulator: Can the bridge power the system through the USB connection without requiring external components, and what is the maximum output current? (This feature is primarily applicable to USB bus-powered applications.)
- In-system programming memory: Does the bridge device contain integrated programmable memory that allows customization via USB?
- Small package options: Smaller packages enable developers to create small, highly-portable solutions.
Selecting a communication bridge that includes these features will result in a simplified design.
Next,translate your prototype connections to schematic connections for theSPI signals (SCLK, MOSI, MISO, SS, GND) between the CP2130 device andhost MCU. Before proceeding to layout, send your schematic to the Silicon Labs’ support team for a complimentary review to verify that the device’s schematicconfiguration is correct. The support team will review the schematic andprovide recommendations if changes are needed. Now the board can besent to manufacturing.
If your product design requires a custom part and driver, please keep reading. If not, start communicating!
What if you want to create a custom part and driver?
Communicationbridges and drivers often come with vendor-specific standard USBdescriptors and strings right out of the box. The USB Vendor ID (VID),Product ID (PID) descriptors, and serial string are used by theoperating system to map drivers to connected devices. As a result, it ishighly recommended that the combination of descriptors and strings beunique to prevent errors when two devices with identical information areconnected to a system. Creating a custom driver and device enablesdevelopers to use product-specific strings and device descriptors. Figure 3 shows the default strings displayed in Windows when installing a non-customized CP2130 device.
Tosuccessfully customize a product, the communication bridge and theassociated driver (if applicable) must be updated. Communication bridgeshave corresponding graphical customization utilities that allowcustomization through the USB connection. Bridge manufacturers alsotypically provide a driver customization utility that can serve as astep-by-step guide to creating a custom driver. After customizing adevice, the device will not be able to communicate with the host systemunless the associated custom driver has also been installed on the host.
Other useful tips
Oncea driver has been customized in any way, an additional certificationstep may be required by operating system vendors. An example of this isMicrosoft’s Windows Hardware Quality Labs (WHQL) testing. Windows 7(x64) and Windows 8 (x64) will not allow an uncertified driver to beinstalled. Other Windows versions will allow installation, but willdisplay a warning message to the user. Application Note 220: USB Driver Customization provides instructions for creating a custom driver, and Application Note 807: Recertifying a Customized Windows HCK Driver Package provides instructions for recertifying a customized driver for Windows.
Forproduction quantities of customized communication bridges,manufacturers can provide pre-programmed devices for use in end systemsthat do not require the graphical customization utility.
Beforeshipping your product to customers, remember to include a USB cable, aswell as a flash drive, CD/DVD, or web address for the custom driver.
Additional benefits and closing thoughts
Althoughthe primary goal of this three-step approach is to easily enable USBcommunication in embedded systems, these bridge devices also have GPIOpins with additional special functions that can integrate functionality,eliminate external components, and further reduce BOM cost. Examples ofthese special functions include:
- USB suspend indicators
- Clock output
- Toggle LED on data traffic
- Count pulses or edges
- Remote wake
Inevaluating your USB bridge chip options, look for a semiconductorvendor that offers a comprehensive portfolio of bridge solutions thatsupport all major communication interfaces. Be sure that thefixed-function communication bridge you choose includes such features ascrystal-less USB operation, an internal voltage regulator, in-systemprogramming memory, and small-footprint package options. Selecting theright bridge chip for your next embedded application ultimately can saveyou considerable development effort and expense and help speed yourdesign to market.
Table 1 compares the features of nearly a dozen Silicon Labs bridge products that use the most common communication interfaces.
Evan Schulz is a microcontroller product manager at Silicon Labs, focusing on thecompany’s 8-bit MCU and Smart Interface USB Bridge portfolios.Previously serving as an applications engineer in the company’s MCUgroup, Mr. Schulz joined Silicon Labs in 2008 as an associateapplications engineer. He holds a bachelor’s degree in ElectricalEngineering from The University of Texas at Austin.