void tx(void) interrupt 4
{
EA=0;
if(RI)
{
RI=0;
switch(sx_step)
{
case 0:
{
if(SBUF==0x7e)
{
sx_step=1;
tx_buf[0]=SBUF;
pf=0x7e;
}
else
{
sxcl_flag=1;
}
}
break;
case 1:
{
if(SBUF==0xd0)
{
sx_step=2;
tx_buf[1]=SBUF;
pf^=0xd0;
}
else
{
sxcl_flag=1;
}
}
break;
case 2:
{
tx_buf[2]=SBUF;
sx_step=3;
pf^=SBUF;
}
break;
case 3:
{
tx_buf[3]=SBUF;
sx_step=4;
pf^=SBUF;
}
break;
case 4:
{
tx_buf[4]=SBUF;
sx_step=5;
pf^=SBUF;
}
break;
case 5:
{
tx_buf[5]=SBUF;
sx_step=6;
pf^=SBUF;
}
break;
case 6:
{
tx_buf[6]=SBUF;
sx_step=7;
pf^=SBUF;
}
break;
case 7:
{
tx_buf[7]=SBUF;
sx_step=8;
pf^=SBUF;
}
break;
case 8:
{
tx_buf[8]=SBUF;
sx_step=9;
pf^=SBUF;
}
break;
case 9:
{
tx_buf[9]=SBUF;
sx_step=10;
pf^=SBUF;
}
break;
case 10:
{
tx_buf[10]=SBUF;
sx_step=11;
pf^=SBUF;
}
break;
case 11:
{
tx_buf[11]=SBUF;
sx_step=12;
pf^=SBUF;
}
break;
case 12:
{
tx_buf[12]=SBUF;
sx_step=13;
pf^=SBUF;
}
break;
case 13:
{
tx_buf[13]=SBUF;
sx_step=14;
pf^=SBUF;
}
break;
case 14:
{
tx_buf[14]=SBUF;
sx_step=15;
pf^=SBUF;
}
break;
case 15:
{
tx_buf[15]=SBUF;
sx_step=16;
pf^=SBUF;
}
break;
case 16:
{
if((SBUF^pf)==0)
{
ture_flag=1;
}
else
{
ture_flag=0;
}
sxcl_flag=1;
}
break;
default:break;
}
}
这段程序我看来看去最后结果SBUF^pf好像不可能为0。而是:
case 0: pf = 7e sbuf = 7e
case 1: pf = ae sbuf = d0
case 2: pf = 7e sbuf = d0
case 3: pf = ae sbuf = d0
...
case 15:pf = ae sbuf = d0
然后case 16:SBUF^pf这样就不为0了,不知这个程序是否这样执行,还望高手点拨一下! |