|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
PCF8583 Writing-Reading |
Posted: Wed Mar 09, 2005 2:19 am |
|
|
i wrote datetime informotion to pcf8583 part.
next, first (sometimes 2) datetime reading not same written data.
same reading routine reads first time wrong data than correct data.
yes, test routines can read correct data but not first time.
i ordered new part, maybe device error?
i test several routines from internet, i wrote my own, still same. Even i tried to stop clock before writing to prevent device malfaction.
any idea?
Write> 09:47:55 21/11/2002 -WRITING
Read> 01:00:50 00/11/2003 ***WRONG READING
Read> 09:00:14 00/10/2003
Read> 09:47:55 21/11/2003 -CORRECT
Read> 09:47:56 21/11/2003
Read> 09:47:57 21/11/2003
Read> 09:47:58 21/11/2003
Read> 09:47:59 21/11/2003
some writing code
Code: |
//SINGLE BYTE WRITING
void PCF8583_WriteDateTimexy(int8 pyear, int8 pmonth, int8 pdate, int8 pweekday,
int8 phour, int8 pminute, int8 pseconds)
{
int8 data;
printf("\n\r%02u:%02u:%02u %02u/%02u/20%02u", phour,pminute,pseconds, pdate,pmonth,pyear);
PCF8583_WriteByte(1, 0);
PCF8583_WriteByte(2, bin2bcd(pseconds));
PCF8583_WriteByte(3, bin2bcd(pminute));
PCF8583_WriteByte(4, bin2bcd(phour));
PCF8583_WriteByte(5, bin2bcd(pdate) | (pyear<<6) );
PCF8583_WriteByte(6, bin2bcd(pmonth) | (pweekday<<5) );
PCF8583_WriteByte(200, pyear & 0x03);
PCF8583_WriteByte(201, pyear);
//delay_ms(1000);
//PCF8583_ReadDateTime(); //WRONG READ HERE
}
|
Other one
Code: |
//PAGE WRITING
void PCF8583_WriteDateTimeN(int8 pyear, int8 pmonth, int8 pdate, int8 pweekday,
int8 phour, int8 pminute, int8 pseconds)
{
int8 data;
short ackbit;
printf("\n\rW>%02u:%02u:%02u %02u/%02u/20%02u", phour,pminute,pseconds, pdate,pmonth,pyear);
i2c_init();
do
{
i2c_start();
ackbit = i2c_write(0xa0);
}while(ackbit);
i2c_write(0x01); //
i2c_write(0x00); //01
i2c_write(bin2bcd(pseconds)); //02
i2c_write(bin2bcd(pminute)); //03
i2c_write(bin2bcd(phour)); //04
i2c_write(bin2bcd(pdate) | (pyear<<6)); //05
i2c_write(bin2bcd(pmonth) | (pweekday<<5)); //06
i2c_stop();
PCF8583_WriteByte(200, pyear & 0x03);
PCF8583_WriteByte(201, pyear);
//PCF8583_ReadDateTime(); //WRONG READING
}
|
and also some codes from Peter Anderson's web site, and others...
i have also have 24lc256 on the same bus with 3.3K pullups. |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Wed Mar 09, 2005 8:17 am |
|
|
Some of these RTC's have a register lock to prevent accidental writing
EX you might have to write to the daylight savings reg before you can write to any of the other registers. I know its not the error pattern you're getting but still check the documentation. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 09, 2005 9:59 am |
|
|
Since your problem is in the reading, you should post the read routine
as well. Also post the i2c_init() routine. |
|
|
Guest
|
|
Posted: Wed Mar 09, 2005 12:19 pm |
|
|
this problem solved but another strange problem appeared!!!
my pcf8583 has no error, i tested with new pcf8583. same problem occured.
when i desoldered 24lc256, datetime reading problem solved! i think, maybe 24lc256 has errors, but it works perfectly while i have pcf8583 reading problems. i put it programmer and read, write it correctly.
i tried with another 24lc256 and new pcf8583 still same problem happened.
now i'm sure it's a hardware problem. i'm using 18f452 and hardware i2c bus. i will try same pic chip but software i2c bus. then i will use new pic.
at beginning, i assume that is a software problem.
as a result, the code shown above working. no software related problem.
thanks to both of you ! |
|
|
Kenny
Joined: 07 Sep 2003 Posts: 173 Location: Australia
|
|
Posted: Wed Mar 09, 2005 3:59 pm |
|
|
There may be an address conflict. If the A0 pin of the PCF8583 is tied to common, and A2,A1 and A0 of the 24LC256 are also tied to common, the addresses will be the same ie. 0xa0.
If so, tie one of the address lines to +5V and change the code to suit.
HTH |
|
|
Guest
|
|
Posted: Tue Mar 15, 2005 6:53 am |
|
|
thanks a lot Kenny.
you saved me from big trouble!
the problem above, comes from faultly pic i2c hardware. soft i2c and another pic18f452 worked. eeproms a0, a1,a2 connected to logic 1.
but i was planning to use 8 * 256K eeprom. this means the address conflict.
when i read your post i checked datasheets for details and changed schematics and pcb.
now everything complated. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|