Ui, mein erster Code hatte doch viele Fehler. Jetzt habe ich sogar das mit dem Interrupt verbessert und im Simulator funktioniert bisher alles tadellos.
Code:$regfile = "m32def.dat" $crystal = 1000000 '***********************************************************************' Dim Scheibe As Integer Dim Punkte As Integer Dim Scheibe_akt As Bit Dim A As Byte Dim B As Byte A = 0 B = 0 Scheibe = 2 Punkte = 0 Config Portd.0 = Output Config Portd.5 = Output Config Portd.6 = Output Config Int0 = Rising Config Int1 = Rising Enable Interrupts Enable Int0 Enable Int1 On Int0 Int0_5punkte On Int1 Int1_10punkte Do '---------------------' If Scheibe = 1 Then Portd.0 = 1 Scheibe = 0 Do Incr Scheibe Waitms 250 If Scheibe_akt = 1 Then Goto Anfang End If Incr B If Scheibe = 3 Then Scheibe = 0 End If Loop Until B = 8 Scheibe = 2 Goto Anfang Else Portd.0 = 0 End If '---------------------' If Scheibe = 2 Then Portd.5 = 0 Scheibe = 0 Do Incr Scheibe Waitms 250 If Scheibe_akt = 1 Then Goto Anfang End If Incr B If Scheibe = 3 Then Scheibe = 0 End If Loop Until B = 8 Scheibe = 3 Goto Anfang Else Portd.5 = 0 End If '---------------------' If Scheibe = 3 Then Portd.6 = 1 Scheibe = 0 Do Incr Scheibe Waitms 250 If Scheibe_akt = 1 Then Goto Anfang End If Incr B If Scheibe = 3 Then Scheibe = 0 End If Loop Until B = 8 Scheibe = 1 Goto Anfang Else Portd.6 = 0 End If Anfang: Scheibe_akt = 0 B = 0 Waitms 1000 Incr A Loop Until A = 20 End 'hier erscheint ein Ton und zeigt das Ende mit Ergebnis. '*************************************************************************' Int0_5punkte: Punkte = Punkte + 5 Portd.0 = 0 Portd.5 = 0 Portd.6 = 0 Scheibe_akt = 1 Return Int1_10punkte: Punkte = Punkte + 10 Portd.0 = 0 Portd.5 = 0 Portd.6 = 0 Scheibe_akt = 1 Return







Zitieren

Lesezeichen