[time-nuts] Maxim DS3232 and I2C
I would like to ask an advise for following: Lets say I have a DS3232 RTC connected by I2C to some MCU. The maximum allowed I2C bus speed is 400KHZ. And I need to read time (HH:MM:SS) from it. It will be THREE SEPARATE REQUESTS for each part (hours, minutes and seconds). My concern: what if I start to read time at the edge, when it will change itself inside of DS3232 ? Potentially, I could get weird results, like hours and minutes stay the same, but seconds has changed. Or even worth - hours is the same, but seconds and minutes has changed. Is there any method to read all three values (HH:MM:SS) by one single requests ? Or is there any other workaround for this issue ? Or it is not issue at all ? Thanks ! -- WBW, V.P. ___ time-nuts mailing list -- time-nuts@febo.com To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts and follow the instructions there.
Re: [time-nuts] Maxim DS3232 and I2C
Read SS MM HH SS and if the first and second readings of SS are within the same minute you know you have a good reading. /tvb - Original Message - From: d0ct0r t...@patoka.org To: time-nuts@febo.com Sent: Friday, February 14, 2014 2:20 PM Subject: [time-nuts] Maxim DS3232 and I2C I would like to ask an advise for following: Lets say I have a DS3232 RTC connected by I2C to some MCU. The maximum allowed I2C bus speed is 400KHZ. And I need to read time (HH:MM:SS) from it. It will be THREE SEPARATE REQUESTS for each part (hours, minutes and seconds). My concern: what if I start to read time at the edge, when it will change itself inside of DS3232 ? Potentially, I could get weird results, like hours and minutes stay the same, but seconds has changed. Or even worth - hours is the same, but seconds and minutes has changed. Is there any method to read all three values (HH:MM:SS) by one single requests ? Or is there any other workaround for this issue ? Or it is not issue at all ? Thanks ! -- WBW, V.P. ___ time-nuts mailing list -- time-nuts@febo.com To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts and follow the instructions there. ___ time-nuts mailing list -- time-nuts@febo.com To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts and follow the instructions there.
Re: [time-nuts] Maxim DS3232 and I2C
I don't think this is an issue. The datasheet indicates : When reading or writing the time and date registers, secondary (user) buffers are used to prevent errors when the internal registers update. When reading the time and date registers, the user buffers are synchronized to the internal registers on any START and when the register pointer rolls over to zero. The time information is read from these secondary registers, while the clock continues to run. This eliminates the need to reread the registers in case the main registers update during a read. So if you do a multi-byte read to get the lot at once, then it should be coherent. I saw some code to do this somewhere, but I have lost track of it. Le 14 févr. 2014 à 23:20, d0ct0r a écrit : I would like to ask an advise for following: Lets say I have a DS3232 RTC connected by I2C to some MCU. The maximum allowed I2C bus speed is 400KHZ. And I need to read time (HH:MM:SS) from it. It will be THREE SEPARATE REQUESTS for each part (hours, minutes and seconds). My concern: what if I start to read time at the edge, when it will change itself inside of DS3232 ? Potentially, I could get weird results, like hours and minutes stay the same, but seconds has changed. Or even worth - hours is the same, but seconds and minutes has changed. Is there any method to read all three values (HH:MM:SS) by one single requests ? Or is there any other workaround for this issue ? Or it is not issue at all ? Thanks ! -- WBW, V.P. ___ time-nuts mailing list -- time-nuts@febo.com To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts and follow the instructions there. ___ time-nuts mailing list -- time-nuts@febo.com To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts and follow the instructions there.
Re: [time-nuts] Maxim DS3232 and I2C
At 04:20 PM 2/14/2014, d0ct0r wrote: hours is the same, but seconds and minutes has changed. Is there any method to read all three values (HH:MM:SS) by one single requests ? Or is there any other workaround for this issue ? Or it is not issue at all ? Thanks ! Sure, read multiple registers (0-2 to get seconds, minutes, and hours) in one IIC transaction. The chip will even help you out, as according to the datasheet: When reading or writing the time and date registers, sec- ondary (user) buffers are used to prevent errors when the internal registers update. When reading the time and date registers, the user buffers are synchronized to the internal registers on any START and when the register pointer rolls over to zero. The time information is read from these secondary registers, while the clock contin- ues to run. This eliminates the need to reread the regis- ters in case the main registers update during a read. -- newell N5TNL ___ time-nuts mailing list -- time-nuts@febo.com To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts and follow the instructions there.
Re: [time-nuts] Maxim DS3232 and I2C
Even on the primitive chips that don't have mutlipbyte reads and buffers. Just read it twice and see it the two reads are the same. On the one in the thousand case where they differ, read a third time. Problems only happen if you are so unlucky to read the time just before the seconds flip over and as I said, you detect a second flip by reading twice. But it appearts this chip is more sophisticated and has buffers On Fri, Feb 14, 2014 at 2:20 PM, d0ct0r t...@patoka.org wrote: I would like to ask an advise for following: Lets say I have a DS3232 RTC connected by I2C to some MCU. The maximum allowed I2C bus speed is 400KHZ. And I need to read time (HH:MM:SS) from it. It will be THREE SEPARATE REQUESTS for each part (hours, minutes and seconds). My concern: what if I start to read time at the edge, when it will change itself inside of DS3232 ? Potentially, I could get weird results, like hours and minutes stay the same, but seconds has changed. Or even worth - hours is the same, but seconds and minutes has changed. Is there any method to read all three values (HH:MM:SS) by one single requests ? Or is there any other workaround for this issue ? Or it is not issue at all ? Thanks ! -- WBW, V.P. ___ time-nuts mailing list -- time-nuts@febo.com To unsubscribe, go to https://www.febo.com/cgi-bin/ mailman/listinfo/time-nuts and follow the instructions there. -- Chris Albertson Redondo Beach, California ___ time-nuts mailing list -- time-nuts@febo.com To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts and follow the instructions there.
Re: [time-nuts] Maxim DS3232 and I2C
michael.c...@sfr.fr said: So if you do a multi-byte read to get the lot at once, then it should be coherent. I saw some code to do this somewhere, but I have lost track of it. For things like that, I tend to write some test code to sanity check my understanding. Then I let it run overnight to see if it will find any problems. Often it does. In this context, I'd have a loop that reads the time and checks to see that it is the same as the last time or has advanced by exactly one second. The same case means you did two reads within the same second. The advance-by-1 will fail if it takes more than a second to do a read. Sometimes adding a few counters and printing them out occasionally (say every hour, or million times around the test loop) is interesting. -- These are my opinions. I hate spam. ___ time-nuts mailing list -- time-nuts@febo.com To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts and follow the instructions there.
Re: [time-nuts] Maxim DS3232 and I2C
I think I found the information in the datasheet: The read operation can be used to read multiple bytes with a single transfer. When reading bytes from the slave, the master simply ACKs the data byte if it desires to read another byte before terminating the transaction. After the master reads the last byte it must NACK to indicate the end of the transfer and then it generates a STOP condition On an I2C START or address pointer incrementing to location 00h, the current time is transferred to a second set of registers. The time information is read from these secondary registers, while the clock may continue to run. This eliminates the need to reread the registers in case the main registers update during a read As far as I understood, I could specify the address and number of bytes to read. Then I could obtain all necessary fields using one transaction. I tried it - it seems it works. Thanks ! On 2014-02-15 14:19, Chris Albertson wrote: Even on the primitive chips that don't have mutlipbyte reads and buffers. Just read it twice and see it the two reads are the same. On the one in the thousand case where they differ, read a third time. Problems only happen if you are so unlucky to read the time just before the seconds flip over and as I said, you detect a second flip by reading twice. But it appearts this chip is more sophisticated and has buffers On Fri, Feb 14, 2014 at 2:20 PM, d0ct0r t...@patoka.org wrote: I would like to ask an advise for following: Lets say I have a DS3232 RTC connected by I2C to some MCU. The maximum allowed I2C bus speed is 400KHZ. And I need to read time (HH:MM:SS) from it. It will be THREE SEPARATE REQUESTS for each part (hours, minutes and seconds). My concern: what if I start to read time at the edge, when it will change itself inside of DS3232 ? Potentially, I could get weird results, like hours and minutes stay the same, but seconds has changed. Or even worth - hours is the same, but seconds and minutes has changed. Is there any method to read all three values (HH:MM:SS) by one single requests ? Or is there any other workaround for this issue ? Or it is not issue at all ? Thanks ! -- WBW, V.P. ___ time-nuts mailing list -- time-nuts@febo.com To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts [1] and follow the instructions there. -- Chris Albertson Redondo Beach, California Links: -- [1] https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts -- WBW, V.P. ___ time-nuts mailing list -- time-nuts@febo.com To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts and follow the instructions there.