Poniżej zamieszczam kod, który nie działa prawidłowo.
Kod: Zaznacz cały
$regfile = "m8def.dat"
$crystal = 8000000
Config Lcd = 16 * 1a
Cursor Off
Config Adc = Single , Prescaler = 128 , Reference = Off
Start Adc
Config Pinb.0 = Output
Config Pinb.1 = Output
Config Pinb.2 = Input
Config Pinc.5 = Input
Dim W As Word
Dim Y As Single
Dim P As Single
Dim Q As Single
Dim W5 As Single
Dim W4 As Single
Dim W3 As Single
Dim W2 As Single
Dim Wart As Single
Dim A As Word
Dim Pozycja As Byte
Dim Wart2 As String * 5 'At $190
Dim Wart3(30) As String * 5 'At $200
Dim P0 As Word At 800 , P11 As Word At 810
Enable Interrupts
Pozycja = 1
P = 0
Q = 0
W = Getadc(0)
P0 = 1000 ' normalnie te dwie wartości znajdują się w EEPROM
P11 = 640
Cls
For A = 1 To 30
Wart3(a) = "0.000"
Next A
Poczatek:
Do
W = Getadc(0)
If W > P11 Then
W2 = P0 - P11
W5 = P0 - W
W3 = 1100 / W2
W4 = W5 * W3
W4 = W4 / 1000
Y = 0 + W4
W2 = Y * Y
W2 = 0.4261 * W2
W3 = Y * 0.4631
W3 = W2 - W3
W3 = W3 + 0.0033
Y = Y + W3
If Y < 0 Then Y = 0.000001
Q = Q + Y
P = P + 1
If P = 20 Then
Q = Q / 20
P = 0
Y = Q
Q = 0
Wart = Y
Wart2 = Str(wart)
Wart2 = Left(wart2 , 4)
Cls
If Pozycja = 1 Then Lcd Wart3(pozycja) Else Lcd Wart3(pozycja -1)
Lcd " " ; Wart2 ; "0 "
End If
Waitms 25
End If
Loop
EndWszystko zaczyna działać poprawnie gdy ręcznie przyporządkuję miejsce w pamięci dla tablicy:
Kod: Zaznacz cały
Dim Wart3(30) As String * 5 At $200Drugi problem dotyczy niszczenia danych w pamięci EEPROM. Co jakiś czas zostają samoczynnie zmienione dane lub całkowicie skasowane. Dlaczego?