RTC question

sbscott

Senior Member
Hey Uall!
Working with the DS1307 and an 18M2 with the serial to parallel pic to monitor outputs of various PICAXE projects. I have the RTC feeding the 18M2 and displaying the time on an LCD. What I am confused about is, what am I seeing? I thought the output of the RTC via the i2C would be Hex values but, displaying the values on the LCD using "#" to convert the hex does not give me the date time...the second value is incrementing, but it is obviously not decimal.

Where have I mislead myself?

Code:
hi2csetup I2CMASTER, %11010000, i2cslow, i2cbyte
hi2cout 0,($00,$33,$14,$01,$04,$11,$10)

writei2c 0, ($00,$59,$11,$3 ,$9, $5,$11, $10)
main:
pause 700
hi2cin 0,(b0,b1,b2,b3,b4,b5,b6,b7)
high c.1:SEROUT c.1,t2400,("?f")  ' clear the LCD
high c.1:SEROUT c.1,t2400,(#b0," ",#b1," ",#b2)
high c.1:SEROUT c.1,t2400,("?n",#b4," ",#b5," ",#b6)
debug
goto main
 

jtcurneal

Senior Member
The output of the DS1307 Uses BCD format, The lowerr 4 bits of the minutes byte is the units of minutes (0 to 9) the upper 4 bits contain the tens of minutes. you sorerate the digits by anding a mask to the byte and saving the result in a temp location. you can then send each digit to a LCD by sending #temp.

let temp = date & %00110000 / 16
serout b.7,N9600_8,(#temp)
let temp = date & %00001111
serout b.7,N9600_8,(#temp,"/")

let temp = month & %00010000 / 16
serout b.7,N9600_8,(#temp)
let temp = month & %00001111
serout b.7,N9600_8,(#temp,"/")

let temp = year & %11110000 / 16
serout b.7,N9600_8,(#temp)
let temp = year & %00001111
serout b.7,N9600_8,(#temp," ")

let temp = hour & %00110000 / 16
serout b.7,N9600_8,(#temp)
let temp = hour & %00001111
serout b.7,N9600_8,(#temp,":")

let temp = mins & %01110000 / 16
serout b.7,N9600_8,(#temp)
let temp = mins & %00001111
serout b.7,N9600_8,(#temp,":")

let temp = seconds & %01110000 / 16
serout b.7,N9600_8,(#temp)
let temp = seconds & %00001111
serout b.7,N9600_8,(#temp)

Joel
 

cactusface

Senior Member
Time and time again!

Hi SB,
I found this to work, you do need to convert the data to ASCII using the command BCDTOASCII like this: Below the 8 bits of b2 (HOURS) are converted to 2 4bit nibbles representing tens of HOURS and HOURS in b10 & b11

bcdtoascii b1,b8,b9 'Mins
bcdtoascii b2,b10,b11 'Hours
bcdtoascii b4,b12,b13 'Date

bcdtoascii b5,b14,b15 'Month

bcdtoascii b6,b16,b17 'Year





pause 100

readtemp c.0,w20 'read Temp from DS18b20

pause 2000




serout c.1,T2400,(254,1,254,1)


serout c.1,T2400,(254,128,"Time ",b10,b11,":",b8,b9," Temp ",#w20,"c")

This displays time in HOURS & MINUTES and the temp which is converted from HEX using #.
Hope it helps..;)
Regards
Mel.
 
Top