Adding USB to your design in three easy steps
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.