Created
February 4, 2016 12:17
-
-
Save rafalw/34e1760cbcf16db1cb9b to your computer and use it in GitHub Desktop.
Miernik częstotliwości - program do przetestowania.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$regfile = "attiny2313.dat" | |
$crystal = 4000000 | |
$hwstack = 40 | |
$swstack = 16 | |
$framesize = 32 | |
Const Podstawa_licznika = 65536 | |
Config Portd.6 = Output | |
' Zwrotnica zamknięta: | |
Portd.6 = 0 | |
Config Timer1 = Counter , Edge = Rising | |
On Timer1 Licznik | |
Enable Timer1 | |
' Przerwanie co 16,384 ms (~61 razy na sekundę) | |
Config Timer0 = Timer , Prescale = 256 | |
On Timer0 Pomiar | |
Enable Timer0 | |
Enable Interrupts | |
Config Portd.5 = Input | |
Portd.5 = 1 | |
Dim I As Dword | |
Dim Czestotliwosc As Dword | |
Dim Czas As Byte | |
Cls | |
Cursor Off | |
Do | |
If Czas = 61 Then | |
' Minęła sekunda, można rozpocząć zliczanie! | |
Stop Timer0 | |
Stop Timer1 | |
Czestotliwosc = I * Podstawa_licznika | |
Czestotliwosc = Czestotliwosc + Timer1 | |
If Czestotliwosc > 990000 Then | |
Portd.6 = 1 | |
Else | |
Portd.6 = 0 | |
Lcd Czestotliwosc | |
Lcd " [Hz]" | |
End If | |
If Portd.6 = 1 Then | |
Czestotliwosc = Czestotliwosc * 32 | |
Czestotliwosc = Czestotliwosc / 1000 | |
Lcd Czestotliwosc | |
Lcd " [kHz]" | |
End If | |
I = 0 | |
Czas = 0 | |
Timer0 = 0 | |
Timer1 = 0 | |
Start Timer1 | |
Start Timer0 | |
End If | |
Loop | |
End | |
Licznik: | |
I = I + 1 | |
Return | |
Pomiar: | |
Czas = Czas + 1 | |
Return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment