How do I convert 1307 data to LCD output?

AllanBertelsen

Senior Member
Hi there. I have just wired up my ds1307 serial clock to the PICAXE and a LCD-display. It works just like clockwork. Only problem is to display the time. From the datasheet I realised that seconds and minutes is torn up from bytes to bits. I'm sure someone has some lines of code that convert these data to a LCD output.
Can anyone help me?
 

AllanBertelsen

Senior Member
Sorry. I did not use enough time thinking before posting. Now I think I got the answer myself.

<code><pre><font size=2 face='Courier'>
symbol LCD=5
symbol Number = b8
symbol Digit = b9

readClock:
i2cslave %11010000, i2cslow, i2cbyte
readi2c 0, (b0,b1,b2,b3,b4,b5,b6,b7)
serout LCD,T2400,(254,128)
Number = b2
Gosub Print2DigitNbr
serout LCD,T2400,(&quot;-&quot;)
Number = b1
Gosub Print2DigitNbr
serout LCD,T2400,(&quot;-&quot;)
Number = b0
Gosub Print2DigitNbr
goto readClock

Print2DigitNbr:
Digit=Number &amp; %11110000
Digit=Digit/16
serout LCD,T2400,(#Digit)

Digit=Number &amp; %00001111
serout LCD,T2400,(#Digit)
return
</font></pre></code>

But there could be a better way.
 
Top