English
Language : 

PIC32MX440F256H-80I Datasheet, PDF (479/646 Pages) Microchip Technology – 64/100-Pin General Purpose and USB 32-Bit Flash Microcontrollers
21.2 Clock Calendar Mode
The PIC32MX RTCC module provides clock and
calendar functions with the following features:
• 100-year clock and calendar with automatic leap
year detection.
• Clock range from 00:00:00 (midnight) on January
1, 2000 to 23:59:59 on December 31, 2099.
• Clock granularity of one second with half-second
visibility to the user.
21.2.1 RTCC CONFIGURATION
The RTCTIME and RTCDATE registers can be
programmed with the desired time and date numeric
values expressed in Binary Coded Decimal (BCD)
format. This simplifies users’ firmware as each of the
digit values is contained within its own 4-bit value (see
Figure 21-2).
FIGURE 21-2:
TIMER DIGIT FORMAT
YEAR
MONTH
DAY
DAY OF
WEEK
0-9 0-9
0-1 0-9
0-3 0-9
0-6
HOURS
(24-hr format)
0-2 0-9
MINUTES
0-5 0-9
1/2 SECOND
BIT
SECONDS (binary format)
0-5 0-9
0/1
PIC32MX3XX/4XX
21.2.2 SAFETY WINDOW FOR REGISTER
READS AND WRITES
The RTCTIME and RTCDATE registers can be safely
accessed when the RTCC module is disabled (ON bit
(RTCCON<15>) = 0). However, when the RTCC mod-
ule is enabled (ON bit = 1), the module provides a single
RTCSYNC bit (RTCCON<2>) that the user must use to
determine when it is safe to read and update the time
and date registers.
The RTCSYNC bit indicates a time window during which
the RTCC time registers (RTCTIME, RTCDATE) are not
about to be updated and can be safely read and written.
For read or write operations, the registers can be safely
accessed by the CPU when RTCSYNC = 0.
For a read operation when RTSYNC = 1, the user must
employ a firmware solution to assure that the data read
did not fall on an update boundary, resulting in an
invalid or partial read. For example, reading and com-
paring a Timer register value twice can ensure in code
that the register read did not span an RTCC clock
update.
Write operations to the Time and Date registers should
not be performed when RTCSYNC = 1. Refer to
Example 21-2 and Example 21-3.
The user can configure the current time by simply writing
the desired year, month, day, hour, minutes and seconds
to the RTCTIME and RTCDATE registers. However,
these registers are write-protected and require a spe-
cial “unlock” sequence to be performed prior to writing
to these registers. Additionally, the user should verify
that the RTCSYNC bit (RTCCON<2>) = 0 (safe to
access registers) for any read or write operations.
Refer to Section 21.2.3 “Write Lock” and
Example 21-3.
© 2008 Microchip Technology Inc.
Preliminary
DS61143E-page 477