ui, da hab ich aber tief im Bastelordner suchen müssen ...
naja, war damals fast and dirty zusammengestrickt, aber funktioniert:
Code:
' #######################################
' DAS IST DER CODE !!!!!!
$regfile = "m8def.dat"
$crystal = 16000000
$baud = 250000
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 2 , Databits = 8
Dim Timeout_counter As Byte , X As Byte , Y As Byte , Z As Byte , Fe_error As Byte
Dim Adresse As Byte , Adresse2 As Byte , Pointer As Byte At &H82
Dim Timercounter As Byte , Flag As Byte , Summe_pwm As Word
Dim Pwm_werte(5) As Byte
Dim Rotation_byte As Byte , Rotation_zaehler As Byte
On Urxc Zeichenempfang
Enable Urxc
Const Pwm_teiler = 255 / 46
Config Int0 = Falling
On Int0 Nulldurchgang
Enable Int0
Config Timer0 = Timer , Prescale = 64
On Timer0 Timer_irq
Const Timervorgabe = 220
Enable Timer0
Enable Interrupts
Config Portd.2 = Input
Config Portb = Output
Config Portc = Input
' interne Pullups an
Portc = &HFF
485_rw Alias Portc.6
Config 485_rw = Output
485_rw = 0
Led Alias Portb.0
Adresse = Pinc
Adresse = Not Adresse
Adresse = Adresse And &B00111111
For Z = 1 To 4
Pwm_werte(z) = 2
Next
Rotation_byte = &B10001000
Do
If Flag = 1 Then
Flag = 0
Y = Pointer
Shift Y , Right , 2
If Y = Adresse Then
Y = Pointer
Y = Y And &B00000011
Incr Y
Summe_pwm = Summe_pwm + X
Pwm_werte(y) = X / Pwm_teiler
Pwm_werte(y) = 49 - Pwm_werte(y)
End If
End If
If Summe_pwm = 1020 Then
If Rotation_zaehler > 30 Then
Rotation_zaehler = 0
Rotate Rotation_byte , Right , 1
End If
For Y = 1 To 4
If Rotation_byte.y = 0 Then
Pwm_werte(y) = 60
End If
Next
End If
If Timercounter < 48 Then
If Pwm_werte(1) <= Timercounter Then
Set Portb.1
Else
Reset Portb.1
End If
If Pwm_werte(2) <= Timercounter Then
Set Portb.2
Else
Reset Portb.2
End If
If Pwm_werte(3) <= Timercounter Then
Set Portb.3
Else
Reset Portb.3
End If
If Pwm_werte(4) <= Timercounter Then
Set Portb.4
Else
Reset Portb.4
End If
End If
' Pause für Zünden
Waitus 10
Portb = 0
If Timeout_counter > 150 Then
For Z = 1 To 4
Pwm_werte(z) = 100
Next
Summe_pwm = 0
End If
Loop
End
Zeichenempfang:
X = Udr
If Fe_error = 1 And X = 0 Then
Fe_error = 0
Pointer = 0
Summe_pwm = 0
End If
If Ucsra.fe = 1 Then
Fe_error = 1
Ucsra.fe = 0
End If
Incr Pointer
Flag = 1
Timeout_counter = 0
Return
End
Nulldurchgang:
Timercounter = 0
Incr Timeout_counter
Incr Rotation_zaehler
Return
End
Timer_irq:
Timer0 = Timervorgabe
Incr Timercounter
Return
End
Hab aber auch nur bis zu Adresse 255 genutzt, für 512 brauchst Du halt
ne Word Variable
@guenter1604:
Deinen Code kannst Du aber noch ne ganze Ecke kürzen:
Code:
$regfile = "m88def.dat"
$crystal = 16000000
$baud = 250000
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 2 , Databits = 8
Dim Buffer(513)as Byte
Dim Dmx_byte As Byte
Dim Kanal As Word
On Urxc Empfang
Enable Urxc
Enable Interrupts
Do
'Hier werden die Ausgänge von Buffer() bestückt
Loop
Empfang:
If Ucsr0a.fe0 = 1 Then
Kanal = 1
Else
Buffer(kanal) = Udr
Incr Kanal
End If
Return
Lesezeichen