HI everyone, although im nt understand the code, but im trying to modify the code to my desire code. Hope to pros 1 can help me to debug =)
'* Name : Elapsed_INT.bas
; syntax = Handler IntSource, Label, Type, ResetFlag?
DEFINE Elapsed_Handler TMR1_INT, _ClockCount, PBP, yes

Ticks var word ' 1/100th of a second (10ms) <--- how to change to 1ms ?

BitSave VAR BIT

'''''Goto OverElapsed <---- ????
' ------------------------------------------------------------------------------
Asm
IF OSC == 4 ; Constants for 100hz interrupt from Timer1
TimerConst = 0D8F7h ; Executed at compile time only
EndIF
If OSC == 8
TimerConst = 0B1E7h
EndIF
If OSC == 10
TimerConst = 09E5Fh
EndIF
If OSC == 16
TimerConst = 063C7h
EndIF
If OSC == 20
TimerConst = 03CB7h
EndIF

; ----------------- ADD TimerConst to TMR1H:TMR1L
ADD2_TIMER macro
CHK?RP T1CON
BCF T1CON,TMR1ON ; Turn off timer
MOVLW LOW(TimerConst) ; 1
ADDWF TMR1L,F ; 1 ; reload timer with correct value
BTFSC STATUS,C ; 1/2
INCF TMR1H,F ; 1
MOVLW HIGH(TimerConst) ; 1
ADDWF TMR1H,F ; 1
endm

; ----------------- ADD TimerConst to TMR1H:TMR1L and restart TIMER1 ----------
RELOAD_TIMER macro
ADD2_TIMER
BSF T1CON,TMR1ON ; 1 ; Turn TIMER1 back on
endm

; ----------------- Load TimerConst into TMR1H:TMR1L --------------------------
LOAD_TIMER macro
MOVE?CT 0, T1CON,0
MOVE?CB 0, TMR1L
MOVE?CB 0, TMR1H
ADD2_TIMER
endm
EndAsm


' ------[ This is the Interrupt Handler ]---------------------------------------
ClockCount:
@ RELOAD_TIMER ; Reload TIMER1
Ticks = Ticks + 1
if Ticks = 65535 then
Ticks = 0

endif

@ INT_RETURN ; Restore context and return from interrupt

'-----====[ END OF TMR1 Interrupt Handler ]====---------------------------------

interrupt:
'
' Restart counting
Tsensor = ticks ; Save the timing between sensor pass through
BitSave = T1CON.0 ; Save TMR1ON bit
@ LOAD_TIMER ; Load TimerConst
T1CON.0 = BitSave ; Restore TMR1ON bit
Ticks = 0

return
define LOADER_USED 1
define OSC 20

include "DT_INTS-14.bas"
INCLUDE "ReEnterPBP.bas"
INCLUDE "Elapsed_INT.bas"

ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _ClockCount, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor

INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts
ENDASM

T1CON.1 = 0 ; (TMR1CS) Select FOSC/4 Clock Source
T1CON.3 = 0 ; (T1OSCEN) Disable External Oscillator
T1CON.0 = 1 ; (TMR1ON) Start TIMER1

Main:

LCDout $FE,$C0, de5 ticks

GOTO Main


but i really dont understand, i have the INTERRUPT: subroutine, but how the system knows when my sensor is falling edge, it will getting interrupt and jump to this subroutine??