Hello everyone,
I'm trying to port Hippy's DS1302 code to an 18M2. Basically the way you pull data out of the DS1302 is to do a REV 8, and then BCD2BIN on each byte. I've figured out BCD to BIN, and BIN to BCD substitutes for the X2 commands.
I can replace REV with my included code, but I'm wondering if anyone knows a better way. My bit math is a little basic. Thanks!
I'm trying to port Hippy's DS1302 code to an 18M2. Basically the way you pull data out of the DS1302 is to do a REV 8, and then BCD2BIN on each byte. I've figured out BCD to BIN, and BIN to BCD substitutes for the X2 commands.
I can replace REV with my included code, but I'm wondering if anyone knows a better way. My bit math is a little basic. Thanks!
Code:
Code I'm replacing:
secs = secs Rev 8 : secs = BcdToBin secs
My REV replacement:
bit8 = bit7
bit9 = bit6
bit10 = bit5
bit11 = bit4
bit12 = bit3
bit13 = bit2
bit14 = bit1
bit15 = bit0