frequency:
Lcdout "Freq Cntr"
ASM: movlw 0x06 'T1 ext osc sync off,timer1 off
ASM: movwf t1con 't1 ext clock input via RC0
ASM: bsf STATUS,RP0
ASM: movlw 0x86 'timer 1:128, pu off
ASM: movwf OPTION_REG
ASM: bcf STATUS,RP0
nxt_freq:
ASM: movlw 0x07 'T1 ext osc sync off,timer1 on
ASM: movwf T1CON
tmr0_cnt = 25 '1 sec count 25
ASM: clrf tmr1_cnt
ASM: clrf TMR0
ASM: bcf INTCON,2
ASM: bcf PIR1,0 'clr tmr1 INTF
ASM: clrf TMR1L 'zero timer1
ASM: clrf TMR1H
timer1:
ASM: btfss PIR1,0
Goto timer0 'no timer1 overflow
ASM: bcf PIR1,0 'clr tmr1 INTF
ASM: incf tmr1_cnt,F 'inc tmr1 cntr
timer0:
ASM: btfss INTCON,2
Goto timer1 'no timer0 overflow
ASM: bcf INTCON,2 'clr TMR0 INTF
ASM: decfsz tmr0_cnt,F 'dec tmr0 cntr
Goto timer1 'Not zero so loop again
ASM: movlw 0x00 'its zero
ASM: movwf T1CON 'stop tmr1
b2avall = TMR1L
b2avalm = TMR1H
b2avalh = tmr1_cnt
Gosub bin2asc
Lcdcmdout LcdLine1Home
Lcdout ascbfr7, ascbfr6, ascbfr5, ascbfr4, ascbfr3, ascbfr2, ascbfr1, ascbfr0, "Hz"
WaitMs 500
Goto nxt_freq