Main Content

Using Pin Multiplexing to Reduce Pin Usage on 8-Bit Microcontrollers

This post will cover two examples of using multiplexing on General Purpose Input/Output (GPIO) pins to reduce a project’s pin usage. The first example uses the technique “Charlieplexing” and the second uses timing peripherals and interrupts to quickly switch between a pin input state and output state to read a pushbutton while driving an LED.

General Purpose Input/Output (GPIO) pins are one of the most important specifications when considering a microcontroller for a design. You need enough pins to connect your microcontroller to all the other components in your design; however, more pins than needed can cause an unnecessary increase in design cost and occupy more space on your board. Additionally, reducing the required number of pins in a design can be the difference between two package sizes in a design. If only there was a way to squeeze just a few more I/O pins out of the smaller one! Fortunately, there are methods to free up pins in such cases.

Here are two examples created by our Microchip applications team using the AVR DD family of microcontrollers. First, we’ll discuss multiplexing GPIO pins to control LEDs through a technique referred to as “Charlieplexing.” Following that, we will look at how to simultaneously run a separate pushbutton and LED using a single pin.

The core idea behind Charlieplexing is to leverage the three states the microcontroller pin can be in: digital HIGH, LOW and high-impedance digital input state (also known as HIGH-Z or Tri-State). By using these three states instead of just the typical HIGH and LOW, the user can use n number of pins to drive up to (n2-n) separate LEDs. In this example, three designated pins would allow for six separate LEDs.

So how exactly does charlieplexing work? To understand that we’ll need to look at an example.”

Link to article