Log in

View Full Version : How to enable two interrupts?



Dick Ivers
- 14th November 2015, 17:05
Hi,
I have one interrupt working but now would like to enable a second. The first one is a Timer2 match interrupt. The Pic is a 16f1829. I use other Pics in this same family as well. They all operate with automatic context saving so I write my interrupt handlers in assembly. When I add a second INTHAND I get an error message "duplicate handler". Maybe this should not be a big surprise. In any case, are there suggestions?

Dick Ivers
- 14th November 2015, 17:42
Hi again,
I'm taking a stab at a possible solution to my own problem:

Of course there cannot be two interrupt handlers. So, within the single handler a test could be made to determine which of the two interrupt flags is set. Then, based on that test, branch to the appropriate handler steps for that interrupt. All within one handler.

Heckler
- 14th November 2015, 21:56
Dick,

I think your on to the right answer...
Here is what I did to detect between a timer overflow vs a button push with a 12f683


MyInt:

inttype = PIR1 & %00000001 'check if timer1 overflow occured
if inttype = 1 then goto TimerInt

goto buttonint 'interrupt was gpio.3


then i clear the interupt flag here...

ExitInt:
intcon.0 = 0
PIR1.0 = 0
resume

enable

Dave
- 16th November 2015, 12:19
That is correct. That is what the interrupt flags are for, to allow the interrupt routine determine which interrupt occured.