Electronic Design

Resistor Allows Multiplexing Of Microcontroller I/O Lines

Because of their small size, low cost, and advanced functionality, the PIC12CXXX family of microcontrollers developed by Microchip are an attractive design element for embeddedcontrol applications. Unfortunately, their restricted number of I/O lines (five bidirectional and one input-only) are sometimes not enough. A method of multiplexing the bidirectional lines using just a resistor is presented here.

There are two keys to this circuit: the isolation resistor (R1) and the software-programmable I/O functionality of the PIC microcontroller. The I/O pin can be programmed as either an input or as an output driving the pin high or low. To read the value of the switch S1, the I/O pin is confirmed as an input. Thus, the value of the switch is read easily. Ignoring the leakage current of the I/O pin and whatever the output is attached to, the voltage is given simply as a voltage divider:

The not-so-obvious part of this circuit occurs when the I/O pin is used as an output and the switch input is closed. Without R1, the value at the I/O pin (VA) would be ground. However, R1 provides isolation, allowing VA to be set by the I/O pin. To output a high voltage, the I/O pin must be able to source at least the output voltage/R1. At +5 V VCC, this is −5 mA, which is well under the 25 mA maximum per I/O for the 12CXXX device. To output a low, the I/O pin must be able to sink at least VCC/R2, in this case about 50 µA. This is well under the 25 mA maximum for the 12CXXX microcontroller family.

Switching an I/O pin from an input to an output, reading the I/O, and writing a value is extremely simple using Microchip’s reduced-instruction set. The code listing provides software snippets needed to accomplish these tasks.

With this multiplexing method, the output always overrides the input, allowing the output to be absolutely defined during critical times. This enables the I/O pin to perform as a data line in a synchronous communication scheme, or as a driver for an LED to provide a rudimentary user interface. And, at the same time, it implements non-timecritical input, such as a configuration switch or a request for service button.

For clarification, the figure shows R2 as an external pull-up resistor. However, the 12CXXX microcontrollers have internal pull-up resistors. This eliminates RZ as a discrete element in the circuit, further reducing system cost and complexity.

With a single resistor, the functionality of an I/O pin on a microcontroller can be vastly increased to allow for an input from one device and an output to another device. With the built-in capabilities of the microcontroller, this method is an easy and effective way to increase the functionality of a product while reducing system cost.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.