RTC updating in real time

Ocean

Member
Can anyone help me figure out why my time wont update in real time. the Rtc will still keep time running but it wont update on the display so its just stuck on the time that its on when the display first turns on

here is my code:
serout c.7, n2400, (254,1)
pause 30

symbol secs = b0 'stores secs on rtc
symbol mins = b1 'stores mins on rtc
symbol hours = b2 'stores hrs on rtc
symbol secs_tens = b3 'for displaying sec on OLED
symbol secs_ones = b4
symbol mins_tens = b5 'for displaying mins on OLED
symbol mins_ones = b6
symbol hrs_tens = b7 'for displaying hrs on OLED
symbol hrs_ones = b8
symbol AM_PM = b9
readrtc:
i2cslave %11010000, i2cslow, i2cbyte 'reads time from in 24 hr from rtc

hi2cin 0,(SECS, MINS, HOURS)

debug
'converts time to 12hr
let AM_PM = "A"
if hours > $11 then : let AM_PM = "P" : endif
if hours = $20 or hours = $21 then : let hours = hours - $6 : endif
if hours > $12 then : let hours = hours - $12 : endif
if hours = $0 then : let hours = $12 : endif

'converts time from bcd to ASCII
bcdtoascii hours, hrs_tens, hrs_ones
if hrs_tens = "0" then : let hrs_tens = " " : endif
bcdtoascii mins, mins_tens, mins_ones
bcdtoascii secs, secs_tens, secs_ones

'display time on OLED
serout c.7, n2400, (254,128)
serout c.7, n2400, (hrs_tens, hrs_ones, ":", mins_tens, mins_ones, ":", secs_tens, secs_ones, AM_PM, "m")
 

Jack Burns

New Member
Try adding goto readrtc to the end of your code, as that will cause the code to loop around, constantly reading the RTC and updating the display.
 
Top