Hello,
I have 3 bytes from CMOS: sec, min and hour.
The problem is that, when I decode digits into string, I get wrong time? (The converter from digit to string works fine)
Thanks. Bye
Get CMOS time
Re:Get CMOS time
How are you decoding the digits? They're BCD encoded, which means that the high nibble and low nibble contain separate decimal digits. If you display the numbers as hex they will appear as their decimal equivalents. To convert to decimal, do:
Code: Select all
sec = ((sec_bcd & 0xf0) >> 16) * 10 + (sec_bcd & 0x0f);
Re:Get CMOS time
Thank you for explaining, but I use a bit different method:
TIME.hour=((TIME.hour>>4)*10+(TIME.hour & 0xF));
Thanks again . Bye
TIME.hour=((TIME.hour>>4)*10+(TIME.hour & 0xF));
Thanks again . Bye