我知道我的问题 但是没查出来
void time0_init() //定时器0初始化 和串口通信初始化
{
EA=1;
ET1=1;
ET0=1;
TR1=1;
TR0=1;
ES=1;
// PT1=1;
TMOD|=0X20;
TH1=0XFD;
TL1=0XFD;
SM0=0; //方式选择位
SM1=1; //
REN=1; //串行通信通信允许位
}
void time0()interrupt 1 //定时器0
{
static uchar i;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
i++;
if(i==2) //刷新数据为每100ms
{
i=0;
shuaxin=1;
}
}
void uart()interrupt 4 //串行通信
{
static uchar i,temp;
if(RI)
{
RI=0;
temp=SBUF;
SBUF=temp;
i++;
time_uart=temp&0x0f;
if(i==16)
{
i=0;
biaozhi=1;
}
}
if(TI)
TI=0;
}
void main(void) //主函数
{
uchar i;
time0_init(); //函数的初始化
ds1302_init();
ds_writeall();
while(1)
{
display();
if(biaozhi==1)
{
for(i=0;i<8;i++)
{
time_begin=time_uart[2*i]*10+time_uart[2*i+1];
}
ds_writeall();
biaozhi=0;
}
if(shuaxin==1)
{
shuaxin=0;
ds_receiveall();
}
shu[0]=duanma[time_begin[4]/10];
shu[1]=duanma[time_begin[4]%10];
shu[2]=0x40;
shu[3]=duanma[time_begin[5]/10];
shu[4]=duanma[time_begin[5]%10];
shu[5]=0x40;
shu[6]=duanma[time_begin[6]/10];
shu[7]=duanma[time_begin[6]%10];
}
}这是程序的一部分我做的是串口发送数据调整数码管时间信息 问题在于同时使用T1和T0,数码管时钟无**常工作
|