How to enable two interrupts?
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?
Re: How to enable two interrupts?
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.
Re: How to enable two interrupts?
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
Code:
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...
Code:
ExitInt:
intcon.0 = 0
PIR1.0 = 0
resume
enable
Re: How to enable two interrupts?
That is correct. That is what the interrupt flags are for, to allow the interrupt routine determine which interrupt occured.