Długi czas już siedzę nad tym programem, analizując inne programy i próbując różnych sposobów ale nie mogę zmusić tego do działania...
Byłby ktoś skłonny wytknąć mi błędy ?
Dodam, że jak pominąć całą sprawę z timerem to na lcd poprawnie liczy mi wartości (tzn prawie poprawnie bo 28 / 10 wychodzi 2.7999995 ale temu już zaradziłem)
Poprawiłem tytuł - regulamin p.11
[zumek]
Byłby ktoś skłonny wytknąć mi błędy ?
Dodam, że jak pominąć całą sprawę z timerem to na lcd poprawnie liczy mi wartości (tzn prawie poprawnie bo 28 / 10 wychodzi 2.7999995 ale temu już zaradziłem)
$regfile = "m32def.dat"
$crystal = 16000000
Config Lcd = 16 * 2 'konfiguracja typu wyświetlacza LCD
Config Lcdpin = Pin , Db4 = Porta.2 , Db5 = Porta.3 , Db6 = Porta.4 , Db7 = Porta.5 , E = Porta.1 , Rs = Porta.0
Config Timer1 = Timer , Prescale = 256
Config Portd = Output
Config Portb = Output
Config 1wire = Portc.0
Dim A As Byte , B As Byte , C As Byte , A1 As Integer , B1 As Byte , B2 As Single , B3 As Single , C1 As Single
Dim Opozniacz As Integer
Dim I As Byte
Dim T(2) As Byte
Dim Temp As Single
Enable Interrupts
Enable Timer1
Counter1 = 65200
On Timer1 Wyswietlanie
Start Timer1
Do
Disable Timer1
Cursor Off
Cls
Lcd A1
Lcd "x"
Lcd B1
Lcd "x"
Lcd B2
Lcd "x"
Lcd B3
Lowerline
Lcd C1
Lcd "x"
Lcd Temp
Lcd "x"
Lcd A
Lcd "x"
Lcd B
Lcd "x"
Lcd C
Enable Timer1
Waitms 200
Disable Timer1
1wreset
1wwrite &HCC
1wwrite &H44
Enable Timer1
Waitms 750
Disable Timer1
1wreset
1wwrite &HCC
1wwrite &HBE
T(1) = 1wread()
T(2) = 1wread()
1wreset
Enable Timer1
If T(2) = 0 Then
Temp = T(1) / 2
Else
I = 256 - T(1)
End If
If Temp < 0 Then
Set Portb.7
Temp = -temp
End If
C1 = Frac(temp)
C = C1 * 10
B1 = Temp - C1
B2 = B1 / 10
B2 = B2 + 0.000001
B3 = Frac(b2)
B = B3 * 10
A1 = B1 - B
A = A1 \ 10
Loop
Wyswietlanie:
Counter1 = 65200
Disable Interrupts
Portd = Lookup(a , Kody7seg)
Portb.0 = 0
Portb.1 = 1
Portb.2 = 1
Waitms 3
Portd = Lookup(b , Kody7seg)
Portb.0 = 1
Portb.1 = 0
Portb.2 = 1
Waitms 3
Portd = Lookup(c , Kody7seg)
Portb.0 = 1
Portb.1 = 1
Portb.2 = 0
Waitms 3
Enable Interrupts
Return
Kody7seg:
Data 64 , 121 , 36 , 48 , 25 , 18 , 2 , 120 , 0 , 16 , 127 , 28 , 255
Poprawiłem tytuł - regulamin p.11
[zumek]