Autor Wiadomość
mateusz119955
PostWysłany: Czw 17:25, 12 Sie 2010    Temat postu: Termometr&zegarek cyfrowy

Witam jestem początkującym programistą więc proszę o wyrozumiałość.
Mam kod zegarka cyfrowego i termometru i chciałem te dwa kody połączyć w jedną całość.No więc połączyłem i otrzymałem taki kod:
$regfile = "m16def.dat"
$crystal = 8000000
Config Portb = Input ; Portb = &B00000000
Config Portd = Output ; Portd = &B11111111
Config Portc = Output ; Portc = &B00000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.3 , Db5 = Portd.2 , Db6 = Portd.1 , Db7 = Portd.0 , E = Portd.4 , Rs = Portd.5
Config 1wire = Portb.0
Config Timer1 = Timer , Prescale = 256
Declare Sub Wysw_czas
Declare Sub Odcz_temp
On Timer1 Odmierz_1s
Dim K As Byte
Dim I As Byte
Dim Temperatura(2) As Byte
Dim Sekundy As Byte
Dim Minuty As Byte
Dim Godziny As Byte
Dim Nowa_w As Bit
Dim Wart_bcd As Byte
S1 Alias Pinb.2
S2 Alias Pinb.1
S3 Alias Pinb.3
S4 Alias Pinb.4
Enable Interrupts
Enable Timer1
Counter1 = 34286
Set Nowa_w
Set Portb.1
Set Portb.2
Deflcdchar 0 , 14 , 17 , 17 , 17 , 14 , 32 , 32 , 32
Deflcdchar 1 , 12 , 4 , 4 , 6 , 12 , 4 , 4 , 14
Deflcdchar 2 , 2 , 4 , 32 , 14 , 17 , 17 , 17 , 14
Deflcdchar 3 , 32 , 4 , 32 , 31 , 2 , 4 , 8 , 31
Deflcdchar 4 , 32 , 32 , 32 , 14 , 18 , 18 , 15 , 1
Do
If Pinb.6 = 1 Then
Pinc.0 = 1
Waitms 100
Cls
Lcd " Do widzenia!!!"
Lowerline
Lcd " Wy" ; Chr(1) ; Chr(4) ; "czanie..."
Waitms 3
Cls
Wait 1
Pinc.0 = 0
End If
If Pinb.5 = 1 Then
Pinc.0 = 1
Cls
Wait 1
Locate 1 , 1
Lcd "Zegarek & Termometr"
Lowerline
Lcd "Cyfrowy Cyfrowy"
For I = 1 To 20
Shiftlcd Left
Waitms 300
Next I
Wait 5
Cls
Lcd " Produkcja:"
Lowerline
Lcd "Mateusz Dziugie" ; Chr(1)
Wait 4
Cls
Lcd "S1 - Termometr"
Lowerline
Lcd "S2 - Zegarek"
If S3 = 1 Then
Pinc.0 = 1
Cls
Waitms 200
Call Wysw_czas
If S1 = 0 Then
Waitms 25
If S1 = 0 Then
Incr Minuty
Sekundy = 0
If Minuty = 60 Then
Minuty = 0
End If
Set Nowa_w
Call Wysw_czas
Waitms 200
End If
End If
If S2 = 0 Then
Waitms 25
If S2 = 0 Then
Incr Godziny
If Godziny = 24 Then
Godziny = 0
End If
Set Nowa_w
Call Wysw_czas
Waitms 200
End If
End If
Loop
End
Sub Wysw_czas
If Nowa_w = 1 Then
Cls
Wart_bcd = Makebcd(godziny)
Lcd Bcd(wart_bcd) ; ":"
Wart_bcd = Makebcd(minuty)
Lcd Bcd(wart_bcd) ; ":"
Wart_bcd = Makebcd(sekundy)
Lcd Bcd(wart_bcd) ; ":"
Reset Nowa_w
End If
End Sub
Odmierz_1s:
Counter1 = Counter1 + 34286
Incr Sekundy
Set Nowa_w
If Sekundy = 60 Then
Sekundy = 0
Incr Minuty
If Minuty = 60 Then
Minuty = 0
Incr Godziny
If Godziny = 24 Then
Godziny = 0
End If
End If
End If
End If
Return
End If
Do
If S4 = 1 Then
Pinc.0 = 1
Cls
Waitms 200
Call Odcz_temp
Cls
If Temperatura(2) = 0 Then
Locate 1 , 1
Lcd "Temperatura:"
Lowerline
Lcd "Temp: " ; Temperatura(1) ; Chr(0) ; "C"
Else
Locate 1 , 1
Lcd "Temperatura:"
Lowerline
Lcd "Temp:- " ; Temperatura(1) ; Chr(0) ; "C"
End If
Loop
Sub Odcz_temp
1wreset
1wwrite &HCC
1wwrite &H44
Waitms 750
1wreset
1wwrite &HCC
1wwrite &HBE
Temperatura(1) = 1wread(2)
1wreset
If Err = 1 Then
Cls
Lcd " Brak uk" ; Chr(1) ; "adu!!!"
Lowerline
Lcd "W" ; Chr(1) ; Chr(2) ; Chr(3) ; " uk" ; Chr(1) ; "ad DS1820!!!"
For K = 1 To 21
Shiftlcd Left
Waitms 300
Next K
Do
Loop
End If
If Temperatura(2) > 0 Then
Temperatura(1) = 256 - Temperatura(1)
End If
Temperatura(1) = Temperatura(1) / 2
End Sub
End If

Wszystko ładnie wygląda dopóki chcę go skompilować, a mianowicie wyskakuje mi taki błąd:
Error: 350 line: 0 Interrupt needs return, in File:
Co może myć nie tak?
Proszę o pomoc i szybką odpowiedź!

Powered by phpBB © 2001,2005 phpBB Group