$baud = 2400
$regfile = "m8def.dat"
$crystal = 1000000
Config Sda = Portc.4
Config Scl = Portc.5
Dim I As Byte
Config Lcdpin = Pin , Db4 = Portb.7 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portb.6 , Rs = Portd.4 ' Natürlich so wie es wirklich angeschlossen ist (4-Bit-Modus)
Dim A As Byte
Config Lcd = 20 * 4
Dim Ura As Byte , Minu As Byte , Sek As Byte , Dan As Byte
Dim S As Byte , M As Byte , H As Byte , D As Byte , Weekdays As Byte
Dim Wm As Byte , Yd As Byte
Dim Wm1 As Byte
Declare Sub Gettime()
Do
Call Gettime
If Ura < 10 Then
Locate 1 , 12
Lcd "0"
Locate 1 , 13
Lcd Ura
Else
Locate 1 , 12
Lcd Ura
End If
If Minu < 10 Then
Locate 1 , 15
Lcd "0"
Locate 1 , 16
Lcd Minu
Else
Locate 1 , 15
Lcd Minu
End If
Loop
Sub Gettime()
I2cstart 'generate start
I2cwbyte 160 'write addres of PCF8583
I2cwbyte 2 'select second register
I2cstart 'generate repeated start
I2cwbyte 161 'write address for reading info
I2crbyte S , Ack 'read seconds
I2crbyte M , Ack 'read minutes
I2crbyte H , Nack 'read hours
' I2crbyte Yd , Ack 'read year and days
' I2crbyte Wm , Nack 'read weekday and month
I2cstop 'generate stop
Ura = Makedec(h)
Minu = Makedec(m)
Sek = Makedec(s)
End Sub
Lesezeichen