I noticed you have "rtccontrol Var byte" but no value assigned to it, then used in the "gettime" sub-routine.
What is supposed to happen there?
I would also suggest using a button input to jump to "settime" so you only have to program once and just push the button to set the time while its running.
Code:
' Main program loop - in this case, it only updates the LCD with the time
mainloop:
Gosub gettime ' Read the time from the RTC
' Display time on LCD
Lcdout $fe, 1, hex2 rtcmonth, "/", hex2 rtcdate, "/" , hex2 rtcyear," "
Lcdout $fe,$C0, hex2 rtchr, ":", hex2 rtcmin, ":", hex2 rtcsec
Pause 30 ' Do it about 3 times a second
IF !switch THEN GOSUB settime
Goto mainloop
End
And add a While/Wend for the switch so it waits before going back or else it'll be continuously setting the time until you release the button.
Code:
settime:
RST = 1 ' Ready for transfer
Shiftout IO, SCLK, LSBFIRST, [$8e, 0] ' Enable write
RST = 0 ' Reset RTC
RST = 1 ' Ready for transfer
' Write all 8 RTC registers in burst mode
Shiftout IO, SCLK, LSBFIRST, [$8e, 128]
Shiftout IO, SCLK, LSBFIRST, [$be, rtcsec, rtcmin, rtchr, rtcdate, rtcmonth, rtcday, rtcyear, 0]
RST = 0 ' Reset RTC
'Shiftout IO, SCLK, LSBFIRST, [$8e, 128]
WHILE !switch: WEND ' Wait until button is released
Return
Bookmarks