I'm building a circuit with an Arduino Mega and simple IC chips (e.g. 7432) but I have many lines to monitor for interrupt conditions and not enough pins on the Atmel so I'm looking for a way to expand this. Problems ensue because I need to be able to switch the trigger condition from rising edge to falling edge for some lines based on conditions, and some lines will remain high after having been serviced, so a priority encoder would suffer from the condition that a higher priority interrupt would mask a lower priority one. For the latter problem, I am thinking of using a register and some gates to allow disabling of some interrupts, but I don't have a good solution for the former. Does anyone have any suggestions? I'm getting new chips as needed, so solutions involving extra 7400 series ICs or similar would be appreciated, but something more exotic would be OK as well.

  • 2
    \$\begingroup\$ A basic CPLD like an XC9536XL is pretty inexpensive, but there's a learning curve. \$\endgroup\$ – Chris Stratton Aug 10 '12 at 15:21

An Arduino Mega has “only” 24 pin change interrupts for its 80 pins. Still, that may be enough for the original poster, and he may not have been aware of this possibility, because the “INT" pins have API support in the Arduino environment, while the pin change interrupts don’t.

Here’s some fairly elaborate code to attach to pin change interrupts


I know this answer is a bit late, but I'm answering it for any late readers to this question.

The software version of adding more interrupts would be to do a "Pin Change Interrupt". There are libraries for it that allow any pin to be able to trigger an interrupt because the ATMega is capable with a little clever coding.

  • 1
    \$\begingroup\$ This might actually be useful as an answer, if it contained some explanation / sample code on how to implement pin change interrupts, and how to use them for the purpose in the question. \$\endgroup\$ – Anindo Ghosh Apr 5 '13 at 2:36
  • \$\begingroup\$ While the AVR has pin change interrupts for all pins, the original question states there are "not enough pins on the Atmel". That means either getting another controller or an I/O expander. \$\endgroup\$ – Yann Vernier Apr 5 '13 at 5:38

I'd use an I/O expander like the MCP23008 or the MCP23017. Both have SPI and I2C versions; interrupts can be configured (edge-sensitive, level-sensitive) for each input.

  • \$\begingroup\$ The Semtech I/O expanders are also fairly priced and flexible, although they only have QFN packages, so MCP chips are easier to breadboard. \$\endgroup\$ – Yann Vernier Apr 5 '13 at 5:46

You could use a Programmable Interrupt Controller (PIC) such as the 82C59A. It will cascade if you need more than the eight interrupts it provides. It's a bit old school but I think it will handle all of your requirements. From these lecture slides:

Block diagram of 82C59A

  • It is treated by the host processor as a peripheral device.
  • It is configured by the host pocessor to select functions.
  • Chip Select is again used to address the 82C59A when necessary.
    • \$\text{A0}\$ address selects different command words within the 8259
  • \$\text{INT}\$ and \$\overline{INTA}\$ ared used as the handshaking interface.
    • \$\text{INT}\$ output connects to the \$\text{INTR}\$ pin from the master and is connected to a master IR pin on a slave
    • In a system with master and slaves, only the master \$\overline{INTA}\$ signal is connected.
  • Interrupt inputs \$\text{IR}_{0}\$ to \$\text{IR}_{7}\$ can be configured as either level-sensitive or edge-triggered inputs. Edge-triggered inputs become active on 0 to 1 transitions.
  • Cascade interface \$\text{CAS}_{0}\$ - \$\text{CAS}_{2}\$ and \$\overline{SP}\$/\$\overline{EN}\$:
    • Cascade interface \$\text{CAS}_{0}\$ - \$\text{CAS}_{2}\$ carry the address of the slave to be serviced.
    • \$\overline{SP}\$/\$\overline{EN}\$ :=1 selects the chip as the master in cascade mode.

Currently produced by Intersil and in stock at Digikey.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.