Created
January 16, 2018 10:44
-
-
Save rafalw/801dbf18f935637ee74481760e461ed0 to your computer and use it in GitHub Desktop.
Zegar czasu rzeczywistego – wersja poprawiona.
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 | |
Config Portb = Output | |
Portb = &B11111111 | |
Config Portd = &B1111100 | |
Portd = &B1111111 | |
Config Timer1 = Timer , Prescale = 64 | |
On Timer1 Odczyt | |
Enable Timer1 | |
Config Timer0 = Timer , Prescale = 64 | |
On Timer0 Multipleks | |
Enable Timer0 | |
Enable Interrupts | |
Dim I As Byte | |
Dim Sekundy As Byte | |
Dim Minuty As Byte | |
Dim Godziny As Byte | |
Dim Godz_dzies As Byte | |
Dim Godz_jedn As Byte | |
Dim Min_dzies As Byte | |
Dim Min_jedn As Byte | |
Dim Tmp As Byte | |
Do | |
' Nastawianie czasu | |
' - przyciski S1 i S2 sa analizowane co 75ms | |
If Pind.0 = 0 Then | |
Waitms 75 | |
If Pind.0 = 0 Then | |
Gosub Zmiana_godzin | |
End If | |
End If | |
If Pind.1 = 0 Then | |
Waitms 75 | |
If Pind.1 = 0 Then | |
Gosub Zmiana_minut | |
End If | |
End If | |
Loop | |
End | |
Multipleks: | |
Select Case I | |
Case 0: | |
Portd.6 = 0 | |
Portd.5 = 1 | |
Portd.4 = 1 | |
Portd.3 = 1 | |
If Godziny < 10 Then | |
Portb = Lookup(0 , Tabela) | |
Else | |
Portb = Lookup(godz_dzies , Tabela) | |
End If | |
Case 1: | |
Portd.6 = 1 | |
Portd.5 = 0 | |
Portd.4 = 1 | |
Portd.3 = 1 | |
Portb = Lookup(godz_jedn , Tabela) | |
Case 2: | |
Portd.6 = 1 | |
Portd.5 = 1 | |
Portd.4 = 0 | |
Portd.3 = 1 | |
If Minuty < 10 Then | |
Portb = Lookup(0 , Tabela) | |
Else | |
Portb = Lookup(min_dzies , Tabela) | |
End If | |
Case 3: | |
Portd.6 = 1 | |
Portd.5 = 1 | |
Portd.4 = 1 | |
Portd.3 = 0 | |
Portb = Lookup(min_jedn , Tabela) | |
End Select | |
Incr I | |
If I = 4 Then | |
I = 0 | |
End If | |
Return | |
Odczyt: | |
Incr Sekundy | |
If Sekundy >= 60 Then | |
Sekundy = 0 | |
Gosub Zmiana_minut | |
End If | |
Return | |
Zmiana_minut: | |
Incr Minuty | |
If Minuty = 60 Then | |
Minuty = 0 | |
Gosub Zmiana_godzin | |
End If | |
Min_dzies = Minuty \ 10 | |
Min_jedn = Minuty Mod 10 | |
Return | |
Zmiana_godzin: | |
Incr Godziny | |
If Godziny = 24 Then | |
Godziny = 0 | |
End If | |
Godz_dzies = Godziny \ 10 | |
Godz_jedn = Godziny Mod 10 | |
Return | |
Tabela: | |
Data 192 , 249 , 164 , 176 , 153 , 146 , 130 , 248 , 128 , 144 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment