Oh my gosh... why didn't I think of that? okay.. I'm an idiot..b3=b1*10+b2 '??
b3=12
You're right, since they come out in BCD format, there was one more step I have add, here's how I get the hours. Since the ASCII value is just the number plus $30 - just do it backwards... subtract $30 and voila!Except, if you are working with a DS1307 I would GUESS that you want BCD numbers?
BCDtoDec:
tmpB4 = value / 16 * 10 'conv 16's column
value = value & $0F + tmpB4
return
I'm dealing with ASCII becuase I use BCDTOASCII to convert the number.Are you dealing with decimal, BCD or ASCII ? The DS1307 uses BCD data.
symbol seconds = b1 ' symbol declaration for "seconds"
hi2cin [%11010000], 0,(seconds) ' read the seconds variable DS1307
' use DS1307 i2c address because there is more than one chip on the i2c bus
BCDTOASCII seconds,b2,b3 ' convert BCD variable to two ASCII numbers
b50 = b2-$30*10 + b3-$30 ' convert ASCII to numerical and do math to add together, b50 now equalis a whole number between 1 and 59
'continue code.....
Thanks for the shortcut. I Think I've illustrated what I wanted to achieve in detailed enough manner.As you seem to be using an X1 or X2 you can simplify that to ...
hi2cin [%11010000], 0,(seconds)
seconds = BcdToBin seconds
An illustration of where the question asked does not necessarily reflect what one wants to achieve.