View previous topic :: View next topic |
Author |
Message |
newguy
Joined: 24 Jun 2004 Posts: 1907
|
IC to expand the total# of external interrupts? |
Posted: Sat Jan 01, 2005 5:04 pm |
|
|
Does anyone know of an IC that can be used to expand the number of external interrupts on a pic?
I have a total of 7 signals that I'd like to monitor using interrupts. I'm using a 18F452 (though that may change), and I'm using pins B4-B7 for my user interface (buttons & a rotary encoder). That leaves 3 external interrupts (B0-B2) for my 7 remaining signals. I know that there are some pics that have 4 external interrupts, but that's just not enough for me.
I could design the code to poll the 7 lines quickly, but there's always the chance that I could miss an event, and I really can't afford that chance.
Is there an IC that would act like a multiplexer (sort of - 8 input, 3 output)? What I'm thinking of is that if something happened on line 5, then the mux IC would output 101 on its output lines, which I could hook up to the pic's external interrupt inputs. I could do this with a GAL or similar, but I'd prefer to buy an off-the-shelf part if possible.
Or is there something like this with an I2C interface (or SPI or whatever)?
If push comes to shove, I might multplex the B4-B7 lines. That is, I'd have a user input mode, where the buttons & encoder would be connected, and also have a "run" mode where the user interfaces would be disconnected, and the lines that I have to monitor would be connected instead.
Anyone ever run into a similar problem? |
|
|
ajt
Joined: 07 Sep 2003 Posts: 110
|
More Interrupts |
Posted: Sat Jan 01, 2005 5:38 pm |
|
|
If you have enough input pins to cover all the lines you want to monitor you could use an OR gate with all the signals going to it as well as input pins. Tie the output of the OR gate to an external interrupt pin and when any line fires the interrupt will fire. In the ISR check the other pins to see which line fired and handle it accordingly. _________________ Al Testani |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
Make your own "Interrupt Controller" |
Posted: Sat Jan 01, 2005 5:49 pm |
|
|
There is the 82C59 interrupt controller but it is way too complex for this task. Using I2C or SPI is not possible because it is far too slow.
One soution I used is an 8 input OR/NOR gate with the output connected to the external interrupt line (usually RB0). When any gate input goes active the gate output to the PIC causes an interrupt to occur and you simply poll the inputs to see which one went active. This approach was very responsive and required only a dozen or so instructions to check the inputs for who went active.
In another project I had all the inputs (27 of them) routed through a multiplexor with each input line also tied to one of the 3 OR gate input lines. I cascaded the output of the 3 OR gates together and took the single output to a D Flip-flop then into the PIC. Any line going active created a rising edge that set the F/F. When the F/F went set I reset the F/F then scanned the multiplexer inputs to see who went active. This allowed me to have as many interrupts as I wished (27 in this case).
Be aware that using this approach means you are limited to having only moderate interrupt response times. My inputs had to be in the active "trip" state for at least 5ms for me to see them reliably when two or more happened at the same time.
FWIW.... |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Sun Jan 02, 2005 1:51 pm |
|
|
Duh. Boy I feel stupid. Of course, an OR gate. Thanks very much guys. Sometimes I need a good swift kick before I begin to think. |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Sun Jun 19, 2005 12:17 am |
|
|
... or you could use PCA9554 I2C i/o expander. |
|
|
ik1wvq
Joined: 21 Feb 2004 Posts: 20
|
|
Posted: Sun Jun 19, 2005 12:57 am |
|
|
Microchip MCP23016 (16 LINES) or MCP23008 (8 lines)
I/O expander via I2C with interrupt port configurable.
Regards
Mauro IK1WVQ |
|
|
ik1wvq
Joined: 21 Feb 2004 Posts: 20
|
|
Posted: Sun Jun 19, 2005 1:03 am |
|
|
or, if you want, write an own expander with an 16F876 (or smaller/larger) configured as I/O expander with interrupt menagement, what poll all lines waiting for events, and talk with master via RB0 for interrupt notification and I2C bus for details about what line (lines) issued the interrupt request..
Mauro IK1WVQ |
|
|
|