Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

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

Status
Not open for further replies.

kyul

Newbie level 3
Joined
Jan 31, 2005
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
26
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??

MArco
 

kyul

Newbie level 3
Joined
Jan 31, 2005
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
26
pcf8593 pic

Can anybody help me???
 

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,309
Reputation
4,620
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,459
$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
void
write_clk(byte address, byte data)
{
i2c_start();
i2c_write(CLK_WRITE);
i2c_write(address);
i2c_write(data);
i2c_stop();
}
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 ..

Regards,
IanP
 

silvio

Advanced Member level 3
Joined
Dec 31, 2001
Messages
716
Helped
105
Reputation
210
Reaction score
16
Trophy points
1,298
Location
Romania
Activity points
11,497
pcf8593

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
 

kyul

Newbie level 3
Joined
Jan 31, 2005
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
26
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 !!!!!!
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top