Merew
20.09.2009, 19:57
Nachdem ich von der blinkenden LED weg wollte und einen 7-segment display aus meinem cybot ausgebaut habe (siehe thread im bausatz forum), habe ich mich entschlossen ein kleines testprogramm zu schreiben. Welches in etwa so aussieht:
$regfile = "m32def.dat"
$framesize = 32
$swstack = 32
$hwstack = 32
$crystal = 16000000
$baud = 9600
Declare Sub Zahlanzeigen(byval Zahl As Byte)
Config Porta.0 = Output
Config Porta.1 = Output
Config Porta.2 = Output
Config Porta.3 = Output
Config Porta.4 = Output
Config Porta.5 = Output
Config Porta.6 = Output
Config Porta.7 = Output
Dim I As Byte
Dim J As Byte
Do
I = I + 1
Call Zahlanzeigen(i)
Waitms 50
If I = 19 Then
I = 0
End If
Loop
Sub Zahlanzeigen(byval Zahl As Byte)
Porta.0 = 1
Porta.1 = 1
Porta.2 = 1
Porta.3 = 1
Porta.4 = 1
Porta.5 = 1
Porta.6 = 1
Porta.7 = 1
If Zahl >= 10 Then
Porta.4 = 0
End If
J = Zahl Mod 10
If J = 1 Then
'cb
Porta.0 = 0
Porta.7 = 0
Elseif J = 2 Then
'abged
Porta.6 = 0
Porta.7 = 0
Porta.2 = 0
Porta.3 = 0
Porta.1 = 0
Elseif J = 3 Then
'abgcd
Porta.6 = 0
Porta.7 = 0
Porta.2 = 0
Porta.0 = 0
Porta.1 = 0
Elseif J = 4 Then
'fgbc
Porta.5 = 0
Porta.2 = 0
Porta.7 = 0
Porta.0 = 0
Elseif J = 5 Then
'afgcd
Porta.6 = 0
Porta.5 = 0
Porta.2 = 0
Porta.0 = 0
Porta.1 = 0
Elseif J = 6 Then
'fgecda
Porta.5 = 0
Porta.2 = 0
Porta.3 = 0
Porta.0 = 0
Porta.1 = 0
Porta.6 = 0
Elseif J = 7 Then
'abc
Porta.6 = 0
Porta.7 = 0
Porta.0 = 0
Elseif J = 8 Then
'alles ausser 4
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Porta.3 = 0
Porta.5 = 0
Porta.6 = 0
Porta.7 = 0
Elseif J = 9 Then
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Porta.5 = 0
Porta.6 = 0
Porta.7 = 0
Else
Porta.0 = 0
Porta.1 = 0
Porta.3 = 0
Porta.5 = 0
Porta.6 = 0
Porta.7 = 0
End If
End Sub
Man bemerke, dass ich nur 50ms warte. Tatsächlich, wartet der Controller aber knapp unter einer sekunde.
Benutze ich eine Sekunde, so wartet er ~16 sekunden.
Woran liegt das?
Fusebits sind auf standart gelassen und ich verwende kein Quarz.
Danke schonmal,
Merew
$regfile = "m32def.dat"
$framesize = 32
$swstack = 32
$hwstack = 32
$crystal = 16000000
$baud = 9600
Declare Sub Zahlanzeigen(byval Zahl As Byte)
Config Porta.0 = Output
Config Porta.1 = Output
Config Porta.2 = Output
Config Porta.3 = Output
Config Porta.4 = Output
Config Porta.5 = Output
Config Porta.6 = Output
Config Porta.7 = Output
Dim I As Byte
Dim J As Byte
Do
I = I + 1
Call Zahlanzeigen(i)
Waitms 50
If I = 19 Then
I = 0
End If
Loop
Sub Zahlanzeigen(byval Zahl As Byte)
Porta.0 = 1
Porta.1 = 1
Porta.2 = 1
Porta.3 = 1
Porta.4 = 1
Porta.5 = 1
Porta.6 = 1
Porta.7 = 1
If Zahl >= 10 Then
Porta.4 = 0
End If
J = Zahl Mod 10
If J = 1 Then
'cb
Porta.0 = 0
Porta.7 = 0
Elseif J = 2 Then
'abged
Porta.6 = 0
Porta.7 = 0
Porta.2 = 0
Porta.3 = 0
Porta.1 = 0
Elseif J = 3 Then
'abgcd
Porta.6 = 0
Porta.7 = 0
Porta.2 = 0
Porta.0 = 0
Porta.1 = 0
Elseif J = 4 Then
'fgbc
Porta.5 = 0
Porta.2 = 0
Porta.7 = 0
Porta.0 = 0
Elseif J = 5 Then
'afgcd
Porta.6 = 0
Porta.5 = 0
Porta.2 = 0
Porta.0 = 0
Porta.1 = 0
Elseif J = 6 Then
'fgecda
Porta.5 = 0
Porta.2 = 0
Porta.3 = 0
Porta.0 = 0
Porta.1 = 0
Porta.6 = 0
Elseif J = 7 Then
'abc
Porta.6 = 0
Porta.7 = 0
Porta.0 = 0
Elseif J = 8 Then
'alles ausser 4
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Porta.3 = 0
Porta.5 = 0
Porta.6 = 0
Porta.7 = 0
Elseif J = 9 Then
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Porta.5 = 0
Porta.6 = 0
Porta.7 = 0
Else
Porta.0 = 0
Porta.1 = 0
Porta.3 = 0
Porta.5 = 0
Porta.6 = 0
Porta.7 = 0
End If
End Sub
Man bemerke, dass ich nur 50ms warte. Tatsächlich, wartet der Controller aber knapp unter einer sekunde.
Benutze ich eine Sekunde, so wartet er ~16 sekunden.
Woran liegt das?
Fusebits sind auf standart gelassen und ich verwende kein Quarz.
Danke schonmal,
Merew