HI,
ich versuche gerade zwei Avr`s (Atmega8535 und Attiny2313) über UART
miteinander zu komuniziern. Was aber ein bisschen in die Hose geht.
Kurz gesagt der Chip der die LEd`s steuert macht irgendwas an was
aber nicht so sein soll. Schaltung ist ganz einfach RxD des einen mit TxD
des anderen chips über ein max232n gekreutzt und das dann halt noch
mal anders rum(TXD mit RxD). Dann habe ich dieses Programm für
den Tiny
und das Programm für den Mega:Code:$regfile = "2313def.dat" $crystal = 1000000 Const Bytes = 1 Dim I As Byte Do Rem start I = 255 : Serout I , Bytes , D , 1 , 4800 , 0 , 8 , 1 Rem Led I = 5 : Serout I , Bytes , D , 1 , 4800 , 0 , 8 , 1 Rem farbe I = 0 : Serout I , Bytes , D , 1 , 4800 , 0 , 8 , 1 I = 1 : Serout I , Bytes , D , 1 , 4800 , 0 , 8 , 1 I = 0 : Serout I , Bytes , D , 1 , 4800 , 0 , 8 , 1 Loop End
KAnn man das mit den Befehlen machen oder brauch mann da andere?Code:$regfile = "8535def.dat" $crystal = 1000000 Declare Sub Allesaus Config Timer2 = Timer , Prescale = 256 Const Aus = 1 Const An = 0 Const Bytes = 1 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 Config Portb.0 = Output Config Portd.4 = Output Config Portd.5 = Output Config Portb.3 = Output Led0 Alias Porta.0 Led1 Alias Porta.1 Led2 Alias Porta.2 Led3 Alias Porta.3 Led4 Alias Porta.4 Led5 Alias Porta.5 Led6 Alias Porta.6 Led7 Alias Porta.7 Led8 Alias Portb.0 Rot Alias Portd.4 Blau Alias Portd.5 Gruen Alias Portb.3 Dim Wertr(10) As Byte Dim Wertb(10) As Byte Dim Wertg(10) As Byte Dim I As Byte Dim J As Byte Dim Value As Byte Dim F1 As Byte Dim F2 As Byte Dim F3 As Byte Wertr(1) = 1 Wertg(1) = 0 Wertb(1) = 0 Wertr(2) = 1 Wertg(2) = 0 Wertb(2) = 0 Wertr(3) = 1 Wertg(3) = 0 Wertb(3) = 0 Wertr(4) = 0 Wertg(4) = 0 Wertb(4) = 0 Wertr(5) = 0 Wertg(5) = 0 Wertb(5) = 0 Wertr(6) = 0 Wertg(6) = 0 Wertb(6) = 0 Wertr(7) = 0 Wertg(7) = 0 Wertb(7) = 0 Wertr(8) = 0 Wertg(8) = 0 Wertb(8) = 0 Wertr(9) = 0 Wertg(9) = 0 Wertb(9) = 0 I = 0 On Timer2 Zeitroutine Const Timervorgabe = 191 Enable Timer2 Enable Interrupts Do Value = 9 F1 = 0 F2 = 0 F3 = 1 Wertr(value) = F1 Wertg(value) = F2 Wertb(value) = F3 Lesen: Serin Value , Bytes , D , 0 , 4800 , 0 , 8 , 1 If Value <> 255 Then Goto Lesen Serin Value , Bytes , D , 0 , 4800 , 0 , 8 , 1 Serin F1 , Bytes , D , 0 , 4800 , 0 , 8 , 1 Serin F2 , Bytes , D , 0 , 4800 , 0 , 8 , 1 Serin F3 , Bytes , D , 0 , 4800 , 0 , 8 , 1 Wertr(value) = F1 Wertg(value) = F2 Wertb(value) = F3 Value = 4 F1 = 0 F2 = 0 F3 = 1 Wertr(value) = F1 Wertg(value) = F2 Wertb(value) = F3 Loop End Zeitroutine: Timer2 = Timervorgabe I = I + 1 If I > 9 Then I = 1 Call Allesaus Waitms 3 If Wertr(i) = 1 Then Rot = An If Wertg(i) = 1 Then Gruen = An If Wertb(i) = 1 Then Blau = An Select Case I Case 1 Led0 = An Case 2 Led1 = An Case 3 Led2 = An Case 4 Led3 = An Case 5 Led4 = An Case 6 Led5 = An Case 7 Led6 = An Case 8 Led7 = An Case 9 Led8 = An End Select Return Sub Allesaus: Led0 = Aus Led1 = Aus Led2 = Aus Led3 = Aus Led4 = Aus Led5 = Aus Led6 = Aus Led7 = Aus Led8 = Aus Rot = Aus Blau = Aus Gruen = Aus End Sub







Zitieren

Lesezeichen