How Much Can be Stored?
Users get to select which logging rate they want
and, as a result, incur a total logging time — if all total
EEPROM is to be filled. When you examine all the
supported RTCC rates and the total number of records
that can be stored, the total logging time becomes quite
impressive. We decided to cap the logging time to 100
years (after all, the RTCC is just a 100 year clock
/calendar). For additional flexibility, the data logger (during
logging operation) can be toggled on or off as needed to
shorten logging times.
The Real Time Clock Calendar
■ FIGURE 5. RTCC Value Registers.
additional spare area to store total record count). We work
the EEPROM using the EEPROM library previously
For retrieval, the record is “unpacked” and converted
back to ASCII for viewing on an LCD display or
downloading to a PC using the serial port. The EEPROM
eight byte record is expanded to 16 character bytes (see
Figure 3). If the record is transferred to the PC, it is
additionally formatted with spaces and carriage return/line
feeds for a nice visual presentation on the Hyper Terminal
■ FIGURE 6. Counting Times in the RTCC.
The RTCC function is intended for applications where
accurate time must be maintained for extended periods of
time with minimum to no intervention from the CPU. The
peripheral is optimized for low power usage in order to
provide extended battery life while keeping track of time.
It features the 100 year clock/calendar with automatic
leap year detection. The range of the clock is from
00:00:00 (midnight) on January 1, 2000 to 23:59: 59 on
December 31, 2099. The hours are available in a 24 hour
(military time) format. The clock provides a granularity of
The RTCC internal register interface with the PIC24F
microcontroller is implemented using the Binary Coded
Decimal (BCD) format. This simplifies the software when
reading and writing to the module, as each of the digit
values is contained within its own four-bit value.
The RTCC module is clocked by an external real time
clock crystal that oscillates at 32.768 kHz. The
Experimenter comes with this crystal. The
clock crystal connects to the PIC24F and
works in conjunction with internal logic
counters within the RTCC module to derive
time (see Figure 6).
Using the RTCC Library
■ FIGURE 7. Data Logger Serial Interface.
The Experimenter comes with an RTCC
software library. The library contains a number
of C function routines to initiate clock
operations, set time/date, and read current
time/date. We use all the clock functions for
the data logger. In order to use the RTCC
library, a #include RTCC.H must appear in
your MAIN code, and the RTCC.C driver
source code must be included as part of your
project. We will also use an alarm setting
function that works off of the RTCC to “alarm”
or, in our case, to initiate a logging activity
(more on this later).
• RTCCInit() — This function sets up the clock
and initializes it to a default date and time.