my question relates to the HOUR registers. In the datasheet bits 0-3 set the hour. Bits 4 and 5 each indicate an additional 10 hours. Bit 6 is the 12/ !24 hour setting.
All of the drivers I have seen on the web read the hours value using a straight BCD to binary conversion, meaning that if the time is (in 24hr format) 10pm == 22:00
then the register reads 00110010 == 0x32 == 50 decimal
then that converts from BCD to binary as an hour of 32 o'clock, which is clearly wrong. In the linked driver, this line reads the register:
Code:
dt->hours = bcd2bin(bcd_hrs & 0x3F);
and converts using:
Code:
char bcd2bin(char bcd_value) {
char temp;
char temp1;
temp = bcd_value;
// Shifting the upper digit right by 1 is
// the same as multiplying it by 8.
temp >>= 1;
// Isolate the bits for the upper digit.
temp &= 0x78;
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum