Providing annoying users with an accurate timekeeping function is easy as long as the real-time operating system is running – things get interesting when the RTOS goes to sleep. A dedicated RTC such as ST Microelectronics’ MT41T62 provides a nice workaround.
M41T62, M41T64 and M41T65 differ from the classic Dallas Semiconductor real time clocks in that they do not contain a battery – providing a capacitor or a similar power supply is the sole responsibility of the circuit designer. The parts, however, do not need much in terms of power – 350 nA (yes, Nanoamps!!!) are enough for timekeeping. An example implementation would look like figure one.
Supercapacitors can keep an M41T62 happy for quite some time
The diode shown in the figure is needed to prevent balancing currents: if the main PSU is off and the diode is missing, backfeeding would deplete the capacitors charge and might even damage the PSU.
Communication with the host is established using a 400KhZ I2C interface. The chip itself stores time accurately, providing a hundreth-of-a-second resolution in some operating modes. Dedicated registers let you access the various components such as the date and the time – there is no need to fiddle around with epoch values on the M41T65 RTC. Configuring the part also is not difficult: just fire off a few I2C writes to set parameters stored in the various internal registers.
Like with most other parts, STM prides itself in providing three different versions of its venerable timekeeper IC. M41T62 and M41T65 both have an alarm function for waking up a microcontroller, while the M41T64 version foregoes the alarm capability for a dedicated oscillator output. SGS recommends you to use this timekeeping clock as a reference or clock source for microcontrollers – the limit, of course, is in your imagination.
Do, however, keep in mind that the housings are extremely small. All versions are available in a 3x3mm QFN16 package, while some parts come in even smaller housings which contain the 32khz crystal required for timekeeping operation.