Is there an application note regarding the procedure to use to read/write the registers of the BQ32000 Real Time Clock?
In particular, should I set the STOP bit in the seconds register before I set the clock?
If I want to read the date/time registers, how do I do so to prevent roll-over while I'm reading? Even though the register update happens internally all at the same time (so the output is glitch free), what happens if I read seconds, then it rolls over, then I read minutes?
Is the normal process to read the device twice and compare the two reads to make sure they are the same? Or is there an alternate/preferred method? i.e. If I read all date/time registers in one I2C read cycle, will that guarantee that there is no roll-over in the registers during the read? Or should I stop the oscillator (yuk), read the registers, and then start the oscillator again?
Thanks for your help.
I believe that all this information is in the datasheet. Please take a look and let me know if anything is still missing.
Motor Drive Application Manager
Unless I can't see the forest through the trees, the only mention that I've found in the data sheet is, "The time registers are normally updated once per second, and all the registers are updated at the same time to prevent a timekeeping glitch." (p.1 in Description section)
I'm currently running a continuous test where I set the clock by writing registers 0-6 in one I2C transfer and I read them back in one transfer. So far, I haven't seen any issues with the read-back being different than expected (some tests wait 1.5 sec for the clock to rollover before reading back the time ... all tests assume that the timer could increment once between the write and the read and take that into consideration when determining whether the value read is correct).
I'm assuming that the BQ32000 has an intermediate buffer, or similar, that all the registers are copied into when an I2C address match with Read is detected and that this intermediate buffer is what feeds the SDA line so that there's no chance of one register changing while another one is being shifted out.
I also assume that if I set up my test read method to read registers 0-6 one register at a time, that I would see occasional roll-over errors if SECONDS was read at 59 on one I2C read, then it rolled over to 0, then MINUTES was read on the next I2C read. (even if the two reads were very close together)
The data sheet doesn't comment on this. It says that the registers are all updated at the same time. Meaning, I assume, that at any particular instant there is no error internally in the presented data. Unfortunately, since I can't read all registers in the same instant, because they have to be shifted out serially, I'm not guaranteed that the values read will be glitch free. (unless there's an intermediate buffer of sorts)
So I was just wondering if there was a preferred method for reading the part to guarantee that the values read were correct.
Thanks for taking a look at my request.
The BQ32000 has an internal buffer which is updated with the RTC counter data every second. The user only has access to this internal buffer and not the real time keeping counters. If the user is in the process of reading the time from the internal buffer, the 1 second update is stopped until the read is complete. The internal buffer is then updated immediately after the read is complete (instead of waiting for the next 1 second update).
As a result the user will never see a rollover condition while doing a read of the registers. I hope this answers your question.
Thanks Ryan. I believe I have the answer to my question, which is that I need to read registers 0-6 in one operation to prevent rollovers in *my* accumulated result. i.e. your description tells me that the scenario I painted earlier would cause a rollover in the data if I assembled it by reading the RTC one register at a time.
RTC has 10:01:59 (hh:mm:ss) on the clock
Read SECONDS (get the value 59)
RTC "one second" update occurs during the previous read, but is held off until read is complete
RTC now has the value "10:02:00" on the clock
Read MINUTES (get value 02)
RTC still has the value "10:02:00" on the clock
Read HOURS (get value 10)
Assemble time inside microprocessor from values read produces the time 10:02:59 -- clearly this is not correct. It should be either 10:01:59 or 10:02:00 but because the registers were read one at a time, instead of six at a time, the rollover in the RTC found its way into the microprocessor.
Reading the registers the other direction (from HOURS to MINUTES to SECONDS) wouldn't help as a rollover between minutes and seconds would produce a time of 10:01:00.
So, I have to use one TWI bus transaction to read registers 0-6 in a single operation.
Please forgive me for being so pedantic and thank you for giving me a better idea of what's happening inside the RTC.
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.