Abel Raynus, Armatron International Inc, Malden, MA
On the lower end of the performance spectrum, many widely available and inexpensive microcontrollers pay for their small pc-board footprints by omitting functions. For example, most low end processors provide only one external-interrupt input pin and only one address vector in memory for the service routine that processes external IRQs (interrupt requests). However, a project occasionally requires that several interrupt-service programs must process multiple external interrupts from various sources. Cost and inventory constraints may make it undesirable to choose another microcontroller whose only advantage is the availability of a few more interrupt pins.
For example, Freescale Semiconductor’s (www.freescale.com) popular Nitron family of Flash-memory microcontrollers, such as the MC68HC908QT and QY, offer only one IRQ input pin. You can use one-time-programmable versions of the family, such as the MC68HC705KJ1 or MC68HC-705J1A, that offer five externalinterrupt inputs but omit some of the family’s valuable functions, such as Flash memory, built-in analog-to digital conversion, and an advanced instruction set. You could also select a larger microcontroller, such as the MC68HC908JL3, from the same product family to gain eight external-interrupt inputs at the expense of significant increases in cost and pc-board area.
This Design Idea offers an alternative that retains the small processor and adds extra interrupt inputs. The technique involves applying the interrupt signals to an AND gate to generate an IRQ signal and using the microcontroller’s inputs to recognize the interrupt’s source.
For example, consider the four external-interrupt sources in Figure 1. If you apply no interrupt signals and if all of the AND gate’s inputs rest at logic ones, the IRQ level also remains at logic one. Applying an interrupt signal (a logic-zero level) to any one of four inputs, INT1 through INT4, drives the gate’s output to a low level and triggers the interrupt. The interrupt-service routine recognizes the interrupt’s source by testing the levels of input pins PA0, PA1, PA4, and PA5 and executing the corresponding interrupt-service routine.
The MC68HC908QY2 microcontroller, IC1, includes built-in pullup resistors that eliminate the need for external resistors, and you can use an inexpensive and readily available 74LS21 for IC2. For demonstration purposes, this circuit displays the address of an incoming interrupt by lighting one of four corresponding LED indicators for 3 sec. The software routine in Listing 1 that assigns a priority to each interrupt uses the standard set of assembler instructions and can apply to any microcontroller. You can download Listing 1, as well as the sample’s assembler code and its accompanying table of equations (Listing 2) from www.edn.com/060302di.