DS1302 24小时与12小时进制的问题
具体如下:
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); //允许写保护 */
}
哪位高手能够说说这个问题
初始化到11:59:59pm 下一秒可以显示12:00:00am.
还木有解决呢
搞定了
dat=Read1302 (READ_HOUR); //这个地方修改一下
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); //允许写保护 */
}
PCB打样找华强 http://www.hqpcb.com 样板2天出货
还木有解决呢
能不能加我下,我这个问题也没有解决