SPI and Microwire buses offer a popular and convenient means for minimizing the number of interconnect wires required in connecting smart peripherals to a microcontroller. These standard synchronous buses comprise a serial-clock, data-in, and data-out line in addition to a chip-select line for each peripheral.
One chip select per device, however, can quickly use up the precious port pins in a microprocessor system. To ease this situation, the dual fourchannel analog multiplexer (an SPI device itself) multiplexes a single port pin (PC0) to provide chip selects for four other SPI peripherals in the system (see the figure). A second port pin (PC1) selects the multiplexer.
All switches in this multiplexer are bidirectional. Its two sections are independent, and either output (unlike those of conventional differential multiplexers) can be programmed to connect to any, all, or none of its four input channels. Thus, the second (top) section is employed, independently of the lower section, to expand the number of analog channels available to the microcontroller. The microcontroller’s internal multiplexer supports eight channels, so this scheme (using one to get four more) yields a total of 11 input channels.
By operating “backwards,” the lower 4:1 multiplexer routes the PC0 signal to a selected peripheral’s —CS input. Driving PC0 low selects that peripheral for receiving SPI data, and driving PC0 high de-selects all four peripherals. Read and write sequences are the same as in regular SPI systems, except that the chip selects must be set up beforehand. PC0 then goes low, the read/write operation is executed, and PC0 returns high to de-select the device.
This procedure isn’t burdensome in practice. Typical SPI systems include a device that’s serviced often (such as a display driver), and several others that require service only occasionally (such as EEPROMs or real-time clocks). Thus, the chip-select multiplexer can leave the heavily used device selected most of the time, and perform an update only when selecting a new device.
To accommodate other combinations of chip-select and analog expansion lines, you can replace the MAX350 with a similar device (the MAX395), whose eight serially-addressed SPST switches can be configured as required.