cattledog:
If the rtc changes every second, why the need to readings at 5 ms intervals.
What are you doing with the returns from the rtc readings? Please explain more about the project.
I would also suggest that you revise the architecture to use the time library synchronized at intervals with the rtc. Requests within the library will be much faster than an i2c bus reading. The time library still ticks in seconds, but you can use millis() for intermediate values.
Hi. Thanks for the reply. I am building a clock with 6 Nixie lamps and an Arduinix shield (http://www.arduinix.com). I will elaborate for those who do not know about this kind of display, so jump to the next paragraph if you already know how they work. Given the limited number of outputs of the Arduino boards, the lamps are multiplexed and only a couple of them are illuminated at any given point. Therefore, the display needs to be constantly refreshed and each pair of lamps is excited for a few milliseconds before illuminating to the next pair of lamps. The less time a lamp is illuminated the less bright it is, so you need to light up a lamp for at least 4 milliseconds to have good visibility of the digit. Due to the high refresh rate the naked eye cannot tell the difference, generating the illusion that all lamps are illuminated at the same time.
Most Nixie clock projects use a delay() function to wait for a the lamps to turn off, generating an idle time in which nothing is done (a pair of lamps are turned on, there is a delay of a few milliseconds, and then the lamps are turned off before moving to the next pair of lamps). I have implemented a task scheduler so I do not have to use any delay() functions and I can benefit of that window of time to perform other operations, like making an RTC request while the the lamps are on. I could use the millis() function to keep track of time, as commented above by another user, but I have noticed that it has a bit of drag and is less precise than the RTC.
In this scenario I have no trouble implementing the RTC request, it works smooth and without hiccups. However, I have also implemented a crossfade effect that allows a smooth transition between digits. This is achieved by gradually illuminating a digit for less and less time in each cycle until it is no longer lit, at the same time than the new digit is illuminated for longer periods of time, so it makes the illusion of both digits being lit at the same time, generating a fade-in-fade-out effect. The number of milliseconds a lamp is on will vary when a digit transition is taking place, but it offers a sporadic gap of 6 ms once the transition to the new digit is completed and the animation is over (which takes an overall time of 400 ms, so it is follow by a period of 600 ms in which the lamps are constantly lit for periods of 6 ms that can be used for other operations, such as updating the time). I make an RTC request every 500 ms, so that should not be a problem. The gap of 6 ms in which the lamps are on is right about the time it takes to make an RTC request, but if you sum up the time it takes to make and RTC request to the time lost in all the calls up and down the stack it takes a bit more than 6 ms to retrieve the time and perform the other operations. I notice that every second there is a slight blink in the nixie lamps, which I attribute to the elapsed time in the RTC request. I am not totally sure if this is really the source of the problem, but in my opinion this is the most plausible cause.
I do not trust that much the onboard RTC of the Arduino M0 Pro, I think it is not very precise, and the DS1307 model I am testing seems to be also a bit crappy, they both drag a few seconds of lag every few days, so I was wondering if other RTC models out there might be a bit faster in responding to RTC requests, but I am not sure if this depends more on the hardware of the software. I have tested a couple of different Arduino boards with different RTC and libraries and in both I get the same result.