Phillips PCF8593 RTC
Has anyone used this chip with an SX uC?
i need it running at off a small 3v battery, so it does not loose the time. meanwhile, the sx will be running on the standard 5v.
has anyone done this before?
I attached the spec sheet, so that should help. All i keep getting back from it is %00000001 from every register.
any help would be great! Thanks!!!
here is my schematic:
pin 1 and 2 are connected to a 32.768 crystal
pin 3 to RE.2
pin 4 to ground
pin 5
pin 6 a 4.7k pullup to 3v, then a 470 to RE.1
pin 7 a 4.7k pullup to 3v, then a 470 to RE.0
pin 8 to 3v
Here is my code:
SDA PIN RE.0 INPUT PULLUP
SCL PIN RE.1 INPUT PULLUP
CLOCK_ID_W CON %10100010
CLOCK_ID_R CON %10100011
ACK CON 0
NCK CON 1
TEMP VAR BYTE(6)
ACKVAR VAR BIT
Start:
LOW RE.2
PAUSE 500
high RE.2
PAUSE 2000
Main:
I2CSTART SDA
I2CSEND SDA, CLOCK_ID_W, ACKVAR
I2CSEND SDA, $01, ACKVAR
I2CSTART SDA
I2CSEND SDA, CLOCK_ID_R, ACKVAR
I2CRECV SDA, TEMP(0), ACK
I2CRECV SDA, TEMP(1), ACK
I2CRECV SDA, TEMP(2), ACK
I2CRECV SDA, TEMP(3), ACK
I2CRECV SDA, TEMP(4), ACK
I2CRECV SDA, TEMP(5), NCK
I2CSTOP SDA
'then i have it send to a com port... this part works correctly though
goto main

i need it running at off a small 3v battery, so it does not loose the time. meanwhile, the sx will be running on the standard 5v.
has anyone done this before?
I attached the spec sheet, so that should help. All i keep getting back from it is %00000001 from every register.
any help would be great! Thanks!!!
here is my schematic:
pin 1 and 2 are connected to a 32.768 crystal
pin 3 to RE.2
pin 4 to ground
pin 5
pin 6 a 4.7k pullup to 3v, then a 470 to RE.1
pin 7 a 4.7k pullup to 3v, then a 470 to RE.0
pin 8 to 3v
Here is my code:
SDA PIN RE.0 INPUT PULLUP
SCL PIN RE.1 INPUT PULLUP
CLOCK_ID_W CON %10100010
CLOCK_ID_R CON %10100011
ACK CON 0
NCK CON 1
TEMP VAR BYTE(6)
ACKVAR VAR BIT
Start:
LOW RE.2
PAUSE 500
high RE.2
PAUSE 2000
Main:
I2CSTART SDA
I2CSEND SDA, CLOCK_ID_W, ACKVAR
I2CSEND SDA, $01, ACKVAR
I2CSTART SDA
I2CSEND SDA, CLOCK_ID_R, ACKVAR
I2CRECV SDA, TEMP(0), ACK
I2CRECV SDA, TEMP(1), ACK
I2CRECV SDA, TEMP(2), ACK
I2CRECV SDA, TEMP(3), ACK
I2CRECV SDA, TEMP(4), ACK
I2CRECV SDA, TEMP(5), NCK
I2CSTOP SDA
'then i have it send to a com port... this part works correctly though
goto main


Comments
You need to control pin 5 of the RTC, not the interrupt pin (pin 7)...
Look at the pinout:
You said:
pin 1 and 2 are connected to a 32.768 crystal
pin 3 to RE.2
pin 4 to ground
pin 5
pin 6 a 4.7k pullup to 3v, then a 470 to RE.1
pin 7 a 4.7k pullup to 3v, then a 470 to RE.0
pin 8 to 3v
But the part has SDA on pin 5, (which you have unconnected?) and then SCL on pin 6.... If this is true, you are not reading the output data, but instead you are reading the interrupt line, which could explain your unexpected answer.
~ Laura
here is the correct layout and code that now works.
SCHEMATIC:
pin 1 and 2 are connected to a 32.768 crystal
pin 3 to RE.2
pin 4 to ground
pin 5 a 4.7k pullup to 3v, then a 470 to RE.0
pin 6 a 4.7k pullup to 3v, then a 470 to RE.1
pin 7
pin 8 to 3v
CODE:
SDA PIN RE.0 INPUT PULLUP
SCL PIN RE.1 INPUT PULLUP
ACK CON 0
NCK CON 1
ACKVAR VAR BIT
CLOCK VAR BYTE(4)
LOW RE.2
PAUSE 500
high RE.2
PAUSE 2000
I2CSTART SDA
I2CSEND SDA, $A2, ACKVAR 'address the chip with r/w bit set to write
I2CSEND SDA, $00, ACKVAR 'start writing at memory location $00
I2CSEND SDA, $80, ACKVAR 'pause the counter
I2CSEND SDA, $00, ACKVAR 'set fraction of seconds to 0
I2CSEND SDA, $00, ACKVAR 'set seconds to 0
I2CSEND SDA, $50, ACKVAR 'set minutes to 50
I2CSEND SDA, $12, ACKVAR 'set hours to 12
I2CSTOP SDA
PAUSE 10
I2CSTART SDA
I2CSEND SDA, $A2, ACKVAR 'address the chip with r/w bit set to write
I2CSEND SDA, $00, ACKVAR 'start writing at memory location $00
I2CSEND SDA, $00, ACKVAR 'start the counter
I2CSTOP SDA
Main:
I2CSTART SDA
I2CSEND SDA, $A2, ACKVAR 'address the chip with r/w bit set to write
I2CSEND SDA, $01, ACKVAR 'start at memory location 1 (fraction of seconds)
I2CSTART SDA
I2CSEND SDA, $A3, ACKVAR 'address the chip with r/w bit set to read
I2CRECV SDA, CLOCK(0), ACK 'read fraction of seconds
I2CRECV SDA, CLOCK(1), ACK 'read seconds
I2CRECV SDA, CLOCK(2), ACK 'read minutes
I2CRECV SDA, CLOCK(3), NCK 'read hours
I2CSTOP SDA
goto Main