12进制换算成24进制过程中没有出错,但是24进制转换为12进制时,晚上0点转换过来是12pm。
具体如下:
dat=(Read1302 (READ_HOUR)&0x7f);
dat0=dat/16;
dat1=dat%16;
dat1=((dat0*10)+dat1); //转换成10进制
if(dat1==0)
{
Write1302 (0x8e,0x00); //禁止写保护
Write1302 (0x84,(0x80|0x12)); //这个地方直接写入Write1302 (0x84,0x92); 显示也是12pm,直接在main函数中写Write1302 (0x84,0x92); 可以显示12am.
Write1302 (0x8e,0x80); //允许写保护
}
else if((dat1>=1)&&(dat1<=11))
{
Write1302 (0x8e,0x00); //禁止写保护
Write1302 (0x84,(dat|0x80));
Write1302 (0x8e,0x80); //允许写保护 */
}
else if(dat1==12)
{
Write1302 (0x8e,0x00); //禁止写保护
Write1302 (0x84,(dat|0xa0));
Write1302 (0x8e,0x80); //允许写保护 */
}
else if((dat1>=13)&&(dat1<=23))
{
dat1=dat1-12;
dat0=dat1/10;
dat2=dat1%10;
dat2=dat2+16*dat0;
Write1302 (0x8e,0x00); //禁止写保护
Write1302 (0x84,(dat2|0xa0)); //小时初始化
Write1302 (0x8e,0x80); //允许写保护 */
}
哪位高手能够说说这个问题
0