Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rafalw
Last active February 16, 2017 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafalw/cc52720608ffb46948cea8242a50b039 to your computer and use it in GitHub Desktop.
Save rafalw/cc52720608ffb46948cea8242a50b039 to your computer and use it in GitHub Desktop.
Wyświetlanie cyferek – ćwiczenie cz. 1 – do całkowitej przeróbki!
$regfile = "attiny2313.dat"
$crystal = 4000000
$hwstack = 40
$swstack = 16
$framesize = 32
Const Zero = &B11000000
Const Jeden = &B11111001
Const Dwa = &B10100100
Const Trzy = &B10110000
Const Cztery = &B10011001
Const Piec = &B10010010
Const Szesc = &B10000010
Const Siedem = &B11111000
Const Osiem = &B10000000
Const Dziewiec = &B10010000
Config Portb = Output
Portb = &B11111111
' Blok 1
Config Portd.3 = Output
Portd.3 = 1
' Blok 2
Config Portd.4 = Output
Portd.4 = 1
' Blok 3
Config Portd.5 = Output
Portd.5 = 1
' Blok 4
Config Portd.6 = Output
Portd.6 = 1
Dim Liczba As Integer
Dim Tysiace As Byte
Dim Setki As Byte
Dim Dziesiatki As Byte
Dim Jednosci As Byte
Dim Tmp As Integer
Dim Wynik As Integer
Dim Cyfra As Byte
Liczba = 1974
Gosub Rozbicie
Jednosci = Wynik
Liczba = Liczba / 10
Gosub Rozbicie
Dziesiatki = Wynik
Liczba = Liczba / 10
Gosub Rozbicie
Setki = Wynik
Tysiace = Liczba / 10
Do
Portd.3 = 0
Portd.4 = 1
Portd.5 = 1
Portd.6 = 1
Cyfra = Jednosci
Gosub Wyswietl
Waitms 5
Portd.3 = 1
Portd.4 = 0
Portd.5 = 1
Portd.6 = 1
Cyfra = Dziesiatki
Gosub Wyswietl
Waitms 5
Portd.3 = 1
Portd.4 = 1
Portd.5 = 0
Portd.6 = 1
Cyfra = Setki
Gosub Wyswietl
Waitms 5
Portd.3 = 1
Portd.4 = 1
Portd.5 = 1
Portd.6 = 0
Cyfra = Tysiace
Gosub Wyswietl
Waitms 5
Loop
End
Wyswietl:
Select Case Cyfra
Case 0:
Portb = Zero
Case 1:
Portb = Jeden
Case 2:
Portb = Dwa
Case 3:
Portb = Trzy
Case 4:
Portb = Cztery
Case 5:
Portb = Piec
Case 6:
Portb = Szesc
Case 7:
Portb = Siedem
Case 8:
Portb = Osiem
Case 9:
Portb = Dziewiec
End Select
Return
Rozbicie:
Tmp = Liczba / 10
Tmp = Tmp * 10
Wynik = Liczba - Tmp
Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment