Multiple External Interupts
Help!
I want to use multiple external interupts and perform different functions depending upon which interupt was triggered. From reading the green book and the product manual I can't see how to do this. Can someone give me a push in the right direction.
I am using a PIC18F4620.
Terry
Multiple External Interupts
Thanks Skimask,
I think I'm good now. I just needed to enable INTCON1 and INTCON2. Somehow I missed them. I have some test code up and working now.
What I doing is not super time critical so I am doing everything I can to stay away from assembly. The only assembly I can do is with a soldering iron, screw driver, wrench....
Thanks also for the hints on TMR0 I'll be needing that soon.
Terry
Multiple External Interupts
Just in case someone wants to see how to do multiple hardware interupts, here is my quick and dirty program.
;************************************************* *******
; PIC18F4620
DEFINE OSC 40
; Setup Ports
TRISB = %11111111 ; Port B all inputs
TRISD = %00000000 ; Port D all outputs
DTR var INTCON.0 ; alias to intcon
DSR var INTCON2.0 ; alias to intcon1
ACC var INTCON3.0 ; alias to intcon2
INTCON = %10010000 ; Enable External Interupt INT0
INTCON2 = %10110000 ; INTCON2.7 = All pull up are disabled
; INTCON2.6 = INT0 trigger on falling edge
; INTCON2.5 = INT1 trigger on rising edge
; INTCON2.4 = INT2 trigger on rising edge
; INTCON2.3 = Not used
; INTCON2.2 = TMR0 low priority
; INTCON2.1 = Not used
; INTCON2.0 = Port change priority
INTCON3 = %01011000 ; INTCON3.7 = INT2 Low priority
; INTCON3.6 = INT1 Hi priority
; INTCON3.5 = Not used
; INTCON3.4 = INT2 external enabled
; INTCON3.3 = INT1 external enabled
; INTCON3.2 = Not used
; INTCON3.1 = INT2 Flag (Read Only)
; INTCON3.0 = INT1 Flag (Read Only)
On Interrupt Goto INTERUPTS ; Define interrupt handler
;************************************************* ********
Loop:
PORTD.0 = 0 ; Turn all LEDs on
PORTD.1 = 0
PORTD.2 = 0
PORTD.3 = 0
Goto loop ; Do it forever
;************************************************* ********
; Interrupt handler
Disable ; No interrupts past this point
INTERUPTS:
if INTCON.1 = 1 then
PORTD.0 = 1 ; Turn LED1 OFF
Pause 500 ; Wait .5 seconds
INTCON.1 = 0 ; Clear interrupt flag
endif
if INTCON3.0 = 1 then
PORTD.1 = 1 ; Turn LED2 OFF
Pause 500 ; Wait .5 seconds
INTCON3.0 = 0 ; Clear interrupt flag
endif
if INTCON3.1 = 1 then
PORTD.2 = 1 ; Turn LED2 OFF
Pause 500 ; Wait .5 seconds
INTCON3.1 = 0 ; Clear the interupt flag
Endif
RESUME ; Return to main program
ENABLE
;************************************************* ********
END
Terry