I/O-Port Expanders Offer Flexibility in MCU-Based Designs
投稿人:电子产品
2011-11-02
A hallmark feature of microcontrollers (MCUs) since the inception of the technology is the integration of I/O ports on the IC. General purpose I/O serves a variety of functions, ranging from simple connection to switches and indicators to functioning as a trigger for mission-critical interrupt processing. However, with a trend toward smaller IC packages with fewer pins, sometimes you may come up short of the number of I/O ports you need in an application. I/O-port-expander ICs are a valuable tool in adding flexibility in MCU-based designs. Some of the ICs attach to integrated I/O lines. Others can be connected with serial interfaces such as Inter IC (I²C). There is probably a design that will meet your needs if you run short of I/O lines or need to distribute I/O in a system. Let's look at some typical expander ICs and the MCUs with which they can be used.
We will begin with a bit more discussion of why you might need an I/O port expander. There is always the simple solution of just choosing a different MCU that has more I/O ports, but that may not be the best option. You may realize a smaller-footprint, lower cost, and lower power design by combining a miniature MCU with a port expander IC. Moreover, most MCUs today assign multiple functions to many pins trying to minimize IC footprint. You may not be able to access an I/O that is integrated in an MCU because you need that pin for another peripheral. In some applications, you may need clusters of I/O located away from the MCU, near the physical interface with the real world.
One place where I/O expanders certainly come in handy is alongside very small MCUs that have few pins. For example, a number of Microchip 8-bit MCUs in the PIC12F family come in 8-pin packages. Specifically, we will discuss the PIC12F1822. The 8-pin MCU includes only six I/O lines, and most designs could not use all of those pins for general-purpose I/O given that pins are shared with other peripherals. The MCU also includes an A/D converter and two timers.
I²C and SPI expanders
The PIC12F1822 also includes a digital interface that can be used to support either an I²C or serial peripheral interface (SPI). Either can be used to connect with multiple off-chip peripherals including serial memory and additional I/O via I/O port expanders.
Microchip offers a number of expander ICs that can be used alongside the PIC12F1822. For example, the MCP23018 IC (Figure 1) is I²C based and includes 16 general-purpose I/O lines that can be seamlessly written and read as a 16-bit port. The serial link can transfer data as fast as 3.4 Mbits/s. That may not seem fast, but will prove sufficient for most I/O operations given that the CPU clock will run at 32 MHz or slower speeds.
Figure 1: The Microchip MCP32018 and MCP23S18 I/O port expander ICs use I²C and SPI interfaces, respectively, to add 16 general-purpose I/O ports to an MCU’s on-chip I/O allotment.
If you look closely at the block diagram in Figure 1, you will note a second option in dashed lines – the MCP23S18 that relies on SPI rather than I²C. The SPI link runs faster at 10 Mbits/s. There are other reasons you may choose either I²C or SPI and a big one may be the other peripherals that you need in your application and the serial standard supported by those peripherals.
Microchip offers other I/O expanders including 8-bit versions. The company also offers expanders that integrate additional peripherals such as additional data converters and timers.
Expansion via one I/O line
Let us move on and discuss a novel approach to expansion from Texas Instruments (TI) which utilizes a simpler interface. TI offers expander ICs that rely on I²C and the system management bus (SMBus), but the new TI TCA5405 relies on one MCU general-purpose I/O line to provide five I/O pins (Figure 2). Figure 2: Texas instruments developed a self-timed, single-wire (STSW) interface to allow engineers to add 5 I/O ports using a single MCU I/O to connect the expander.
The TCA5405 uses what TI calls a STSW (self-timed single wire) interface that requires a single wire and ground. By contrast, SPI requires three wires at a minimum and I²C requires wires, although two are reference voltage and ground.
The master MCU that connects to the TCA5405 must generate a master clock for the expander to sample during a setup period and then generate its own clock that is synchronized with the master. TI does not define a maximum data rate for the STSW interface, but the spec sheet defines a maximum input switching frequency for the TCA5405 of 10 kHz.
I/O port characteristics
There are many other characteristics of port expanders that might impact the product you choose for an application. For example, the TCA5405 relies on push-pull-type I/O. TI said that push-pull design allows the expander to drive LEDs in portable applications at currents below 20 mA.
Of course, the expander can only perform such a task if the supply voltage is greater than the forward voltage of the LED. TI specifies supply voltage in a range of 1.65 to 3.6 V, and a design that drives an LED would fall at the high end of that range.
The Microchip expanders discussed earlier use open-drain outputs. Such a configuration can be useful because ICs can often sink more current than they can source. Moreover, the MCU and I/O expander IC can both operate from a lower supply voltage than what may be required to power an external component. In the case of an LED, for example, an open-drain output could sink drive current through an LED that was pulled up to 5 V, even though the expander operated at lower voltage and delivered corresponding power savings.
Given that many IC makers supply a wide variety of I/O expanders, one final topic is whether you can use an MCU from one vendor and an expander IC from a second vendor. Generally the answer is yes. However, it could take some effort. For example, you would have to program an MCU from another vendor to provide the requisite timing for the TI STSW interface. Conversely, expect TI to support that interface in its tool libraries for many MCUs and perhaps even other DSPs or microprocessors. Expanders based on standards such as SPI should prove simpler to use across company lines.
Next time you face a mismatch between an MCU you desire to use and I/O requirements, make sure you consider an expander IC before simply choosing a larger MCU that may use more power and cost more. Moreover, see if distributing I/O makes more sense, given that with an expander you can locate the I/O at the physical interface. You may find the decidedly-simple expander a valuable part of your toolbox.
免责声明:各个作者和/或论坛参与者在本网站发表的观点、看法和意见不代表 DigiKey 的观点、看法和意见,也不代表 DigiKey 官方政策。