Ds3231 real time clock i2c reading
Chuck Minton
Posts: 45
I am having trouble understanding the sequence of operations to read a particular register on the DS3231 Real Time Clock.
using I2C Object
I2C.INIT( 5,4,FALSE) 'to initiate the object
I2C.WRITELOCATION(%11010000,%00000000,%00000011,8,8) 'to set data to the seconds register
SECONDS:=I2C.READLOCATION(%11010001,%00000000,8,8) 'to attempt to read data from same register
Then try to send to Parallax Serial Terminal:
DATA.bin(0, SECONDS, 8)
DATA.TX(0,13)
I am getting varying data returned , and is not sequential in any way.
I looked for patterning thinking I was not addressing the register right...but I am at a loss here right now,
If any one has had experience reading from this chip I could sure use some guidance.
I have read from I2C temp sensors with no problem, but these have 13 registers to choose from and I am missing something.
using I2C Object
I2C.INIT( 5,4,FALSE) 'to initiate the object
I2C.WRITELOCATION(%11010000,%00000000,%00000011,8,8) 'to set data to the seconds register
SECONDS:=I2C.READLOCATION(%11010001,%00000000,8,8) 'to attempt to read data from same register
Then try to send to Parallax Serial Terminal:
DATA.bin(0, SECONDS, 8)
DATA.TX(0,13)
I am getting varying data returned , and is not sequential in any way.
I looked for patterning thinking I was not addressing the register right...but I am at a loss here right now,
If any one has had experience reading from this chip I could sure use some guidance.
I have read from I2C temp sensors with no problem, but these have 13 registers to choose from and I am missing something.
Comments
I wrote DS3231 code last year.
But it's PropForth. #24 of below;
http://forums.parallax.com/showthread.php?133312-PropForth4.6-is-available-for-download/page2
I think i2c-reading has no problem because you can read Temp of DS3231.
How do you set register-number?
I used the ChronoDot RTC module. This code lets you set the chip in 12 or 24 hour mode.
Hope it helps