Hallo,
ich habe ein Problem mit der Ansteuerung der RTC DS 1307. Hier mal mein Code:
Code:
$regfile = "m8def.dat"
$crystal = 8000000
$baud = 9600
Config Sda = Portc.4
Config Scl = Portc.5
Dim _date As Byte
Dim _month As Byte
Dim _year As Byte
Dim _sec As Byte
Dim _min As Byte
Dim _hour As Byte
Dim Ds1307w As Byte
Dim Ds1307r As Byte
Ds1307w = &B11010000
Ds1307r = &B11010001
_date = 23
_month = 6
_year = 05
_sec = 10
_min = 10
_hour = 13
_date = Makebcd(_date)
_month = Makebcd(_month)
_year = Makebcd(_year)
_sec = Makebcd(_sec)
_min = Makebcd(_min)
_hour = Makebcd(_hour)
I2cstart
I2cwbyte Ds1307w
I2cwbyte &H00
I2cwbyte &B0 , _sec
I2cwbyte &H01
I2cwbyte &B0 , _min
I2cwbyte &H02
I2cwbyte &B01 , _hour
I2cwbyte &H04
I2cwbyte &B00 , _date
I2cwbyte &H05
I2cwbyte &B000 , _month
I2cwbyte &H06
I2cwbyte _year
I2cstop
Do
I2cstart
I2cwbyte Ds1307r
I2cwbyte &H00
I2crbyte _sec , Ack
I2cwbyte &H01
I2crbyte _min , Nack
I2cwbyte &H02
I2crbyte _hour , Nack
I2cwbyte &H04
I2crbyte _date , Nack
I2cwbyte &H05
I2crbyte _month , Nack
I2cwbyte &H06
I2crbyte _year , Ack
I2cstop
_sec = Makedec(_sec)
_min = Makedec(_min)
_hour = Makedec(_hour)
_date = Makedec(_date)
_month = Makedec(_month)
_year = Makedec(_year)
Print _date ; "/" ; _month ; "/" ; _year
Print _hour ; "/" ; _min ; "/" ; _sec
Print "---------------------------------------"
Waitms 500
Loop
Pullups hab ich dran, 4k7 an SDA und SCL.
Hab echt keine Ahnung woran dass noch liegen könnte. Ich krieg immer für jeden Wert 165 raus.
Gruß
Florian
Lesezeichen