$regfile = "m16def.dat"
$baud = 38400
$crystal = 16000000
Stop Watchdog
Config Watchdog = 2048
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40
Config Timer2 = Timer , Prescale = 1024
Config Int0 = Change
On Int0 Isr_int0
On Timer2 Isr_tmr2
Enable Timer2
Enable Int0
Enable Interrupts
Dim Data_cnt As Byte
Dim Dataw As Long
Dim Datal(2) As Word At Dataw Overlay
Dim Datalalt As Long
Dim Datapos As Byte
Dim Pausen(32) As Integer
Dim Zeit As Integer
Config Pind.2 = Input
Config Pind.3 = Output
Config Pind.4 = Output
Pin_ir Alias Pind.2
Gnd Alias Portd.3
Vcc Alias Portd.4
Reset Gnd
Set Vcc
'Set Pin_ir
Config Portc = Output
Config Porta = Input
Led Alias Portc
Dim B As Integer , I As Integer
Dim Leds As Byte
Dim Alt As Byte
Dim Anzdaten As Byte
Dim A(512) As Byte
Dim Vari As Byte
Fertig Alias Vari.0
Merk1 Alias Vari.1
Fstop Alias Vari.2
Dim X As Integer
Dim Cnt As Byte
Print "FB Analyse Atmega 16"
Cnt = 0
I = 1
Do
If Fertig = 1 Then
Reset Fertig
For I = 1 To Anzdaten
Print Dataw.i;
Next I
Print ",";
For I = 1 To Anzdaten
Print Pausen(i);
Print ",";
Next I
Dataw = 0
Reset Fstop
End If
Incr X
If X = 30000 Then
X = 0
Toggle Led.2
End If
Loop
End
'Isr_int0:
' $asm
' sbis pind,2
' cbi portc,4
' sbic pind,2
' sbi portc,4
' $end Asm
'Return
Isr_int0:
Disable Int0
If Fstop = 0 Then
Zeit = 0
Merk1 = Not Pin_ir
Reset Fertig
Do
Incr Zeit
If Zeit = 800 Then
If Data_cnt > 22 Then
Set Fertig
Set Led.7
Set Fstop
Anzdaten = Data_cnt
End If
Data_cnt = 0
Exit Do
End If
Loop Until Pin_ir = Merk1
Toggle Led.0
If Zeit < 800 Then
Incr Data_cnt
Pausen(data_cnt) = Zeit
If Zeit < 150 Then
Dataw.data_cnt = 0
Else
Dataw.data_cnt = 1
End If
End If
End If
Enable Int0
Return
Isr_tmr2:
Datalalt = 0
Return
Lesezeichen