I have not used the Philips RTC but I am sure the basic device will be similar to the DS 1629 that I use.
I notice you are writing to the chip in single bytes. You should be able to write an entire string and save on the eerom write delays.
Here is a code snip.
ConfigureClock:
i2cwrite sda, scl, %10011110, $AC, [$A0]
' Write to Configuration Register $AC with value $A0.
' See page 10 of DS1629 data sheet. Disables all alarms.
SetClock:
' Set up current time parameters - MUST be in BCD format
' note HEX is the same as BCD for this application
' Set for UTC which is AEST - 10 hours
' debug 13, 10, " Writing to clock", 13, 10
RTCSec = $00 ' Seconds NOTE 00 enables, 80 halts oscillator
read 49, RTCMin ' Minutes
read 50, RTCHour ' Hours
read 51, RTCDate ' Date
read 52, rTCMonth ' Months
read 53, RTCYear ' Year
RTCWDay = $04 ' Weekday - arbitrary number 1-7 (not used)
WriteClock: ' Write setup info.
I2Cwrite SDA,SCl,%10011110,$C0,$00,[RTCSec,RTCMin,RTCHour,_
RTCWDay,RTCDate,RTCMonth,RTCYear]
' set DS1629 into 'convert on demand' mode to save power
' write to $AC -
' No Alarm, active LOW, single conversion on command
' MSB = %00000101
i2cwrite SDA, SCl, %10011110, $AC, [ %10100000]
gosub lowestpower
end
And another snip.
ShowTime:
'fetch current time
I2CRead SDA,SCl,%10011110,$C0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,_
RTCDate,RTCMonth,RTCYear]
'display current time
debug $0D, $0A, "200", #rtcyear & $0F, "/", #rtcmonth >> 4 & $0F,_
#rtcmonth & $0F , "/", #RTCDate>> 4 & $0F, #RTCDate& $0F, ", ",_
#rtchour >> 4 & $0F, #rtchour & $0F, ":", #rtcmin >> 4 & $0F,_
#rtcmin & $0F,":", #rtcsec >> 4 & $0F, #rtcsec & $0F
HTH
Brian




Bookmarks