推荐 最新
脑洞大咖

时钟芯片rx8025t芯片读取,小时超出24小时,请问是什么原因?

https://wmlx-new-image.oss-cn-shanghai.aliyuncs.com/images/20241103/ce745ccc4df0004f86fe90132a608b1a.png 这是i2c返回的结果 小时是第三个字节,0x36,转成bcd然后10进制是36,直接超出24小时了 #include unsigned char bcd_decimal(unsigned char bcd) { return bcd - (bcd >> 4) * 6; } int main(void) { unsigned char buf[7] = {0x18, 0x27, 0x36, 0x00, 0x08, 0x12, 0x23}; printf("date -s %04d-%02d-%02d %02d:%02d:%02d\n", 2000 + bcd_decimal(buf[6]), bcd_decimal(buf[5]), bcd_decimal(buf[4]), bcd_decimal(buf[2] & 0x3f), bcd_decimal(buf[1]), bcd_decimal(buf[0])); return 0; } 输出结果是 ➜ gcc hello.c && ./a.out date -s 2023-12-08 36:27:18 参数解析: https://wmlx-new-image.oss-cn-shanghai.aliyuncs.com/images/20241103/5bc2a24b1011b6c7496b2c3ff7dffb34.png 具体规格书:"规格书" (https://link.segmentfault.com/?enc=Kcgjj4eycl7L3sPVYw24cQ%3D%3D.%2BxZX%2B2Q8SycJ%2Bbo3MhW13bjxJu4EfOiBtOOFGnCR27iUxm6H2NjtGtQuGaPZ3KYQOJ%2FYC4Kpg3kp0AZizKCRbCRKAhQPUoK1q%2FPyIpatoEBR9XpVNCsTOJXHtK%2FyAq1h) 请问是什么原因导致的?

0
1
0
浏览量16