Hallo,
ich habe ein kleines Problem bei meinem Code.
Und zwar arbeitet der Mega8 sehr langsam bei einer Frequenz von 4MHz.
Selbst bei einem Wait von "1" braucht er mehrere Sekunden um fortzufahren. wenn kein Wait eingefügt rennt er wie verrückt.
Der Code stellt Blinkende bzw. laufende LEDs dar.
zugleich könntet ihr mir veraten wie ich zu einer variable +1 rechne
Danke im Voraus
Carsten
Code:$regfile = "m8def.dat" $crystal = 4000000 Enable Interrupts 'einschalten Der Interrupts Enable Int0 'einschalten Von Interrupt Int0 Config Int0 = Low Level 'configuriere Int0 Auf Low Level On Int0 Keypress 'springe zu Keypress Dim Up As Bit Dim Count As Byte Dim Action As Byte Config Portc = Input Config Portb = Output Portb = &B111111111 Do If Action = 1 Then If Up = 0 Then Rotate Portb , Left Wait 1 End If If Up = 1 Then Rotate Portb , Right Wait 1 End If If Count = 1 Then Up = 0 End If If Count = 0 Then Up = 1 End If End If If Action = 2 Then Rotate Portb , Left Wait 1 End If Loop Keypress: If Pinc.0 = 0 Then Action = 1 Count = 1 Up = 0 Portb = &B1111110 Elseif Pinc.1 = 0 Then Action = 2 Portb = &B1010101 Elseif Pinc.2 = 0 Then Action = 3 End If Return







Zitieren

Lesezeichen