Datasheet

Jon Waddington
44
In this example, the Propeller transmits the Start Condition, followed by the read
address for the PCF8563. An acknowledge bit is received and the Propeller sends the
address of the minute register. The PCF8563 acknowledges the request and then sends
the value of the register. The PCF8563 then leaves the SDA line high to inform the
Propeller that no more data will be transmitted and the Propeller transmits a Stop
Condition.
3.8.3 Setting the Time and Date
The SPIN code below shows how the hours are set when setting the time in the program.
PRI sett | h, m
{{shows the set time menu}}
text.out($00) 'clear display
showtime(3, 3) 'show current time at X, Y
h := gethour 'get hour and minute
m := getminute
text.colour(2) 'change text colour to yellow
repeat until code == enter 'repeat until enter is pressed
text.xy(3, 3)
text.dec(h>>4 & $03) 'show hour (BCD)
text.dec(h & $0F)
repeat until rc.getcommand 'wait until a button is pressed
code := rc.getcommand
rc.flush
if code == down 'increment hour
++h
if (h & $0F) => 10
h &= $30
h += 16
if (h & $3F) => $24 'loop hour
h := 0
if code == up 'decrement hour
if (h & $0F) > 1
--h
elseif (h & $30) > 0
h -= 16
h |= $09
else 'loop hour
h := $23
text.xy(3, 3) 'show set hour in white
text.colour(0)
text.dec(h>>4 & $03)
text.dec(h & $0F)
text.str(string(":"))