Witam wszystkich forumowiczów. Napisałem ostatnio program w Bascomie, do wyświetlania numeru na wyświetlaczu led (7seg), i można je zmieniać za pomocą dwóch przycisków. Chciałbym, aby ktoś mi to sprawdził:
$regfile = "m8def.dat"
$crystal = 8000000
Config Portd = Output 'podłaczony wyświetlacz
Config Pinb.0 = Output ' anoda 1
Config Pinb.1 = Output 'anoda 2
Config Pinb.2 = Input 'przycisk 1
Config Pinb.3 = Input przycisk 2
Config Timer0 = Timer , Prescale = 256
Declare Sub Pobr_znaku(cyfra As Byte)
On Timer0 Mult_wysw
Dim A As Byte , B As Byte 'zmienne do wyswietlenia
Dim Nr_wysw As Byte 'Numer anody
Dim Wart As Byte 'liczba do wyswietlenia
W1 Alias Portb.0
W2 Alias Portb.1
P1 Alias Portb.2
P2 Alias Portb.3
Enable Interrupts
Enable Timer0
Load Timer0 , 125
Do
Wart = 11
Wart = Makebcd(wart)
A = Wart And &B00001111
Shift Wart , Right , 4
B = Wart
Wait 5
If P1 = 1 Then 'obsługa przycisku pierwszego
Waitms 25
If P1 = 1 Then
Incr Wart
End If
End If
If P2 = 1 Then 'obsługa przycisku drugiego
Waitms 25
If P2 = 1 Then
Decr Wart
End If
End If
If P1 = 1 And P2 = 1 Then 'zerowanie numerka
Wait 1
If P1 = 1 And P2 = 1 Then
Wart = 0
End If
End If
Wart = Makebcd(wart)
A = Wart And &B00001111
Shift Wart , Right , 4
B = Wart
Loop
End
Sub Pobr_znaku(cyfra As Byte)
If Cyfra < 10 Then
Portd = Lookup(cyfra , Kody7seg)
Else
Portd = 0
End If
End Sub
Mult_wysw:
Load Timer0 , 125
Set W1
Set W2
Select Case Nr_wysw
Case 0:
Call Pobr_znaku(a)
Reset W1
Case 1:
Call Pobr_znaku(b)
Reset W2
End Select
Incr Nr_wysw
If Nr_wysw = 2 Then
Nr_wysw = 0
End If
Return
Kody7seg:
Data &B0011111 , &B00000110 , &B01011011 , &B01001111 , &B01100110,
Data &B01101101 , &B01111101 , &B00000111 , &B01111111 , &B01101111
$regfile = "m8def.dat"
$crystal = 8000000
Config Portd = Output 'podłaczony wyświetlacz
Config Pinb.0 = Output ' anoda 1
Config Pinb.1 = Output 'anoda 2
Config Pinb.2 = Input 'przycisk 1
Config Pinb.3 = Input przycisk 2
Config Timer0 = Timer , Prescale = 256
Declare Sub Pobr_znaku(cyfra As Byte)
On Timer0 Mult_wysw
Dim A As Byte , B As Byte 'zmienne do wyswietlenia
Dim Nr_wysw As Byte 'Numer anody
Dim Wart As Byte 'liczba do wyswietlenia
W1 Alias Portb.0
W2 Alias Portb.1
P1 Alias Portb.2
P2 Alias Portb.3
Enable Interrupts
Enable Timer0
Load Timer0 , 125
Do
Wart = 11
Wart = Makebcd(wart)
A = Wart And &B00001111
Shift Wart , Right , 4
B = Wart
Wait 5
If P1 = 1 Then 'obsługa przycisku pierwszego
Waitms 25
If P1 = 1 Then
Incr Wart
End If
End If
If P2 = 1 Then 'obsługa przycisku drugiego
Waitms 25
If P2 = 1 Then
Decr Wart
End If
End If
If P1 = 1 And P2 = 1 Then 'zerowanie numerka
Wait 1
If P1 = 1 And P2 = 1 Then
Wart = 0
End If
End If
Wart = Makebcd(wart)
A = Wart And &B00001111
Shift Wart , Right , 4
B = Wart
Loop
End
Sub Pobr_znaku(cyfra As Byte)
If Cyfra < 10 Then
Portd = Lookup(cyfra , Kody7seg)
Else
Portd = 0
End If
End Sub
Mult_wysw:
Load Timer0 , 125
Set W1
Set W2
Select Case Nr_wysw
Case 0:
Call Pobr_znaku(a)
Reset W1
Case 1:
Call Pobr_znaku(b)
Reset W2
End Select
Incr Nr_wysw
If Nr_wysw = 2 Then
Nr_wysw = 0
End If
Return
Kody7seg:
Data &B0011111 , &B00000110 , &B01011011 , &B01001111 , &B01100110,
Data &B01101101 , &B01111101 , &B00000111 , &B01111111 , &B01101111