pic chips have only one interrupt vector
DEFINE INTHAND CCP_INT ' Declare high-pri interrupt handler
needs to do something like this
DEFINE INTHAND which_CCP_INT ' Declare high-pri interrupt handler
then
asm
which_ccp_int
pseudo code wise
if ccp1 INTflag set then bra ccp_int1
else
if ccp2 INTflag set then bra ccp_int2
else
RETFIE FAST ' not my interrupt
CCP_INT1
BTFSS CCP1CON,0 ; capture from rising edge?
BRA Fall ; no .. goto falling edge
MOVFF CCPR1L, _T1 ; get low capture byte into _T1
MOVFF CCPR1H, _T1+1 ; get high capture byte into _T1
BRA IntExit ; outta here
Fall
MOVFF CCPR1L, PW ; get low capture byte into PW
MOVFF CCPR1H, PW+1 ; get high capture byte into PW
BSF CF,0 ; indicate last capture
IntExit
BTG CCP1CON,0 ; toggle between rising/falling edge captures
BCF PIR1,2 ; clear capture interrupt flag bit
RETFIE FAST ; return/restore W, STATUS and BSR
CCP2_INT
BTFSS CCP2CON,0 ; capture from rising edge?
BRA Fall2 ; no .. goto falling edge
MOVFF CCPR2L, _T2 ; get low capture byte into _T1
MOVFF CCPR2H, _T2+1 ; get high capture byte into _T1
BRA IntExit2 ; outta here
Fall2
MOVFF CCPR2L, PW2 ; get low capture byte into PW
MOVFF CCPR2H, PW2+1 ; get high capture byte into PW
BSF CF2,0 ; indicate last capture
IntExit2
BTG CCP2CON,0 ; toggle between rising/falling edge captures
BCF PIR2,0 ; clear capture interrupt flag bit
RETFIE FAST ; return/restore W, STATUS and BSR
ENDASM
Bookmarks