RTC to display on LCD screen

Salmon

New Member
I am trying to place the results from a RTC into Ram, then from Ram onto the display.
I have tried (and failed) and apparently the RTC output is hexidecemal so it shows 255...

If I put Seconds into a variable named "Sec", Minutes into "Min" and Hours into "Hour", how do I place them in ram known as SecU, SecT, MinU, MinT, HourU and HourT (U and T donating Units and Tens).
I have one spare variable know as Time_Dump.

I would greatly appriciate help with this. I do not know much more than the basics, so any terms outher than Poke, peek, Readi2c, gosub and if need explaing.

 
 

hippy

Technical Support
Staff member
Firstly you need to define where in SFR (RAM) you want to place the data ...

- SYMBOL SecT = $50
- SYMBOL SecU = $51
- SYMBOL MinT = $52
- SYMBOL MinU = $53
- SYMBOL HourT = $54
- SYMBOL HourU = $55

Then you need to take your raw data in BCD hexadecimal format, extract the tens and units, and put them in the SFR ...

- timeDump = sec / 16 : POKE SecT,timeDump
- timeDump = sec & $F : POKE SecU,timeDump
- timeDump = min / 16 : POKE MinT,timeDump
- timeDump = min & $F : POKE MinU,timeDump
- timeDump = hour / 16 : POKE HourT,timeDump
- timeDump = hour & $F : POKE HourU,timeDump

The 'timeDump = sec / 16' extracts the most significant four bits of 'sec' while 'timeDump = sec & $F' extracts the least significant four bits.
 
Hi, i did a project which used a RTC and reading/writing to SFR a few weeks ago. you can find some info on it on http://www.dofzone.com/cgi-bin/artikel/front.cgi?ShowPage=FullArticle&ID=42

Take a look at the routines display_time and time_to_ram which should give you some idea.
 

Salmon

New Member
I have just spoken to my teacher, he said that the clock chip is in binary coded decimal (?!?). And will show me how to decode it. Thank you to everyone.
 
Top