unsigned char displayTime[2];
rtc->day = ReadRtc();//从RTC寄存器读取时间
displayTime[0] = 0x30+(rtc->day / 16);
displayTime[1] = 0x30+(rtc->day % 16);
DisPlayTime(1,0,displayTime);//LCD显示时间函数
BCD码转十进制:(rtc->day / 16);
(rtc->day % 16);
十进制转ASCII码:0x30+(rtc->day / 16);
0x30+(rtc->day % 16);
也可这样写:
unsigned char displayTime[2];
rtc->day = ReadRtc();//从RTC寄存器读取时间
displayTime[0] = 0x30+(rtc->day >> 4);
displayTime[1] = 0x30+(rtc->day & 0x0f);
DisPlayTime(1,0,displayTime);//LCD显示时间函数