• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Microcontroller Tips

Microcontroller engineering resources, new microcontroller products and electronics engineering news

  • Products
    • 8-bit
    • 16-bit
    • 32-bit
    • 64-bit
  • Applications
    • 5G
    • Automotive
    • Connectivity
    • Consumer Electronics
    • EV Engineering
    • Industrial
    • IoT
    • Medical
    • Security
    • Telecommunications
    • Wearables
    • Wireless
  • Learn
    • eBooks / Tech Tips
    • EE Training Days
    • FAQs
    • Learning Center
    • Tech Toolboxes
    • Webinars/Digital Events
  • Resources
    • Design Guide Library
    • DesignFast
    • LEAP Awards
    • Podcasts
    • White Papers
  • Videos
    • EE Videos & Interviews
    • Teardown Videos
  • EE Forums
    • EDABoard.com
    • Electro-Tech-Online.com
  • Engineering Training Days
  • Advertise
  • Subscribe

DEMUX, MUX, and Decoders: How To Expand I/O

September 6, 2017 By Mike Parks 2 Comments

The relentless march of technological progress has given engineers increasingly smaller and more energy efficient microcontrollers to use in their designs. These benefits do come with a cost, however. Physically smaller packages have less room for I/O pins meaning fewer peripheral components can interface with the microcontroller itself. Fewer peripherals means less functionality which tends not to be a desirable tradeoff.

Even when utilizing bus-based protocols such as I2C or SPI, there is often a need for each external integrated circuit to have a pin dedicated for chip select or output enable (often notated as CS or OE on schematics, or /CS and /OE for active low variations). After accounting for power, ground, reset, and the I2C pins on a small 8-pin chip like an ATtiny85, a design might at most interface with three external peripherals using the remaining I/O pins. Of course, one option would be to explore larger chips within the same microcontroller family. Depending on component availability or design constraints this might not be a possible option. Another possibility is to incorporate an additional circuit that sits between the microcontroller and the various external components. Circuits such as multiplexers, demultiplexers, and decoders come in a variety of packages and voltage levels so they can be incorporated into a board layout with relative ease.

Figure 1A: Demultiplexer can route a data output pin to different components based on address pins. Figure 1B: A decoder takes address pins as inputs and raises the corresponding pin to a logic high. Figure 1C: A multiplexer takes inputs from multiple devices, selected using the microcontrollers address pins, and routes the desired components output to a single input pin on the microcontroller.

With a demultiplexer we can take two of the microcontroller’s I/O pins and turn them into address pins (for example A1 and A0). The third pin serves as a digital output whose signal then can be redirected to up to four external peripheral components by toggling the address pins into one of four states including < A1:A0 > = 00, 01, 10, and 11.

If there is no need for a controllable output signal then it might be more desirable to instead use a decoder. With a decoder those same three pins (the two address pins and the digital output pin) could be instead used to interface with eight peripheral components thanks to the power of binary arithmetic (23 = 8). This is extremely useful in situations such as handling chip select or output enable pins of external ICs where those pins only need to drive to the source voltage or ground. Inverters can be placed on the output of the active high decoders to handle chips that required active low enables. Practically speaking 2:4 and 3:8 decoders are most common in discrete packages. However, it is possible to cascade multiple discrete decoders into larger networks as needed. Be careful not to go too large as problems may arise from fan-in and fan-out. Issues that could arise include slowed response times or even voltage levels dropping below defined logic levels.

Lastly, it is also possible to employ a similar concept for inputs being fed into a microcontroller from external devices such as sensors or switches. Instead of a demultiplexer, a multiplexer can be employed to funnel multiple outputs into a single input pin. Special care must be placed by the firmware designer to ensure the logic is correct when handling the different inputs and the associated variables that represent them in code. Be aware that decoder, multiplexer, and demultiplexer chips may have output enable (OE) pins themselves. Depending on the circuit design these pins can be hardwired to ground or source voltage so a microcontroller pin need not be used. The tradeoff being the chip is always on which may or may not be desired. Otherwise, a microcontroller pin must be budgeted for in the design.

Filed Under: FAQ, Featured, Industry Experts, microcontroller Tagged With: basics, FAQ

Reader Interactions

Comments

  1. Jose Ortiz says

    May 17, 2019 at 4:39 pm

    I would add shift registers to the list. Cheap 74HC595 chips or development boards, for example.

    Reply
    • wcqxdsxc waxdwdx says

      August 21, 2021 at 6:48 am

      Hii what if we have to control every single pin. in shift register we shift data from one pin to other.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Featured Contributions

Five challenges for developing next-generation ADAS and autonomous vehicles

Securing IoT devices against quantum computing risks

RISC-V implementation strategies for certification of safety-critical systems

What’s new with Matter: how Matter 1.4 is reshaping interoperability and energy management

Edge AI: Revolutionizing real-time data processing and automation

More Featured Contributions

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center

EE ENGINEERING TRAINING DAYS

engineering
“bills
“microcontroller
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

DesignFast

Design Fast Logo
Component Selection Made Simple.

Try it Today
design fast globle

Footer

Microcontroller Tips

EE World Online Network

  • 5G Technology World
  • EE World Online
  • Engineers Garage
  • Analog IC Tips
  • Battery Power Tips
  • Connector Tips
  • DesignFast
  • EDA Board Forums
  • Electro Tech Online Forums
  • EV Engineering
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips

Microcontroller Tips

  • Subscribe to our newsletter
  • Advertise with us
  • Contact us
  • About us

Copyright © 2025 · WTWH Media LLC and its licensors. All rights reserved.
The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media.

Privacy Policy