Hallo,
ich habe folgendes Problem, ich habe eine Programm für zwei Led Lauflichter geschrieben aber leider bekomme ich nach kurzer Zeit einen Stacküberlauf.
Ich finde keine Lösung um das zu verhindern, kann mir gemand helfen??
Hier ist das Programm, ich habe es für einen AT89S8252 geschrieben und verwende es auf einen AT89S8253.
EDIT: das heisst "CODE" und nicht "QUOTE"Code:$large Dim A As Byte Dim C As Byte Dim D As Byte Dim L1 As Byte Dim R1 As Byte Dim R2 As Byte Dim L2 As Byte Dim Merker1 As Byte Dim Merker2 As Byte P0 = &HFF P1 = &HFF P2 = &HFF P3 = &HFF ' Enstellung Links Laufband 2 =1 A = 1 D = 1 Merker1 = 0 Merker2 = 0 Main: Do Zulauflicht1: If P0.0 = 0 And Merker1 = 0 Then Set L1 Print L1 Gosub Zu_lauflicht1 Else If L1 = 1 Then Gosub Zu_lauflicht1 Else Auflauflicht1: If P0.0 = 0 And Merker1 = 1 Then Set R1 Print R1 Gosub Auf_lauflicht1 Else If R1 = 1 Then Gosub Auf_lauflicht1 Else If L2 = 1 Then Gosub Zu_lauflicht2 End If End If End If End If End If Zulauflicht2: If P0.3 = 0 And Merker2 = 0 Then Set L2 Print L2 Gosub Zu_lauflicht2 Else If L2 = 1 Then Gosub Zu_lauflicht2 Else Auflauflicht2: If P0.3 = 0 And Merker2 = 1 Then Set R2 Print R2 Gosub Auf_lauflicht2 Else If R2 = 1 Then Gosub Auf_lauflicht2 Else If L1 = 1 Then Gosub Zu_lauflicht1 End If End If End If End If End If Loop Zu_lauflicht1: If L1 = 0 Then Goto Main Else If A = 1 Then P0.6 = 0 Waitms 0.2 A = A + 1 Goto Zulauflicht2 Else If A = 2 Then P0.7 = 0 Waitms 0.2 A = A + 1 Goto Zulauflicht2 Else If A = 3 Then P1.0 = 0 Waitms 0.2 A = A + 1 Goto Zulauflicht2 Else If A = 4 Then P1.1 = 0 Waitms 0.2 A = A + 1 Goto Zulauflicht2 Else If A = 5 Then P1.2 = 0 Waitms 0.2 A = A + 1 Goto Zulauflicht2 Else If A = 6 Then P1.3 = 0 Waitms 0.2 A = A + 1 Goto Zulauflicht2 Else If A = 7 Then P1.4 = 0 Waitms 0.2 A = A + 1 Goto Zulauflicht2 Else If A = 8 Then P1.5 = 0 Waitms 0.2 A = A + 1 Goto Zulauflicht2 Else If A = 9 Then P1.6 = 0 Waitms 0.2 A = A + 1 Goto Zulauflicht2 Else If A = 10 Then P1.7 = 0 Waitms 0.2 A = A + 1 Goto Zulauflicht2 Else If A = 11 Then P2.0 = 0 Waitms 0.2 A = A + 1 Goto Zulauflicht2 Else If A = 12 Then P2.1. = 0 Waitms 0.2 A = A + 1 Goto Zulauflicht2 Else If A = 13 Then P2.2 = 0 Waitms 0.2 A = A + 1 Goto Zulauflicht2 Else L1 = 0 Merker1 = 1 Goto Main End If End If End If End If End If End If End If End If End If End If End If End If End If End If Return End Zu_lauflicht2: If L2 = 0 Then Goto Main Else If D = 1 Then P2.3 = 0 Waitms 0.2 D = D + 1 Goto Zulauflicht1 Else If D = 2 Then P2.4 = 0 Waitms 0.2 D = D + 1 Goto Zulauflicht1 Else If D = 3 Then P2.5 = 0 Waitms 0.2 D = D + 1 Goto Zulauflicht1 Else If D = 4 Then P2.6 = 0 Waitms 0.2 D = D + 1 Goto Zulauflicht1 Else If D = 5 Then P2.7 = 0 Waitms 0.2 D = D + 1 Goto Zulauflicht1 Else If D = 6 Then P3.0 = 0 Waitms 0.2 D = D + 1 Goto Zulauflicht1 Else If D = 7 Then P3.1 = 0 Waitms 0.2 D = D + 1 Goto Zulauflicht1 Else If D = 8 Then P3.2 = 0 Waitms 0.2 D = D + 1 Goto Zulauflicht1 Else If D = 9 Then P3.3 = 0 Waitms 0.2 D = D + 1 Goto Zulauflicht1 Else If D = 10 Then P3.4 = 0 Waitms 0.2 D = D + 1 Goto Zulauflicht1 Else If D = 11 Then P3.5 = 0 Waitms 0.2 D = D + 1 Goto Zulauflicht1 Else If D = 12 Then P3.6 = 0 Waitms 0.2 D = D + 1 Goto Zulauflicht1 Else If D = 13 Then P3.7 = 0 Waitms 0.2 D = D + 1 Goto Zulauflicht1 Else L2 = 0 Merker2 = 1 Goto Main End If End If End If End If End If End If End If End If End If End If End If End If End If End If Return End Auf_lauflicht1: If R1 = 0 Then Goto Main Else If A = 14 Then P2.2 = 1 Waitms 0.2 A = A - 1 Goto Zulauflicht2 Else If A = 13 Then P2.1 = 1 Waitms 0.2 A = A - 1 Goto Zulauflicht2 Else If A = 12 Then P2.0 = 1 Waitms 0.2 A = A - 1 Goto Zulauflicht2 Else If A = 11 Then P1.7 = 1 Waitms 0.2 A = A - 1 Goto Zulauflicht2 Else If A = 10 Then P1.6 = 1 Waitms 0.2 A = A - 1 Goto Zulauflicht2 Else If A = 9 Then P1.5 = 1 Waitms 0.2 A = A - 1 Goto Zulauflicht2 Else If A = 8 Then P1.4 = 1 Waitms 0.2 A = A - 1 Goto Zulauflicht2 Else If A = 7 Then P1.3 = 1 Waitms 0.2 A = A - 1 Goto Zulauflicht2 Else If A = 6 Then P1.2 = 1 Waitms 0.2 A = A - 1 Goto Zulauflicht2 Else If A = 5 Then P1.1 = 1 Waitms 0.2 A = A - 1 Goto Zulauflicht2 Else If A = 4 Then P1.0 = 1 Waitms 0.2 A = A - 1 Goto Zulauflicht2 Else If A = 3 Then P0.7 = 1 Waitms 0.2 A = A - 1 Goto Zulauflicht2 Else If A = 2 Then P0.6 = 1 Waitms 0.2 A = A - 1 Goto Zulauflicht2 Else R1 = 0 Merker1 = 0 End If End If End If End If End If End If End If End If End If End If End If End If End If End If Return End Auf_lauflicht2: If R2 = 0 Then Goto Main Else If D = 14 Then P3.7 = 1 Waitms 0.2 D = D - 1 Goto Zulauflicht1 Else If D = 13 Then P3.6 = 1 Waitms 0.2 D = D - 1 Goto Zulauflicht1 Else If D = 12 Then P3.5 = 1 Waitms 0.2 D = D - 1 Goto Zulauflicht1 Else If D = 11 Then P3.4 = 1 Waitms 0.2 D = D - 1 Goto Zulauflicht1 Else If D = 10 Then P3.3 = 1 Waitms 0.2 D = D - 1 Goto Zulauflicht1 Else If D = 9 Then P3.2 = 1 Waitms 0.2 D = D - 1 Goto Zulauflicht1 Else If D = 8 Then P3.1 = 1 Waitms 0.2 D = D - 1 Goto Zulauflicht1 Else If D = 7 Then P3.0 = 1 Waitms 0.2 D = D - 1 Goto Zulauflicht1 Else If D = 6 Then P2.7 = 1 Waitms 0.2 D = D - 1 Goto Zulauflicht1 Else If D = 5 Then P2.6 = 1 Waitms 0.2 D = D - 1 Goto Zulauflicht1 Else If D = 4 Then P2.5 = 1 Waitms 0.2 D = D - 1 Goto Zulauflicht1 Else If D = 3 Then P2.4 = 1 Waitms 0.2 D = D - 1 Goto Zulauflicht1 Else If D = 2 Then P2.3 = 1 Waitms 0.2 D = D - 1 Goto Zulauflicht1 Else R2 = 0 Merker2 = 0 End If End If End If End If End If End If End If End If End If End If End If End If End If End If Return EndPicnick
MFG Matthias







Zitieren


Lesezeichen