Inverting an Interrupt

adub

New Member
What do I mean by inverting an interrupt? I've got two switches and a push button attached to a 20x2.
Using: setint %00101100, %00101100
No problem with the push button but when one of the switches is flipped from High to Low I can no longer use the same mask to know when it's changed back to High.
I would need to use:
setint %00101000, %00101100
or
setint %00100100, %00101100

So is there a combination of and's or or's that can be used to make the new input pattern or do I just need to use an if/then structure to set it?

I'm sure there's a nicer way than doing this:
Code:
Interrupt:
	pause 150 ' debounce
	IntFlags = PinsC & %00001100
	
	if IntFlags = %00001100 then'0
	   setint %00001100,%0001100,C
	else 
	   if IntFlags = %00000100 then'4
	      setint %00001100,%0000100,C 
	   else
	      if IntFlags = %00001000 then'8
	   	   setint %00001100,%00000100,C
	      else
	         if IntFlags = %00001100 then'12
	            setint %00001100,%00000000,C
	         endif
	      endif
	   endif
	endif
return
'setint %00001100,%00001100,C
 
Last edited:

inglewoodpete

Senior Member
When the interrupt pattern gets complicated, it would probably be better to put the input condition into a variable. Then you can manipulate each bit as you require.

In your examples, you are using the AND logic case for the input bit pattern:
Code:
setint %00101000, %00101100
Ie "If in5=1 And in3=1 And in2=0 Then Interrupt"

You may be expecting the interrupt to occur when just one of the 3 inputs meets the criteria. In that case you would use
Code:
SetInt Or %00101000, %00101100
The interrupt is usually used to catch fleeting conditions. You mention using toggle switches. This is a situation that would not normally require using interrupts. Your code, in particular the interrupt logic, could be much simpler if you just polled the pins concerned.
 

adub

New Member
I think you're right. I'll just drop the interrupt routine. An if/then/else to test the inputs won't be any more time consuming than this any way.
Thanks
Arvin
 
Top