大佬们, 我用RX8025T出现一个诡异问题, 例如将时间设置为 2022-07-15 23:59:55; 等待5秒后, 时间变成了 2022-07-15 24:00:00; 日期不增加, 小时数也不归零,有人碰到过这个问题码?
代码如下:
[C] 纯文本查看 复制代码 u8 set_rtc_time(TIME *t)
{
u8 rtc_str[7];
rtc_str[0] = ((t->second / 10) << 4) | (t->second % 10);
rtc_str[1] = ((t->minute / 10) << 4) | (t->minute % 10);
rtc_str[2] = ((t->hour / 10) << 4) | (t->hour % 10);
rtc_str[3] = t->week;
rtc_str[4] = ((t->day / 10) << 4) | (t->day % 10);
rtc_str[5] = ((t->month / 10) << 4) | (t->month % 10);
rtc_str[6] = ((t->year / 10) << 4) | (t->year % 10);
if (Write8025TData(RX8025T_SEC_REG, rtc_str, 7)) //写入日期与时间
return 1;
else
return 0;
}
[C] 纯文本查看 复制代码 u8 get_rtc_time(TIME *t)
{
u8 rtc_str[7];
if (Read8025TData(RX8025T_SEC_REG, rtc_str, 7)) //获取日期与时间
return 1; //读取出错
t->second = ((rtc_str[0] >> 4) * 10) + (rtc_str[0] & 0x0f);
t->minute = ((rtc_str[1] >> 4) * 10) + (rtc_str[1] & 0x0f);
t->hour = ((rtc_str[2] >> 4) * 10) + (rtc_str[2] & 0x0f);
t->week = rtc_str[3];
t->day = ((rtc_str[4] >> 4) * 10) + (rtc_str[4] & 0x0f);
t->month = ((rtc_str[5] >> 4) * 10) + (rtc_str[5] & 0x0f);
t->year = ((rtc_str[6] >> 4) * 10) + (rtc_str[6] & 0x0f);
return 0;
}
|