MCU Serial Interfaces Can Link a Broad Set of Peripherals

By Maury Wright

Contributed By Electronic Products

While engineers often think about a microcontroller (MCU) in terms of integrating the peripherals needed for the application at hand, there are many instances in which adding functionality external to the MCU is necessary. For example, you may need to place a sensor or actuator physically close to an external device, well away from the MCU. Or you may find that a lower-end MCU combined with some external peripherals offers the best combination of cost and system footprint for a given application. In any case, there's a growing roster of peripherals for MCUs based on interfaces such as I²C and SPI (Serial Peripheral Interface). This article will examine some typical peripherals, and how you might use them with popular MCUs.

Both I²C and SPI are widely supported on MCUs. In some cases you will have to choose one or the other because MCUs use the same on-chip resources to support either I²C or SPI. Moreover, you will need some software to handle the serial bus protocol, but virtually every MCU vendor has software support readily available.

I²C offers the advantages of using fewer signal lines and also fewer MCU pins. Most implementations have a single bidirectional data line and a clock line, supporting half-duplex communications. Typically, the MCU acts as a master that can connect to multiple slave devices, although some implementations do support the flexibility of having multiple masters on the bus. The master targets a specific slave device with address bits at the beginning of a transmission, eliminating the need for dedicated slave-select signals.

The SPI bus typically requires a minimum of three to four wires. SPI uses separate date lines for full duplex communications. Moreover, it uses dedicated, slave-select signal lines so if you have a system with a number of SPI peripherals you can easily exhaust the I/O ports on your MCU using them as select signals.

SPI is generally higher in performance, both based on higher data transmission speeds and full duplex communications. You will find SPI clock rates in the 20 to 40-MHz range. Most I²C implementations have been in the 10 to 100-kbit/s range, although some implementations operate much faster with the latest MCUs.

Motivation and features

Now let's discuss some reasons why you might want to use peripherals connected to an MCU by a serial interface and the type of functions available. Data converters provide a prime example of the type of peripheral you might use. And one reason that you may consider an external converter is that you may need more precision than offered by the converter integrated on your chosen MCU.

Consider some converters from Linear Technology. The company offers I²C A/D converters, I²C D/A converters, SPI A/D converters, and SPI D/A converters. Moreover, all are available with much higher precision than you will find in converters integrated on a typical MCU. Consider, for example, the relatively new Renesas RL78 MCU family, the company's top-of-the-line offering in 16-bit MCUs. Most of the family members available thus far offer an 8-bit A/D converter, while some do offer 10-bit converters. The discrete Linear Technology A/D converters, by comparison, range from 8 to 24 bits in precision, and the D/A converters range from 8 to 18 bits in precision. Even in an 8- or 16-bit system you could easily have a single sensor that required the higher precision.

Consider one specific product example – the LTC2451 16-bit A/D converter. The I²C-based device is depicted in Figure 1. The converter relies on a delta-sigma modulator as a converter core and can perform 30 or 60 conversions per second. The 16-bit converter delivers full-scale error of 4 least significant bits, and settles in one sample conversion time for multiplexed operations. Moreover, the device is very small, measuring 2 x 3 mm, and comes in an 8-pin SOT-23 package.

Linear Technology 8-pin LTC2451 A/D converter

Figure 1: The 8-pin LTC2451 A/D converter from Linear Technology provides 16-bit precision and connects to MCUs over the I²C serial interconnect.

Small system footprint

External peripherals can also offer a way to achieve a minimum system footprint. That may seem counterintuitive since we generally think about integrated peripherals as the road to miniaturization. But staying with data converters, let's discuss an example paring of an MCU and an A/D converter from Microchip.

Microchip offers a long list of I²C A/D converters along with D/A converters and SPI-based versions of both. Focusing on one specific example, the MCP3021 10-bit A/D converter is based on I²C and uses the successive approximation conversion topology. The miniature device comes in an SOT-23 package with only five pins, yet it offers better precision than those found in converters on many low-end MCUs.

You can also select 6- and 8-pin 8-bit MCUs from Microchip and other vendors. For example, the Microchip PIC10 MCU family includes a number of MCUs that come in 6-pin SOT-23 packages. The combination of the tiny MCU and equally-tiny data converter may prove smaller, and lower in cost, than an MCU that integrates a converter that matches your application requirements.

Peripheral flexibility

What other type of peripherals can you add to an MCU-based design via a serial interface? The list is long. One simple example is an I/O port expander. Many low-end MCUs are pin constrained. Moreover, even when you have an MCU with plenty of I/O, you may find a need to locate some I/O pins physically away from the MCU – near a sensor for example.

NXP Semiconductors offers the PCA9502 I/O port expander that can operate with SPI or I²C masters. The IC provides 8 I/O lines. Moreover, it's very compact, measuring 4.1 x 4.1 mm, and comes in an SOT616 package. NXP also offers the SC16IS740/50/60 UART that allows you to add a serial interface capable of 5-Mbit/s rates to a design. The SC16IS750 and SC16IS760 variants include an 8-bit I/O expander as well.

Still, the more useful peripherals may be those with application-specific capabilities. For example, Microchip offers a broad range of I²C digital potentiometers. You might use the product in combination with a thermistor in a temperature-sensing application. Figure 2 depicts an example where the Microchip MPC4018 potentiometer is used to calibrate a thermistor and account for the nonlinear operation of the thermistor.

Microchip serially connected digital potentiometer

Figure 2: A serially connected digital potentiometer from Microchip can serve in numerous applications, such as in calibrating a nonlinear thermistor in the circuit pictured here.

For more robust temperature-centric applications, Microchip also offers I²C-based temperature-sensor ICs. The MCP9808 digital temperature sensor, for example, offers ±0.5°C accuracy over a range of –20°C to 100°C. Moreover, the IC comes in a variety of 2 x 3-mm packages.

The range of serial peripherals extends all of the way to user-interface or human-machine-interface (HMI) applications. For example, Microchip offers the AR1000 touch screen controller (Figure 3) that is compatible with both SPI and I²C. The serial interface links the MCU to the controller. And the AR1000 connects to four-, five-, and eight-wire touchscreen sensors from multiple vendors (Figure 3). The IC delivers digital coordinates directly to the MCU over the serial interface.

Microchip AR1000 IC

Figure 3: The Microchip AR1000 IC links to touchscreen sensors for advanced HMI applications.

As you can see, serial interconnects offer considerable flexibility in MCU-based designs. In some cases, SPI and I²C may be purely useful as a way to implement a function that you just can't find integrated on an MCU. But don’t limit your consideration of the serial buses to such instances. Consider how external peripherals might impact the footprint, power consumption, and cost of your system. Moreover, make sure you aren't sacrificing fidelity with long signal runs between an on-chip peripheral and the real-world interface, where a local peripheral could add value in terms of fidelity. You may find that distributed peripherals deliver benefits such as small footprints and more accurate system specs.

Disclaimer: The opinions, beliefs, and viewpoints expressed by the various authors and/or forum participants on this website do not necessarily reflect the opinions, beliefs, and viewpoints of Digi-Key Electronics or official policies of Digi-Key Electronics.

About this author

Maury Wright

Maury Wright is an electronics engineer turned technology journalist and industry consultant with broad experience in technology areas ranging from microprocessors to digital media to wireless to power management. Wright worked at EDN Magazine for 22 years, serving as editor-in-chief and editorial director for five years. Wright also served as editor of EE Times' Digital Home and Power Management websites.

Currently, Wright is working as a consultant for a number of technology companies and writing under his own byline for the Intel Embedded Community website and for LEDs Magazine.

Wright has won numerous industry awards, including ASBPE national wards for EDN's 50th Anniversary Issue and a similar award for the EDN Prying Eyes department. Wright is an expert in the area of digital media and the connected home, having covered the wired and wireless service-provider and in-home networks extensively. This expertise extends from processors and ASSPs all the way up through the end application. Wright graduated from Auburn University in 1978 with a BSEE and a curriculum emphasis on digital design and development with early microprocessors.

About this publisher

Electronic Products

Electronic Products magazine and serves engineers and engineering managers responsible for designing electronic equipment and systems.