Kod: Zaznacz cały
$crystal = 11059200
'$default Xram
$large
Dim Cyfra(12) As Byte
Dim Jedn_sekund As Byte
Dim Dzie_sekund As Byte
Dim Jedn_minut As Byte
Dim Dzie_minut As Byte
Dim Jedn_godzin As Byte
Dim Dzie_godzin As Byte , W As Byte , Czas As Integer
Dim Flag As Bit
Dim Czas_wys As Byte
Dim Tempo As Byte
Config Timer0 = Timer , Gate = Internal , Mode = 1
Th0 = &H4C ' 19508
Tl0 = &H34 ' 46080/(11.0592/12)= 50,00 mSec.
Enable Timer0
Enable Interrupts
On Timer0 1s
Start Timer0
P0 = 0
P1 = 0
P2 = 0
P3 = 0
Czas = 1
'-------------definiowanie cyfr-------------------
Cyfra(0) = 63
Cyfra(1) = 6
Cyfra(2) = 219
Cyfra(3) = 207
Cyfra(4) = 230
Cyfra(5) = 237
Cyfra(6) = 125
Cyfra(7) = 7
Cyfra(8) = 255
Cyfra(9) = 111
Cyfra(11) = 128
'-------------------------------------------------
Declare Sub Warunek
Declare Sub Wys1
Declare Sub Wys2
Declare Sub Wys3
Declare Sub Wys4
Declare Sub Wspolne
Declare Sub Wspolne2
Declare Sub Program_glowny
Declare Sub Wstep
'------------------ustawianie zegarka-------------
Dzie_godzin = 2
Jedn_godzin = 0
Dzie_minut = 2
Jedn_minut = 4
Dzie_sekund = 0
Jedn_sekund = 0
'-------------------------------------------------
'-----------------program glowny-----------------
Start Timer0
Program_glowny
End
Sub Program_glowny
Do
If Flag = 1 Then
Wys1
Wys2
Wys3
Wys4
End If
Loop
End Sub
'------------------------------------------------
Sub Warunek
If Jedn_sekund > 9 Then
If Dzie_sekund > 4 Then
Dzie_sekund = 0
Decr Dzie_sekund
Incr Jedn_minut
End If
Jedn_sekund = 0
Incr Dzie_sekund
End If
If Jedn_minut > 9 Then
If Dzie_minut > 4 Then
Dzie_minut = 0
Decr Dzie_minut
Incr Jedn_godzin
End If
Jedn_sekund = 0
Dzie_sekund = 0
Jedn_minut = 0
Incr Dzie_minut
End If
If Jedn_godzin > 9 Then
Jedn_sekund = 0
Dzie_sekund = 0
Jedn_minut = 0
Dzie_minut = 0
Jedn_godzin = 0
Incr Dzie_godzin
End If
If Jedn_godzin > 3 And Dzie_godzin = 2 Then
End If
End Sub
Sub Wys1
P2.1 = 1
P1.7 = 0
P1 = Cyfra(dzie_godzin)
P1.7 = 0
'Waitms Czas_wys
Delay
P2.1 = 0
P1 = 0
End Sub
Sub Wys2
P2.2 = 1
P1.7 = 0
P1 = Cyfra(jedn_godzin)
P1.7 = 0
'Waitms Czas_wys
Delay
P2.2 = 0
P1 = 0
End Sub
Sub Wys3
P2.3 = 1
P1.7 = 0
P1 = Cyfra(dzie_minut)
P1.7 = 0
'Waitms Czas_wys
Delay
P2.3 = 0
P1 = 0
End Sub
Sub Wys4
P2.4 = 1
P1.7 = 0
P1 = Cyfra(jedn_minut)
P1.7 = 0
'Waitms Czas_wys
Delay
P2.4 = 0
P1 = 0
End Sub
Sub Wys5
P2.5 = 1
P1.7 = 0
P1 = Cyfra(dzie_sekund)
P1.7 = 0
'Waitms Czas_wys
Delay
P2.5 = 0
P1 = 0
End Sub
Sub Wys6
P2.6 = 1
P1.7 = 0
P1 = Cyfra(jedn_sekund)
P1.7 = 0
'Waitms Czas_wys
Delay
P2.6 = 0
P1 = 0
End Sub
Sub Wspolne
Jedn_sekund = 0
Dzie_sekund = 0
Jedn_minut = 0
Dzie_minut = 0
Jedn_godzin = 0
Dzie_godzin = 0
End Sub
Sub Wstep
W = 0
Do
If P3.0 = 1 Then
P0 = 0
P2 = 0
P1 = 0
Wait Czas
W = W + 1
If W > 14 Then W = 0
End If
If W = 1 Then
Wys1
If P3.1 = 1 Then
Wait Czas
Incr Dzie_godzin
If Dzie_godzin > 9 Then Dzie_godzin = 0
End If
End If
If W = 2 Then
Wys2
If P3.1 = 1 Then
Wait Czas
Incr Jedn_godzin
If Jedn_godzin > 9 Then Jedn_godzin = 0
End If
End If
If W = 3 Then
Wys3
If P3.1 = 1 Then
Wait Czas
Incr Dzie_minut
If Dzie_minut > 9 Then Dzie_minut = 0
End If
End If
If W = 4 Then
Wys4
If P3.1 = 1 Then
Wait Czas
Incr Jedn_minut
If Jedn_minut > 9 Then Jedn_minut = 0
End If
End If
If W = 5 Then
Wys5
If P3.1 = 1 Then
Wait Czas
Incr Dzie_sekund
If Dzie_sekund > 5 Then Dzie_sekund = 0
End If
End If
If W = 6 Then
Wys6
If P3.1 = 1 Then
Wait Czas
Incr Jedn_sekund
If Jedn_sekund > 9 Then Jedn_sekund = 0
End If
End If
If Dzie_godzin > 2 Then Dzie_godzin = 0
If Jedn_godzin > 3 And Dzie_godzin = 2 Then Jedn_godzin = 0
If Dzie_minut > 5 Then Dzie_minut = 0
If Dzie_sekund > 5 Then Dzie_sekund = 0
If P3.3 = 1 Then
Wait Czas
Goto 1s
End If
Loop
End Sub
1s:
Th0 = &H4C
Tl0 = &H34
If P3.0 = 1 Then Wstep
Incr Tempo
Warunek
If Tempo = 20 Then '20 x 50 mSecs = 1 Second
Flag = 1
Incr Jedn_sekund
Tempo = 0
End If
Return[ Dodano: 29-09-2005, 19:46 ]
Nikt nie może mi pomóc w przeróbce tego programu ?????