Hallo,
der Code sieht so aus (eigentlich nichts besonderes drin)
Code:
$regfile = "m8def.dat"
$crystal = 8000000
$projecttime = 10
Config Int0 = FALLING
Config Int1 = FALLING
Config Timer1 = Timer , Prescale = 8
Config LCD = 20 * 4
Config LCDPIN = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portc.4 , Rs = Portc.5
Config PORTD.2 = Input 'Auf Eingang setzen
Config PORTB.3 = Output 'LCD Beleuchtung einschalten
Const Timervorgabe = 64535 '16Bit = 65535
Dim Millisekunden As Long
Dim ZeitMs as Long
Dim Sekunden as Single
Dim Messstrecke_M as Byte
Dim metersec as Single
Dim KMH as Single
Dim MPH as Single
Dim KMHstr as String * 6
Dim MPHstr as String * 6
Dim KMHa as Single
Dim MPHa as Single
Dim Messung as Byte 'Merkerbyte für erfolgte Messung
PortD.2 = 1 'PullUp Einschelten
Portd.3 = 1 'PullUp einschalten
PortB.3 = 1 'Port B3 einschalten (Hintergrundbeleuchtung
Millisekunden = 0
KMH = 0
Messstrecke_M = 3 'Messstrecke in Meter einstellen
On Int0 Irq0
On Int1 Irq1
Enable INT0
Enable INT1
On Timer1 Timer1_irq
Enable Timer1
Enable Interrupts
'LCD initialisieren
Initlcd
Cls
Cursor off
'Startbild anzeigen
Locate 1 , 1
LCD " "
Locate 2 , 1
LCD " "
Locate 4 , 1
LCD ""
Wait 5
Cls
Locate 1 , 1
LCD " "
Do
If Messung = 1 then
Sekunden = Millisekunden / 1000
Metersec = Messstrecke_M / sekunden
KMH = 3.6 * Metersec
MPH = KMH * 0.62
Messung = 2
end IF
If KMH > 999.9 then
KMHstr = "ERR"
MPHstr = "ERR"
Knotenstr = "ERR"
Else
KMHstr = Fusing(KMH , "#.#")
MPHstr = Fusing(MPH , "#.#")
End IF
If Messung = 2 then
' Anzeige auf Display
Locate 2 , 1
LCD "KMH : "
Locate 2 , 7
LCD KMHstr
Locate 3 , 1
LCD "MPH : "
Locate 3 , 7
LCD MPHstr
Locate 4 , 1
LCD " : "
Locate 4 , 7
LCD
Messung = 3
End IF
If Messung = 3 then
Enable Int0
Enable INT1
Portb.3 = 0
waitms 100
Portb.3 = 1
Messung = 0
end IF
Loop
End
'Startimpuls
Irq0:
Millisekunden = 0
Disable INT0
Return
'Stopimpuls
Irq1:
ZeitMs = Millisekunden
Messung = 1
Disable INT1
Return
'Pro Sekunde ein Aufruf
Timer1_irq:
Timer1 = Timervorgabe
Incr MILLISEKUNDEN
Return
Lesezeichen