Re: Controlling PCF8583 clock chip with a PIC
From: John Gruenenfelder (johng_at_as.arizona.edu)
Date: Mon, 06 Dec 2004 13:56:39 -0700
On Sat, 04 Dec 2004 02:00:58 +0100, Jeroen wrote:
> "John Gruenenfelder" <firstname.lastname@example.org> wrote in message
>> I have a board set up with a PIC16F877 microcontroller and on the I2C bus
>> I have a Phillips PCF8583 clock/alarm chip.
>> I am attempting to use the alarm function of this chip and thus far am
>> having almost no luck getting it to work. I know the I2C bus is good
>> because I have several other devices on it plus the clock function of this
>> chip is working fine.
>> Specifically, no matter what type of alarm I instruct the chip to enable
>> (i.e. daily, weekly, etc.) none of them seem to function. I can test this
>> by checking the interrupt output pin of the chip with a scope. The
>> interrupt generation is enabled, but nothing shows on the pin.
>> I realize this is rather general. My hope is that somebody else has used
>> this chip and may be able to help me with my problem. If, by any remote
>> chance, you have, please contact me or post a followup.
> The interrupt output seems to be a open drain output... So it will only
> supply a path to ground when an interrupt is active, or high impedance when
> not; in other words, you will see nothing on your scope... Add a pull up
> resistor to VCC.
Our board is set up correctly in this respect. The pull up resistor is
there, and we have tested the power-on 50% duty cycle interrupt generated
by the 8583 which does work. It's just the interrupt that is to be
triggered by the alarm function which never occurs.
For a little more information, here is how I am setting the alarm:
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
#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)
That's about it. It's really simple, but it just doesn't seem to work.
The I2C functions are verified as there are used extensively elsewhere.
The values are set properly in the clock/alarm. They can be read back and
-- --John Gruenenfelder Research Assistant, Steward Observatory, U of Arizona email@example.com Try Weasel Reader for PalmOS -- http://gutenpalm.sf.net "This is the most fun I've had without being drenched in the blood of my enemies!" --Sam of Sam & Max