Hallo liebe Leute,
ich versuche eine Laufschrift zu bauen. Auf der Laufschrift soll (wenn fertig) mittels SPI kommuniziert werden. Da mein Programm nicht funktionierte und nur falsche Werte lieferte bin ich auf etwas ganz Seltsames gestoßen: 49=120. Wie geht das denn?
Die wichtigen Code-Teile:
Bei z.B. X=2 kommt dann heraus, dass Temp0=49 ist obwohl A(2)=120 ist. Auch der Bascom-Simulator scheint meiner Meinung zu sein. Habe ich vielleicht ein Grundsatzproblem mit dem Array? Kann jemand helfen? Ich verstehe die Welt nicht mehr.Code:Dim A(7) As Byte Dim Temp As Byte , Temp0 As Byte A(1) = 15 A(2) = 120 A(3) = 15 A(4) = 120 A(5) = 42 A(6) = 85 A(7) = 127 ... For X = 1 To 7 Temp0 = A(x) ...
Bild hier
Hier mal mein Code.
Die Stacks sind schon künstlich erhöht worden weil ich erst dort den Fehler vermutet habe.
Code:$regfile = "m8def.dat" $crystal = 8000000 $swstack = 140 $hwstack = 140 $framesize = 100 $sim Config Portb.0 = Output Config Portb.1 = Output Config Portb.6 = Output Config Portb.7 = Output Config Portc.0 = Output Config Portc.1 = Output Config Portc.2 = Output Config Portc.3 = Output Config Portc.4 = Output Config Portc.5 = Output Config Portd.4 = Output Config Portd.5 = Output Config Portd.6 = Output Config Portd.7 = Output Const San = 1 Const Saus = 0 Const Zan = 0 Const Zaus = 1 Z1 Alias Portc.5 Z2 Alias Portc.4 Z3 Alias Portc.3 Z4 Alias Portc.2 Z5 Alias Portc.1 Z6 Alias Portc.0 Z7 Alias Portb.1 S1 Alias Portd.4 S2 Alias Portb.6 S3 Alias Portb.7 S4 Alias Portd.5 S5 Alias Portd.6 S6 Alias Portd.7 S7 Alias Portb.0 Config Spi = Hard , Interrupt = On , Data Order = Msb , Master = No , Polarity = Low , Phase = 0 , Clockrate = 128 Dim A(7) As Byte Dim B(7) As String * 7 Dim X As Byte , Y As Byte Dim Temp As Byte , Temp0 As Byte Dim Temp2 As String * 7 Spiinit A(1) = 15 A(2) = 120 A(3) = 15 A(4) = 120 A(5) = 42 A(6) = 85 A(7) = 127 Do 'spaltenweise eingabe ' Spiin A(1) , 7 B(1) = "" B(2) = "" B(3) = "" B(4) = "" B(5) = "" B(6) = "" B(7) = "" For X = 1 To 7 Temp0 = A(x) Temp = Bin(temp0) Temp2 = Str(temp) B(1) = B(1) + Mid(temp2 , 1 , 1) B(2) = B(2) + Mid(temp2 , 2 , 1) B(3) = B(3) + Mid(temp2 , 3 , 1) B(4) = B(4) + Mid(temp2 , 4 , 1) B(5) = B(5) + Mid(temp2 , 5 , 1) B(6) = B(6) + Mid(temp2 , 6 , 1) B(7) = B(7) + Mid(temp2 , 7 , 1) Next X 'zeilenweise ausgabe For X = 1 To 7 If X = 1 Then Z1 = Zan If X = 2 Then Z2 = Zan If X = 3 Then Z3 = Zan If X = 4 Then Z4 = Zan If X = 5 Then Z5 = Zan If X = 6 Then Z6 = Zan If X = 7 Then Z7 = Zan If Mid(b(x) , 1 , 1) = "1" Then S1 = San If Mid(b(x) , 2 , 1) = "1" Then S2 = San If Mid(b(x) , 3 , 1) = "1" Then S3 = San If Mid(b(x) , 4 , 1) = "1" Then S4 = San If Mid(b(x) , 5 , 1) = "1" Then S5 = San If Mid(b(x) , 6 , 1) = "1" Then S6 = San If Mid(b(x) , 7 , 1) = "1" Then S7 = San If X = 1 Then Z1 = Zaus If X = 2 Then Z2 = Zaus If X = 3 Then Z3 = Zaus If X = 4 Then Z4 = Zaus If X = 5 Then Z5 = Zaus If X = 6 Then Z6 = Zaus If X = 7 Then Z7 = Zaus Next X Loop End







Zitieren

Lesezeichen