PDA

View Full Version : Interupts - can two switches share the 'INT' Pin?



HankMcSpank
- 17th May 2010, 11:22
I have two switches that I'd like to use an interupt with....just wondering in my naive n00b world, if it's possible to have both switches connect to & ultimately trigger the INT interupt (pin RA2 on my 16f690) & then in the interupt handle part actually then work out which of the two buttons was pressed by way of also connecting each of these switch to a dedicated unique 16f690 input pin.

Dave
- 17th May 2010, 12:02
HankMcSpank, Why yes you can by using a couple of diodes and a pullup or pulldown reststor, depending on the switching state of the switches. If the switches are connecting VDD when made, place the anode of each diode to the appropriate switch and the cathodes of both diodes to the interrupt pin along with a pulldown resistor, When ether of the switches is pressed the interrupt pin will be set high and inside of the interrupt routine you can read which switch is connected to VDD.....

Dave Purola,
N8NTA

HankMcSpank
- 17th May 2010, 14:05
They say a picture is worth a thousand words, so to save me typing, I tried to knock up a quick Eagle irepresentation - do you mean something like this (or have I misinterpreted you?)...

http://i39.tinypic.com/25kkmt5.jpg

Dave
- 17th May 2010, 17:19
HankMcSpank , Exactly...

Dave Purola,
N8NTA

Dave
- 17th May 2010, 17:23
HankMcSpank, I spoke too quickly.... The pin used for the interrupt should have the cathodes of the two diodes connected to it with a pulldown ONLY... The other two anodes should be connected to each of the resistors and individually connected connected to the port pins to be read as well as the push buttons..

Dave Purola,
N8NTA

Bruce
- 17th May 2010, 17:41
Here's one example with 13 switches using just 2 interrupt input pins.

HankMcSpank
- 18th May 2010, 23:28
Thanks guys - I have my two switches working sweet onto the one INT pin now (once I figured out that OPTION_REG.6 = 1 wasn't set that is !)

http://www.darreltaylor.com/DT_INTS-14/hello.html

On that above URL, I see Darrel is using a cap to debounce the switches - going that route is there any win over & above using a short pause in the interupt handling routine (200ms seems to be debouncing fine & it save me a couple of caps - I'm not a tightwad, but space is going to be limited on my pcb!)