Electronic – ny Real time clock (RTC) which provides time resolution in microseconds

microcontrollerrtcrtostime

I've been searching for high precision RTCs on Google but almost all RTCs like DS12C887, DS1307 provide time resolution in seconds which is ok for general use. But is there any RTC IC which can provide more fine resolution like in milli seconds and microseconds?

Best Answer

I've often found it frustrating that external RTC devices (and for that matter even internal ones, for reasons I can't fathom) seldom offer resolution anywhere near that of the incoming time base, but I would find it extremely unlikely that any conventional RTC device would offer microsecond accuracy in any case. RTC chips are designed to minimize power consumption when the system is idle, and an RTC chip which used a 1MHz clock would almost certainly use more than 30 times as much energy as one that used a 32KHz clock.

Depending upon what you are trying to do, and your system's waking/sleeping patterns, it may be possible to use an RTC with somewhat coarse resolution in conjunction with a higher-speed timer/counter circuit which is triggered by an external event. Operation would be something like:

  • Have everything wait while asleep until the external event occurs

  • When the event occurs, start up a ~5MHz non-precision clock and start counting

  • Log the count and RTC time at the first tick of the RTC clock following the event

  • Log the count at the second tick of the RTC clock following the event

The difference between the count values at the two RTC ticks will indicate the rate of the non-precision 5MHz clock, and the count value at the first event will indicate how long before the first RTC tick the event took place.

For example, suppose that the RTC can be read in units of 1/256 second. On receives an event when the RTC clock reads 12:34:56 78/256. The RTC clock advances to 12:34:56 79/256 when the count reads 1,000, and then advances to 80/256 when the count reads 20,000. One could then figure that the "5MHz" clock was running at a speed of 4,864,000Hz, and thus the event happened 1,000/4,864,000 second before that second timer tick, which is to say--if the RTC clock was precisely correct--at a time of 12:34:56.3122944.

Note that one would have to wait up to 1/128 second to know the exact time when an event had occurred, but once one had seen the RTC advance twice one would know within a fraction of a microsecond the time of the event [and could thus determine very precisely the time between two distinct events between which the CPU had been sleeping]. Some Lattice Mach series CPLDs have a fast-starting clock oscillator which runs at 5MHz nominal, and have relatively low sleep currents, and thus might be usable for this sort of timekeeping.