PCF8563 Real Time Clock

OSCIN 1 -PCF-
-
8563-
8 VCC
OSCOUT 2 7 CLKOUT
!INT 3 6 SCL
GND 4 5 SDA
Pin Names and functions
CLKOUT Clock output
!INT Interrupt.
SDA, SCL I2C bus
OSCIN, OSCOUT Connect to 32768 Hz watch crystal.
Vcc Power (1V8 to 5V5 DC)
GND Ground

Registers

00 control/status 1
01 control/status 2
02 VL seconds 00 to 59 coded
in
BCD
03 - minutes 00 to 59
04 - - - - - hours 00 to 23
05 - - - - - days 01 to 31
06 - - - - - weekdays 0 to 6
07 C - - - - months 1 to 12
08 - - - - - years 00 to 99
09 AE minute alarm 00 to 59
0a AE - hour alarm 00 to 23
0b AE - day alarm 01 to 31
0c AE - - - - weekday alarm 0 to 6
Address = 1 0 1 0 0 0 1 r/!w

Developer's notes

When I first fired up this device, and reading the raw data, some of the bytes were changing values unexpectedly. The seconds and minutes seemed fine though.

After clearing everything to zero, I noticed that the hours register was 40 (BCD) whenever the seconds register was >= 40. Bit(s) from one register are appearing in others! That explains why the mystery bits changed consistently, instead of randomly as you would expect signal noise to be. Looking at the data sheet, the hour is BCD coded in D5-D0, while D7 and D6 are undefined. They are not legally bound to be anything at all!

So although puzzling at first, this behaviour is not a bug or noise.

Definite bug!

The device does not handle leap years correctly. The data sheet states that:

"The PCF8563 compensates for leap years by adding a 29th day to February if the year counter contains a value which is exactly divisible by 4, including the year ‘00’."

Jean Meeus' book Astronomical Algorithms states (on page 62) that:

"...centurial years that are not divisible by 400, such as 1700,1800,1900 and 2100, are common years.
The other century years which are divisible by 400, are leap years, for instance 1600,2000, and 2400."

Therefore this chip behaves correctly for years 1901 to 2099, but will mistake 2100 for a leap year! You heard the Y2K1 bug warning here first, but I won't be around by that time! :-)