Gast
#459704
Warum lässt sich die Uhrzeit nicht stellen.
Kann mir jemand auf die Sprünge helfen ??
Gruss
Frank
'#####################
'# Uhrmodul RTC-8563 #
'#####################
$regfile = "m8def.dat"
$crystal = 3686400
$lib "i2c.lbx"
$lib "mcsbyte.lbx"
$lib "datetime.lbx"
$baud = 19200
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 ,
Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
Config Lcd = 16 * 2
Initlcd
Cursor Off
Cls
'##### configure the used port pin for I2C
Config Clock = Soft
Config Date = Dmy , Separator = . '
Konfiguriert Ausgabe auf Deutsch
Config I2cdelay = 5 ' default
slow mode
Config Sda = Portc.4
Config Scl = Portc.5
I2cinit
'##### declare used subs
Dim Weekday As Byte
Const R8563 = &HA3
Const W8563 = &HA2
Declare Sub Getdatetime
Declare Sub Initial
Gosub Settime
Call Initial
Do
Call Getdatetime 'get time
Loop
End
Sub Getdatetime
I2cstart 'generate
start
I2cwbyte W8563 'write
addres of RTC8563
I2cwbyte 2 'select
second register
I2cstart 'generate
repeated start
I2cwbyte R8563
I2crbyte _sec , Ack 'read
seconds
I2crbyte _min , Ack 'read minuts
I2crbyte _hour , Nack 'read hours
I2crbyte Weekday , Ack ' Day of
Week
I2crbyte _day , Ack ' Day of
Month
I2crbyte _month , Ack ' Month of
Year
I2crbyte _year , Nack ' Year
I2cstop 'generate
stop
Waitms 30
_day = Makedec(_day) : _month = Makedec(_month) : _year =
Makedec(_year)
_sec = Makedec(_sec)
_sec = _sec - 80
_min = Makedec(_min)
_min = _min - 80
_hour = Makedec(_hour)
_hour = _hour - 80
Locate 1 , 1
Lcd Time$
Print Time$
Print Date$
End Sub
Return
Settime:
_sec = 1
_min = 2
_hour = 3
_day = 4
_month = 5
_year = 6
_sec = Makebcd(_sec) : _min = Makebcd(_min) : _hour = Makebcd(_hour)
I2cstart ' Generate
start code
I2cwbyte W8563 ' send
address
I2cstart
I2cwbyte 2 ' starting
address in RTC8563
I2cwbyte _sec ' Send Data
to SECONDS
I2cwbyte _min ' MINUTES
I2cwbyte _hour ' Hours
I2cstop
Waitms 30
Return
Readdate:
_day = Makebcd(_day) : _month = Makebcd(_month) : _year =
Makebcd(_year)
I2cstart ' Generate
start code
I2cwbyte W8563 ' send
address
I2cwbyte 6 ' starting
address in RTC8563
I2cwbyte _day ' Send Data
to Day
I2cwbyte _month ' Month
I2cwbyte _year ' Year
I2cstop
Waitms 30
Return
Sub Initial
I2cstart
I2cwbyte W8563
I2cstart
I2cwbyte 0
I2cwbyte 0
I2cstop
End Sub
Return