When you get right down to it, the TinyRTC is really
little more than a breakout board for the DS1307 clock
chip and the AT24C32 EEPROM. So, everything described
in this article can be applied to those two ICs should you
really want to tax your eyes and solder up some surface-mount chips on your own. You can spot the two tiny
integrated circuits in Figure 1.
The reverse side (shown in Figure 2) shows the
rechargeable lithium-ion battery in its piggyback holder. If
it isn’t obvious, this means that the clock continues to
keep time even if main power to the circuit is absent.
When power is there, the battery is kept fully charged.
It’s pretty clear that the module was originally created
with the Arduino crowd in mind. In fact, that community
already has libraries available for
putting the TinyRTC through its paces.
Many people — me included — prefer
working from scratch with the PIC for
implementations costing far less than
the Arduino approach, however. Does
that mean we have to start all over
again in assembly language? Not at all!
I’ll show you how to easily get the
TinyRTC up and running on a PIC and
— best of all — in the easy-to-use Basic
language. Let’s tuck in.
All About the
As mentioned, at the heart of the
TinyRTC is the well-known DS1307
chip. Within this IC are eight registers
which allow you to set things up and
monitor the time and date. Figure 3
gives the details. Though pretty self-explanatory and complete, there are a
few points deserving a little extra
explanation for newcomers.
The various numbers stored within
these registers are in binary-code-decimal (BCD) format, which is
particularly handy when printing things out to an LCD,
among other things. Recall that in this scheme, a single
byte (eight bits) can store a two digit number; the lower
nibble specifies the unit’s place, and the higher nibble
gives the ten’s place. As it turns out, when referring to
time and date, not all of the bits within the higher nibble
will be needed.
For example, with minutes and seconds, the greatest
number which can occur is 59, meaning that only three
bits are required to represent the ten’s place digit.
What about dates? The largest number you’ll have to
worry about is 31 — the greatest number of days to
appear in a month. In this case, only two bits need to be
spent in the higher nibble to represent that ten’s place
April 2015 49
Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/
FIGURE 1. FIGURE 2.