SPI Output Driver Supplies Mixed Digital Inputs As Well As Transient Protection

Aug. 22, 2011
Serial Peripheral Interface (SPI) output driver chips are popular with embedded designers because they provide multiple outputs without using any CPU I/O pins. This article explains how to adapt a standard octal relay driver to provide a random I/O mix at its output pins.

Fig 1. An SPI-based output driver (in this case, an L9822 octal relay driver from STMicroelectronics) can be used to provide a random mix of I/O pins at the chip’s output. The circuit in (a) senses a high-side digital input, and the circuit in (b) shows the connection for a low-side digital input.

Fig 2. These flow charts show the programming for a high-side digital input (a) and a low-side digital input (b).

Serial Peripheral Interface (SPI) output driver chips are popular with embedded designers because they provide multiple (typically eight) outputs without using any CPU I/O pins. The chips accept output commands over the CPU’s SPI bus and pass on diagnostic information regarding output opens and shorts to supply or ground over SPI lines.

However, most applications require a random mix of inputs and outputs. So, a chip that provides such a random I/O mix that could be processed by the CPU over the SPI bus would be a boon for embedded designers. But most of the chips provide only outputs or inputs, not a random mix, forcing designers to live with many unused input and output pins.

This idea explains how to adapt a standard octal relay driver (the L9822 from STMicroelectronics) to provide a random I/O mix at its output pins, though designers can apply the concept to any equivalent chip. The scheme uses the chip’s “diagnostic status” feature, which identifies “load open circuit” as well as “short circuit to ground” faults and notifies the CPU over the SPI bus. This feature can be used to sense high-side digital inputs and low-side digital inputs.

Figure 1 illustrates the concept. In Figure 1a, an on-board pull-up resistor acts as the dummy load for the output pin, which needs to sense a high-side digital input. External switch S1 is connected between the dummy load and the output pin. To sense the status of S1, the output pin must be programmed at a high logic level (the output driver switch remains off). When S1 is ON, the diagnostic status shows an absence of a load open-circuit fault. When the switch is OFF, the diagnostic status indicates the presence of load open-circuit fault.

Figure 1b shows how to connect a low-side digital input (S2) to an output pin of the L9822. Again, the output pin is maintained off. If S2 is off, the diagnostic status will not indicate any fault. If S2 is on, the chip diagnostic status will indicate a short-to-ground fault.

Consequently, both high-side and low-side switches can be read as digital inputs using the chip’s output pins. Also, the inherent transient protection provided in the chip’s output circuit comes in handy for automotive applications. Designers of automotive systems need not worry about level shifting from 12 V to 5 V as required during conventional input interfacing to the CPU pins. Figure 2 shows the flow charts for the two versions.

A word of caution is needed before you apply this idea to high-current output chips (a few amperes). The pull-up resistor will have to drain considerable current, slightly above the open-circuit current threshold of such a chip. Typically, this may run into several tens of milliamps for a chip with, say, a 5-A current capacity. Such a large current drain may not be acceptable in many applications. This is not a problem for chips like the L9822, which are rated for driving a few hundred milliamps and thus can easily allow pull-ups draining a only a few milliamps. (Its open-circuit current threshold is 1 mA.)

Sponsored Recommendations

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!