SERTXD from DS1307

Michael V

Senior Member
I have set up a circuit with a Picaxe 18X, and a clock on the i2c bus. It seems to have loaded the time OK, because the numbers i see when using debug look right, and the clock light flashes.

I've spent all day trying to use SERTXD to display the time from the clock chip. Then I discovered that the output is in HEX, which explains all the gobbldigook coming out of it.

So how do i convert the data read in Hex from the DS1307 into a number that will display as real time on SerTXD?

I also have an inherited I2C LCD module that i would like to output the data on, but not having any luck with that either.

 
 

craigcurtin

Senior Member
Here you go - the stuff coming out of the RTC is actually Binary Coded Decimal BCD


ReadTimeFromRTC:

i2cslave %11010000, i2cslow, i2cbyte
readi2c 0,(workvariable1,mins,hours)

'Convert to Decimal from BCD
let workvariable1 = mins & %11110000 / 16 * 10
let mins = mins & %00001111 + workvariable1
let workvariable1 = hours & %11110000 / 16 * 10
let hours = hours & %00001111 + workvariable1
 
Top