This works with P16F628 (4MHz)
Interrupt must be disabled
Result 32bit counter Hicntr,Locntr
'
Locntr var word
Hicntr var word
'
'
Freqy:
Hicntr = 0
'tmr1 no gate control, no prescaler, no sync, external clock source, stop tmr1
t1con = %00000110
tmr1l = 0
tmr1h = 0 'clr counter
pir1.0 = 0 'clr tmr1if
asm
movlw 77 ; x 4MHz
movwf r1 ;load 1sec. gate timer
movlw 70
movwf r2
movlw 2
movwf r3
movlw 1
movwf r4
bsf t1con,0 ;start Tmr1
measure
clrwdt ;1
btfss pir1,0 ;1 / 2
goto skkp ;2
bcf pir1,0 ;1
incf _Hicntr,f ;1
btfsc status,z ;1 / 2
incf _Hicntr+1,f ;1
goto precise ;2 9tic
skkp
goto $+1 ;2
goto $+1 ;2
nop ;1 9tic
precise
decfsz r1
goto measure
decfsz r2
goto measure
decfsz r3
goto measure
decfsz r4
goto measure
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
nop
endasm
t1con.0 = 0 'stop tmr1
if pir1.0 = 1 then 'tmr1 overflow ?
Hicntr = Hicntr + 1
endif
Locntr.byte0 = tmr1l
Locntr.byte1 = tmr1h
lcdout $FE,1
lcdout hex4 Hicntr,hex4 Locntr
pause 100
goto freqy
'
'
Regards
Bookmarks