uchar buf[6]={0,0,0,0,0,0};
uchar point;
void delayms(int t) //延时子程序
{
uchar i;
while(t--)
{
i=100;
while(i--);
}
}
void senbyte (uchar *s_byte)
{
uchar i;
for(i=0;i <6;i++)
{
SBUF=s_byte[i];
while(TI==0);
TI=0;
}
}
main()
{
TMOD=0x20; //T/C0方式1,T/C1方式2
TH1=0xfd; //9600 bit/s
TL1=0xfd;
SCON=0xd8; //选择串口工作方式为3,打开接收允许
PCON=0x00;
TR1=1;
while(1)
{if(RI)
{RI=0;
for(point=0;point <6;point++)
{
while(RI==0);RI=0;
buf[point]=SBUF;
}
delayms(10);
senbyte(buf);
}
}
}