This appears to be working correctly. Are there any problems going this route?
Of course this isn't all the code, just the part that is relevant.
Code:
DEFINE INTHAND Direction
ASM
Direction
ENDASM
If PIR1.2 = 1 then
goto RPMASM
endif
If PIR2.1 = 1 then
goto ClockCount
endif
return
RPMASM:
ASM
CCP_INT
BTFSS CCP1CON,0 ; capture from rising edge?
BRA Fall ; no .. goto falling edge
MOVFF CCPR1L, TS ; get low capture byte into T1
MOVFF CCPR1H, TS+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
ENDASM
ClockCount: ' Note: this is being handled as an ASM interrupt
@ INT_START
@ RELOAD_TIMER ; Reload TIMER1
R0save = R0 ; Save 2 PBP system vars that are used during
R1save = R1 ; the interrupt
R4save = R4
Ticks = Ticks + 1
if Ticks = 1000 then
Ticks = Ticks-1000
Seconds = Seconds + 1
SecondsChanged = 1
if Seconds = 60 then
Minutes = Minutes + 1
MinutesChanged = 1
Seconds = 0
endif
if Minutes = 60 then
Hours = Hours + 1
HoursChanged = 1
Minutes = 0
endif
if Hours = 24 then
Days = Days + 1
DaysChanged = 1
Hours = 0
endif
endif
R4 = R4save ; Restore the PBP system vars
R1 = R1save
R0 = R0save
@ INT_RETURN ; Restore context and return from interrupt
Bookmarks