Code:$regfile = "m32def.dat" ' specify the used micro $crystal = 16000000 ' used crystal frequency 16mHz $framesize = 80 $hwstack = 80 $swstack = 80 $baud = 9600 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 Flashlinks Alias Porta.0 Flashrechts Alias Porta.1 Baconheck Alias Porta.2 Flashheck Alias Porta.3 Landescheinwerfer Alias Porta.4 Posilightlirot Alias Porta.5 Posilightregruen Alias Porta.6 Timer1 = 3000 Config Timer1 = Timer , Prescale = 8 Enable Timer1 Stop Timer1 On Timer1 Flash Gosub Flashoff Gosub Landescheinwerferoff Gosub Posilightsoff Dim V As Byte Dim Flasher As Byte Dim Posi As Byte Declare Sub Flash Config Timer2 = Timer , Prescale = 256 Stop Timer2 Timer2=0 Dim Zahl as Byte Dim Z11 As Byte Enable Interrupts Start Timer1 Do Waitms 20 Loop Empfaengerwerten: Gosub Empfaengereins Return Empfaengereins: Bitwait PIND.2, reset Bitwait PIND.2, set Start Timer2 Bitwait PIND.2, reset Stop Timer2 Zahl = Timer2 Timer2 = 0 Waitms 500 Return Empfaengersort: Print Zahl If Zahl > 105 Then Gosub Flashon Gosub Landescheinwerferon Else If Zahl > 85 Then Gosub Flashon Gosub Landescheinwerferoff Else If Zahl < 75 Then Gosub Flashoff Gosub Landescheinwerferoff End If End If End If Return Flash: 'Disable Interrupts Stop Timer1 If V = 0 Then Set Flashlinks Set Flashrechts Set Flashheck End If If V = 1 Then Reset Flashlinks Reset Flashrechts Reset Flashheck End If If V = 2 Then Waitms 30 End If If V = 3 Then Waitms 30 End If If V = 4 Then Set Flashlinks Set Flashrechts Set Flashheck End If If V = 5 Then Reset Flashlinks Reset Flashrechts Reset Flashheck End If If V = 6 Then Waitms 30 Set Baconheck End If If V = 7 Then Gosub Empfaengerwerten End If If V = 8 Then Gosub Empfaengersort End If If V = 9 Then End If If V = 10 Then Waitms 30 End If If V = 11 Then Waitms 30 End If If V = 12 Then End If If V = 13 Then End If If V = 14 Then Waitms 30 Reset Baconheck End If If V = 15 Then Waitms 30 V = 0 'Enable Interrupts Start Timer1 Timer1 = 3000 Return End If 'Enable Interrupts Incr V Start Timer1 Timer1 = 3000 Return Flashon: If Flasher = 0 Then Start Timer1 Flasher = 1 End If Return Flashoff: Stop Timer1 Flasher = 0 Reset Flashlinks Reset Flashrechts Reset Flashheck Reset Baconheck Return Landescheinwerferon: If Landescheinwerfer = 0 Then Set Landescheinwerfer End If Return Landescheinwerferoff: If Landescheinwerfer = 1 Then Reset Landescheinwerfer End If Return Posilightson: If Posi = 0 Then Set Posilightlirot Set Posilightregruen Posi = 1 End If Return Posilightsoff: If Posi = 1 Then Reset Posilightlirot Reset Posilightregruen Posi = 0 End If Return
Lesezeichen