Hi Robson,
This might fill in a few of the blanks...
Code:
ADCON1 = %111
DEFINE OSC 4
LED1 VAR PORTB.0
LED2 VAR PORTB.1
RBCpins VAR BYTE
LastPins VAR BYTE
TRISA = %00110000
TRISB = %11000000 ' RB7 & RB6 as inputs
TRISC = %00000000
OPTION_REG.7 = 0 ; If you want Internal PORTB Pull-ups
PAUSE 10 ; Let weak pull-ups stabilize
LastPins = PORTB ; save current pin state,
; and end any mismatch conditions
INTCON.0 = 0 ; Clear RB Port change Int Flag
INTCON.3 = 1 ; Enable RB Port Change Interrupts
ON INTERRUPT GOTO myint
main:
'...
'...
GOTO main
DISABLE
myint:
RBCpins = PORTB ; read PORTB and end the mismatch
INTCON.0 = 0 ; reset RB Port change INT flag
if RBCpins.7 != LastPins.7 then ; Pin 7 changed
LastPins.7 = RBCpins.7
Toggle LED1
endif
if RBCpins.6 != LastPins.6 then ; Pin 6 changed
LastPins.6 = RBCpins.6
Toggle LED2
endif
RESUME
ENABLE
Bookmarks