Witam, w założeniach jest by zrobić miernik częstotliwości z odczytem na komputerze po RS232.
Coś posklejałem więc prosił bym o sprawdzenie kodu.
Coś posklejałem więc prosił bym o sprawdzenie kodu.
$regfile = "m8def.dat"
$crystal = 8000000
$baud = 9600
Dim Czestotliwosc As Long
Dim Licz_8ms As Byte
Config Timer0 = Timer , Prescale = 256
Config Timer1 = Counter , Edge = Falling
On Timer0 Czas
On Timer1 Zlicz
Enable Interrupts
Enable Timer0
Enable Timer1
Declare Sub Licz_cze
Czas:
Load Timer0 = 250
Incr Licz_8ms
If Licz_8ms = 125 Then
Licz_8ms = 0
Stop Timer1
Gosub Licz_cze
Start Timer1
End If
Sub Licz_cze
Czestotliwosc = Czestotliwosc * 256
Czestotliwosc = Czestotliwosc + Counter1
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
Counter1 = 0
End Sub
Zlicz:
Incr Czestotliwosc
Return
Wyswietl_hz:
Print Czestotliwosc ; "Hz"
Return
Wyswietl_khz:
Print Czestotliwosc ;
Czestotliwosc = Czestotliwosc \ 1000
Print Czestotliwosc ; " kHz "
Return
Wyswietl_mhz:
Print Czestotliwosc ;
Czestotliwosc = Czestotliwosc \ 1000000
Print Czestotliwosc ; " MHz "
Return