Lcdout "Period"
period:
bsf STATUS,RP0
movlw %11000110 'pu off,+RB0,tmr0 1:128
movwf OPTION_REG
bcf STATUS,RP0
loop0:
movlw %00000100 '1:1,intclk, tmr1 stop
movwf T1CON 't1 ext clock input via RC0
clrf tmr1_cnt
clrf TMR1L 'zero timer1
clrf TMR1H
bcf INTCON,1 'RB0 intr
bcf PIR1,0 'clr tmr1 INTF
bsf INTCON,3 'enb RB0 intr
'cleared and waiting
loop1: 'await the +PB.0 intr
btfss INTCON,1 'test for RB0 intr
Goto loop1
bcf INTCON,1 'clr the RB0 intf
'start tmr1
bsf PIE1,0 'enb tmr1 intr
bcf PIR1,0 'clr tmr1 INTF
bsf T1CON,0 'enb tmr1
period1:
btfss PIR1,0 'is tmr1 intr
Goto period2 'no
incf tmr1_cnt,F 'yes inc tmr1 cntr
bcf PIR1,0 'clr tmr1 INTF
period2:
btfss INTCON,1 'is RB0 intr
Goto period1 'no
bcf T1CON,0 'stop tmr1
bcf INTCON,3 'stop all intr
bcf PIE1,0 'enb tmr1 intr
;local registers
b2avall = TMR1L
b2avalm = TMR1H
b2avalh = tmr1_cnt
Gosub bin2asc; conversion binary to ascii
Lcdcmdout LcdLine1Home
Lcdout ascbfr7, ascbfr6, ascbfr5, ascbfr4, ascbfr3, ascbfr2, ascbfr1, ascbfr0
Goto loop0