$regfile = "M8def.DAT"
$crystal = 11059200
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.5 , Db5 = Portb.4 , Db6 = Portb.3 , Db7 = Portb.2 , E = Portb.6 , Rs = Portb.7
Cursor Off
Dim Czestotliwosc As Long
Const Licznik = 22336
Config Timer1 = Timer , Prescale = 256
Config Timer0 = Counter , Edge = Falling
Deflcdchar 1 , 2 , 4 , 14 , 16 , 16 , 17 , 14 , 32 ' replace ? with number (0-7)
Deflcdchar 0 , 2 , 4 , 14 , 16 , 14 , 1 , 30 , 32
Deflcdchar 2 , 32 , 32 , 14 , 17 , 31 , 16 , 14 , 4 ' replace ? with number (0-7)
On Timer1 Czas
On Timer0 Zlicz
Cls
Lcd " MIERNIK"
Lowerline
Lcd " CZESTOTLIWOSCI"
Wait 1
Cls
Enable Interrupts
Enable Timer1
Enable Timer0 'Pomiar czasu
Counter1 = Licznik
Do
Loop
End
Czas:
Stop Timer0
Stop Timer1
Czestotliwosc = Czestotliwosc * 256
Czestotliwosc = Czestotliwosc + Counter0
Locate 1 , 2 : Lcd "Cz" ; Chr(2) ; "stotliwo" ; Chr(0) ; Chr(1)
If Czestotliwosc < 1000 Then Gosub Wyswietl_hz
If Czestotliwosc >= 1000 And Czestotliwosc < 1000000 Then Gosub Wyswietl_khz
If Czestotliwosc >= 1000000 Then Gosub Wyswietl_mhz
Czestotliwosc = 0
Counter0 = 0
Counter1 = Licznik
Start Timer0
Start Timer1
Return
Zlicz:
Incr Czestotliwosc
Return
Wyswietl_hz:
Locate 2 , 2
Lcd " " ; Czestotliwosc ; " "
Locate 2 , 9 : Lcd " Hz "
Return
Wyswietl_khz:
Locate 2 , 3
Lcd " " ; Czestotliwosc ; " "
Czestotliwosc = Czestotliwosc \ 1000
Locate 2 , 2
Lcd " " ; Czestotliwosc ; "."
Locate 2 , 11 : Lcd " kHz "
Return
Wyswietl_mhz:
Locate 2 , 3
Lcd Czestotliwosc ; " "
Czestotliwosc = Czestotliwosc \ 1000000
Locate 2 , 2
Lcd Czestotliwosc ; "."
Locate 2 , 11 : Lcd " MHz "
Return