Code:
'-----------Chip Definiton-----------'
$regfile = "m16def.dat"
$crystal = 16000000
Config Portd = Output
Config Portb = Output
Config Sda = Portc.1
Config Scl = Portc.0
'-----------Sub Deklaration----------'
Declare Sub Hauptschirm()
Declare Sub Uhrzeit()
Declare Sub Temperatur()
Declare Sub Gettime()
Declare Sub Settime()
'-----------Variabeln----------------'
Dim S As Byte , M As Byte , H As Byte , D As Byte
Dim Wm As Byte , Yd As Byte , Month As Byte
S = 0
M = 0
H = 0
D = 1
Month = 1
Wm = 1
Yd = 5
'-----------Lcd Konfiguration--------'
Config Graphlcd = 240 * 64 , Dataport = Portd , Controlport = Portb , Ce = 2 , Cd = 3 , Wr = 0 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 8
'-----------Grafik Rahmen------------'
Cls
Cursor Off
Call Hauptschirm
Call Settime
'-----------Hauptprogramm------------'
Do
Call Gettime
Waitms 100
Loop
'-----------Hauptschirm--------------'
Sub Hauptschirm()
Line(0 , 0) -(240 , 0) , 1
Line(0 , 0) -(0 , 127) , 1
Line(239 , 0) -(239 , 127) , 1
Line(195 , 0 ) -(195 , 127) , 1
Line(50 , 0) -(50 , 127) , 1
Line(50 , 22) -(195 , 22) , 1
Line(0 , 63) -(239 , 63 ) , 1
Locate 5 , 11
End Sub
'-----------Uhrzeit-----------------'
Sub Uhrzeit()
Locate 2 , 9
Lcd "Uhrzeit: "
End Sub
'-----------Temperatur--------------'
Sub Temperatur()
Locate 3 , 2
Lcd "In:"
Locate 3 , 26
Lcd "Out:"
Waitms 200
Locate 5 , 2
Lcd "22 C"
Waitms 200
Locate 5 , 26
Lcd "31 C"
End Sub
'--------Uhrzeit holen-------------'
Sub Gettime()
I2cstart 'I2C Start
I2cwbyte &HA0 'Schreibemodus
I2cwbyte 2 'Sekunden-Register auswählen
I2cstart 'I2C Start
I2cwbyte &HA1 'Lesemodus
I2crbyte S , Ack 'lese Sekunden
I2crbyte M , Ack 'lese Minuten
I2crbyte H , Ack 'lese Stunden
I2crbyte Yd , Ack 'lese Jahr und Tag
I2crbyte Wm , Nack 'lese Wochentag und Monat
I2cstop 'I2C Stop
S = Makedec(s)
M = Makedec(m)
H = Makedec(h)
Locate 2 , 9
Lcd Bcd(h) ; ":" ; Bcd(m)
End Sub
'----------Uhrzeit schreiben--------'
Sub Settime()
S = Makebcd(s) 'Sekunden
M = Makebcd(m) 'Minuten
H = Makebcd(h) 'Stunden
D = Makebcd(d) 'Tag
Month = Makebcd(month) 'Monat
I2cstart 'I2C Start
I2cwbyte &HA0 'Schreibemodus
I2cwbyte 0 'select control register
I2cwbyte &HC 'set year and day bit for masking
I2cstop 'I2C Stop
I2cstart 'I2C Start
I2cwbyte &HA0 'Schreibemodus
I2cwbyte &H2 'Sekunden-Register auswählen
I2cwbyte S 'Sekunden schreiben
I2cwbyte M 'Minuten schreiben
I2cwbyte H 'Stunden schreiben
I2cwbyte D 'Tag schreiben
I2cwbyte Month 'Monat schreiben
I2cstop 'I2C Stop
End Sub
ich kann nichts auslesen und bekomme nix angezeigt. kann mal jemand schauen, wo der fehler liegt ?
Lesezeichen