Below is my working ASM interrupt routine. I'm sure it could be improved, but it appears to work 100%. Using only 1 priority interrupt for the CCP module. Thanks for all the help!
Code:ASM X_CCP_INT BTFSC PIR1,2 ; if ccp1 BRA CCP_INT ; goto CCP_INT BTFSC PIR2,0 ; if ccp2 BRA CCP2_INT ; goto CCP2_INT RETFIE FAST ; outta here CCP_INT 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