CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

IC to expand the total# of external interrupts?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

IC to expand the total# of external interrupts?
PostPosted: Sat Jan 01, 2005 5:04 pm     Reply with quote

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? Rolling Eyes
ajt



Joined: 07 Sep 2003
Posts: 110

View user's profile Send private message

More Interrupts
PostPosted: Sat Jan 01, 2005 5:38 pm     Reply with quote

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: 1934
Location: Norman, OK

View user's profile Send private message

Make your own "Interrupt Controller"
PostPosted: Sat Jan 01, 2005 5:49 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jan 02, 2005 7:22 am     Reply with quote

Or similar to what Al suggested, read the 4th post here:
http://www.ccsinfo.com/forum/viewtopic.php?t=18958
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Sun Jan 02, 2005 1:51 pm     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Sun Jun 19, 2005 12:17 am     Reply with quote

... or you could use PCA9554 I2C i/o expander.
ik1wvq



Joined: 21 Feb 2004
Posts: 20

View user's profile Send private message

PostPosted: Sun Jun 19, 2005 12:57 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jun 19, 2005 1:03 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group