Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to set the control register and the alarm register in Philips PCF8593?

Not open for further replies.


Newbie level 3
Jan 31, 2005
Reaction score
Trophy points
Activity points
Hello friends,
can anybody help me??
I'm using a philips pcf8593 as a real time clock for a pic 18F6720 but I'm not able to use the alarm functions and It's always late.
Can u make an example of how to set the control register and the alarm register in order to set a daily alarm???
Have u a good advice for the time jitter??


pcf8593 pic

Can anybody help me???

$a2 pcf8593

Here is an example on how to set an alarm in PCF85XX chips:

write_clk(CLOCK_CONTROL, 0x04); // stop 1Hz reset, enable alarm
write_clk(ALARM_WEEKDAY, 0x40); // weekly alarm on weekday 6
write_clk(ALARM_CONTROL, 0xA0); // enable weekly alarm and interrupt

The first argument is the address to write to. The ones used above are
defined as:

#define CLOCK_CONTROL 0x00
#define ALARM_CONTROL 0x08
#define ALARM_WEEKDAY 0x0E

And the function to set the alarm values is:

#define CLK_WRITE 0xA0
write_clk(byte address, byte data)

As far as the "clock problem" is concerned, there is almost nothing you can do fix it ..
This is common issue and the beauty (in its negative meaning) of these cheap RTC ICs with build-in generators and relaying on cheap 32,768kHz crystals ..
You can try to use a crystal from different batch, but that's probably all ..



An alarm signal is generated when the contents of the alarm registers (09 - 0E) matches bit-by-bit the contents of the involved counter registers (01 - 06).
A daily alarm ignores the month and date bits.
Thus registers contents whom address are 05 hex and 06 hex are ignored and is useless to set the registers at address 0D hex and 0E hex.
You must set only the registers at address 09 (hundredths of seconds), 0A (seconds), 0B (minutes) and 0C (hours). You can even ignore address 09 and 0A but if you want to be more precise.

Thus let's say you want an alarm daily at 07:14 AM early in the morning.

Your sequence must be:

1. generate I2C-bus start condition
2. send slave address 1010001W - A2 hex
4. send word address 00001000 - 08 hex
5. send data for alarm control register 10010000 - 90hex (see bellow)
6. send data for alarm hundredths of seconds 00000000 00hex at address 09 hex
7. send data for alarm seconds 00000000 - 00 hex at address 0A hex
8. send data for alarm minutes 00010100 - 14 hex at address 0B hex
9. send data for alarm hours
if you set 12h format with AM/PM send 10000111 - 87 hex at address 0C hex
if you set 24 h format send 00000111 - 07 hex at address 0C hex
10. generate I2C-bus stop condition
11. generate I2C-bus start condition
12. send slave address 1010001W - A2 hex
13. send word address 00000000 - 00 hex control/status register (see bellow)
14. send data 00000100 - 04 hex at addres 00 hex
15. generate I2C-bus stop condition

I did not check for slave acknowledge.
The memory word address is automatically incremented after each data byte write.

When INT line is driven low, read the Control/Status register at address 00 hex, clear the bit 1 and send it back to PCF8593 to release the INT line.
If you don't want any more the alarm, just clear the bit 2 of Control/Status register.

Contents of Alarm Control and Control/Status register sets for daily alarm.

Memory location 08 hex - Alarm Control register

1 - alarm flag interrupt - MSB
0 - no timer alarm
0 - daily alarm
1 - daily alarm
0 - timer flag no interrupt
0 - no timer
0 - no timer
0 - no timer - LSB

Memory location 00 hex - Control/Status register

0 - count pulses - MSB
0 - count
0 - clock mode 32.768 kHz
0 - clock mode 32.768 kHz
0 - read locations 05 to 06 unmasked
1 - enable Alarm Control register location 08 hex
0 - alarm flag
0 - timer flag - LSB

i2c pcf 8593

Thank you!!!!!!!!!!!
Now it's working!!!!!!!!! The problem with my software was that I forgot to inizialize to 0x00 the alarm hundredths and so the interruts never happened !!!!!!

Not open for further replies.

Part and Inventory Search

Welcome to