More on I2C and BCD
Posted: Wed Mar 22, 2017 5:52 am
In an attempt to implement comms between a RTC chip and the ESP, I accessed the "I2C Reading DS1321" example on the Examples page. It didn't work. And the reason is this:
This is wrong! I won't go into the detail now - it's a useful quick exercise to find the problem! This, however, works - and is neater than the original!
And no, the problem is not the f$ - I just use that because I prefer to identify my string variables!
Phil
Code: Select all
[bcd]
a = d / 16
a = int(a)
a = a + 48
c = a * 16
b = d - c
b = b + 48
e = chr(a)
f = chr(b)
f = e & f
return
This is wrong! I won't go into the detail now - it's a useful quick exercise to find the problem! This, however, works - and is neater than the original!
Code: Select all
[bcd]
a = int(d / 16)
c = a * 16
a = a + 48
b = d - c + 48
f$ = chr(a) & chr(b)
return
And no, the problem is not the f$ - I just use that because I prefer to identify my string variables!
Phil