'Sparrow_TPS4.bas
'Eingabe über RS232 mit 300 Baud
$regfile = "attiny13.dat"
$crystal = 1200000
$hwstack = 8
$swstack = 4
$framesize = 4
Led1 Alias Portb.1
Led2 Alias Portb.3
S1 Alias Pinb.0
S2 Alias Pinb.2
Config Portb = &B000011010
Dim D As Byte
Dim T As Byte
Dim B As Byte
Dim C As Byte
Dim A As Byte
Dim P As Byte
Dim Addr As Byte
Dim Eebyte As Byte
Dim Dat As Byte
Dim Kom As Byte
Dim Adrhi As Byte
Dim Adrlo As Byte
Dim Adrret As Byte
Dim Dd As Word
Dim Delaytime As Word
Dta:
Data 1% , 2% , 5% , 10% , 20% , 50% , 100% , 200% , 500% , 1000% , 2000% , 5000% , 10000% , 20000% , 30000% , 60000%
Open "comb.2:300,8,n,1" For Input As #1
'Open "comb.1:300,8,n,1,INVERTED" For Output As #2
Config Adc = Single , Prescaler = Auto
If S1 = 0 Then
A = 0
Do
Led2 = 1
Get #1 , D
D = D * 16
Led2 = 0
Waitms 30
Get #1 , C
C = C And 15
D = D + C
Writeeeprom D , A
' Put #2 , D
A = A + 1
Waitms 30
Loop Until D = 255
End If
Addr = 0
Do
Readeeprom Eebyte , Addr
Addr = Addr + 1
Dat = Eebyte And 15
Kom = Eebyte / 16
If Kom = 1 Then '1: Direkte Portausgabe
Led1 = Dat.0
Led2 = Dat.1
Portb.4 = Dat.2
End If
If Kom = 2 Then
Restore Dta
Delaytime = Lookup(dat , Dta)
Waitms Delaytime '2: Wartezeit
End If
If Kom = 3 Then '3: Sprung - relativ
Addr = Addr - 1
Addr = Addr - Dat
End If
If Kom = 4 Then 'A=
A = Dat
End If
If Kom = 5 Then
If Dat = 2 Then C = A 'C=A
If Dat = 4 Then 'Port = A
Led1 = A.0
Led2 = A.1
' Portb.4 = A.2
End If
If Dat = 9 Then
Config Timer0 = Pwm , Prescale = 8 , Compare B Pwm = Clear Up
Pwm0b = A * 16 'PWM=A
End If
End If
If Kom = 6 Then '6 9 , A = Ain1 (=B4)
Ddrb.4 = 0
Dd = Getadc(2)
Shift Dd , Right , 6
A = Dd
End If
If Kom = 7 Then
If Dat = 1 Then A = A + 1 'A=A+1
If Dat = 2 Then A = A -1 'A=A-1
End If
' If Kom = 8 Then
' Adrhi = Dat 'Oberes Nibble der Adresse
' End If
' If Kom = 9 Then
' Addr = Adrhi * 16 'Springe absolut 0...255
' Addr = Addr + Dat
' End If
If Kom = 10 Then
C = C - 1
C = C And 15
If C > 0 Then 'C-mal
Addr = Adrhi * 16 'Springe absolut 0...255
Addr = Addr + Dat
End If
End If
If Kom = 12 Then 'Skip if S1=1
If Dat = 4 Then
If S1 = 1 Then Addr = Addr + 1
End If
If Dat = 5 Then 'Skip if S2=1
If S2 = 1 Then Addr = Addr + 1
End If
End If
Loop