PCF8563 date data corrupted
PIC16F628, Pic Basic Pro 2.60, Pickit programmer
Good day ,
Below is my code to read the PCF8563:
I2Cread SDA,SCL,rtcadd,rtcloc,[secs,minu,hrs,DoM,doW,mon,year]
gosub waita 'read D&T data then wait 10ms
write $20,secs,minu,hrs, DoM,doW,mon,year 'write D&T data to F628 eeprom
When I read the data in the F628 eeprom I get correct minutes seconds and hours but the DoM,dOW,mon,year
data is corrupt. Every time I run that code the calendar data changes to something different and sometimes
some of the data is correct.
When I set alarms they work correctly.
When I replace the PCF8563 with a DS1307 and change the addresses accordingly, the program works perfectly.
I want to use this PCF8563 because it has alarms and battery voltage sensing that the DS1307 doesn't have.
I have also tried 3k3 resistors on SCL & SDA instead of 4k7 but that made no difference.
Can somebody help please.
Re: PCF8563 date data corrupted
you need to mask off the bits that are not used for the value being returned
Code:
minu = minu & $7f
hrs = hrs & $3f
Dow = dow & 7
Dom = dom & $3f
mon = mon & $1f
Re: PCF8563 date data corrupted
Thank you very much Richard , your advice fixed my problem.
I am so happy 'cause I really like this chip.
Now I can apply my mind to getting an interrupt every minute which
appears to be quite cumbersome.
Regards
Hebe