Hallo,
danke für die Tipps, jetzt funktionierts so halb, hier erstmal mein code
Code:
$regfile = "m8def.dat"
$crystal = 8000000
$baud = 9600
Config Sda = Portc.4
Config Scl = Portc.5
Dim _weekday As Byte
Dim _day As Byte
Dim _month As Byte
Dim _year As Byte
Dim _sec As Byte
Dim _min As Byte
Dim _hour As Byte
Dim ___lcdno As Bit
Dim Ds1307w As Byte
Dim Ds1307r As Byte
Ds1307w = &B11010000
Ds1307r = &B11010001
_day = 29
_month = 6
_year = 05
_sec = 15
_min = 25
_hour = 20
_sec = Makebcd(_sec)
_min = Makebcd(_min)
_hour = Makebcd(_hour)
I2cstart
I2cwbyte Ds1307w
I2cwbyte 0
I2cwbyte _sec
I2cwbyte _min
I2cwbyte _hour
I2cstop
_day = Makebcd(_day)
_month = Makebcd(_month)
_year = Makebcd(_year)
I2cstart
I2cwbyte Ds1307w
I2cwbyte 3
I2cwbyte _weekday
I2cwbyte _day
I2cwbyte _month
I2cwbyte _year
I2cstop
Do
Rem Datum und Zeit holen
I2cstart
I2cwbyte Ds1307w
I2cwbyte 0
I2cstop
I2cstart
I2cwbyte Ds1307r
I2crbyte _sec , Ack
I2crbyte _min , Ack
I2crbyte _hour , Ack
I2crbyte _weekday , Ack
I2crbyte _day , Ack
I2crbyte _month , Ack
I2crbyte _year , Ack
I2cstop
_day = Makedec(_day)
_month = Makedec(_month)
_year = Makedec(_year)
_sec = Makedec(_sec)
_min = Makedec(_min)
_hour = Makedec(_hour)
Print _day ; "/" ; _month ; "/" ; _year
Print _hour ; "/" ; _min ; "/" ; _sec
Print "-----------------------------------------"
Waitms 2000
Loop
ich kriege jetzt im Terminal folgendes raus:
Code:
.
.
.
.
165/165/165
165/165/45
-----------------------------------------
29/6/5
20/37/2
-----------------------------------------
0/2/2
120/40/1
-----------------------------------------
165/165/165
165/165/45
-----------------------------------------
29/6/5
20/37/8
-----------------------------------------
.
.
.
.
Also immer jede dritte AUsgabe stimmt, der Rest ist Müll. Hat jemand ne Ahnung, woran dass liegen kann? Ne niedrigere waitms am Ende hab ich auch schon probiert, bringt nix.
Gruß
Florian
Lesezeichen