I have this. Hope it helps you
Code:' RTC registers ControlReg con 0 SecondsReg con 2 DayYear con 5 Month con 6 TimerReg con 7 AlarmReg con 8 Time var byte[3] '================================================================================ ' I2C RTC PCF8583 CODE using I2C_read and I2C_write routines of compiler '================================================================================ ' RTC registers are defined ' 0 - Command / Status register ' .0 timer flag ' .1 alarm flag ' .2 alarm enable 1 - enabled ' .3 mask flag ' .54 function 00 clock 32.768KHz/01 clock 50Hz/10 evt counter/11 test ' .6 hold last count flag ' .7 stop counting, reset divider ' 1 - 1/10 s | 1/100s ' 2 - 10s | 1s seconds ' 3 - 10m | 1m minutes ' 4 - 10h | 1h hours ' .3..0 unit hours BCD ' .54 10s hours 0..2 binary ' .6 1 PM ' .7 1 12 hour format ' 5 - 10d | 1day Day & Year ' .3..0 unit days BCD ' .54 ten days 0..3 binary ' .76 year 0..3 binary (read 0 if mask) ' 6 - 10mo | 1month month ' .3..0 unit months BCD ' .4 ten months ' .7..5 weekdays 0..6 binary (read 0 if masked) ' ' 0x10 to 0xff RAM ' If RTC is not running, start it TimerOff: I2CWRITE SDA, SCL, $A2, ControlReg, [0] return ' Read the time in BCD format RTC_GetTime: I2Cread SDA, SCL, $A2, SecondsReg+0, [Time[2],Time[1],Time[0]] return ' Set time in BCD format RTC_SetTime: I2Cwrite SDA, SCL, $A2, SecondsReg+0, [Time[2],Time[1],Time[0]] goto TimerOff ' *********************************************************************** ' End of 8583 code ' ***********************************************************************




Bookmarks