Hmmm. I don't see any code to initialize the RTC. Add something like this to your code, so it runs once before you enter the main loop....
You'll have to look in the data sheet to set your preferred trickle charge rates and such if you are going to use the charger.


Code:
'initialize the RTC and set the trickle charge rate
Low SCLK
low rst        ' Reset RTC
high rst       ' RTC Ready for transfer        
Shiftout IO, SCLK, LSBFIRST, [$8e, 0]  ' Enable write
low rst        
high rst
Shiftout IO, SCLK, LSBFIRST, [$90, %10101011]  ' Set charger on and to "2 diodes, 8Kohm"              
Low RST         ' Reset RTC

steve