Software Real-Time Clock and Calendar Using PIC16F1827: Data Interface
Software Real-Time Clock and Calendar Using PIC16F1827: Data Interface
Current Date/Time
The basis of the Real-Time Clock (RTC) is the Timer1 0x02 Time Minutes 00-59
counter. This timer can be configured to accept a clock 0x03 Hour 0-23
source from the internal low-power oscillator. This
internal circuit is used in conjunction with an external 0x04 Day 0-6
32.768 kHz crystal. The oscillator has the ability to work 0x05 Date 1-31
during Sleep mode. This feature can be very helpful if Date
0x06 Month 1-12
the Real-Time Clock and Calendar circuit is to be
0x07 Year 0-99
powered from a battery. The Timer1 register pair
Alarm Date/Time
Timer1 can operate during Sleep mode to help reduce 0x0D Time Seconds 00-59
Current/Date/Time
TABLE 2: MONTHS
January 0 (in leap year 6)
February 3 (in leap year 2)
March 3
April 6
May 1
June 4
July 6
August 2
September 5
October 0
November 3
December 5
POSSIBLE UPGRADES
The current implementation updates the time and
calendar once every second. In the previous chapter,
we learned that, in order to preserve more power, the
processor must stay in Sleep mode as much as
possible. Thus, the time spent in Active mode, when
the power consumption is higher, must be kept as short
as possible. One possible upgrade would be to have a
32-bit register incremented once every second. This
will help minimize the on-time of the microcontroller
even more. The only task the processor will do during
the active period would be to increment the counter.
The actual conversion between the counter and the
date and time will be made on demand, during an I2C
data transfer. Wake-up alarms or time-triggered events
can also be implemented using this 32-bit time-stamp
method.
• Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
03/26/09