#include<reg52.h>//发射方
#define uint unsigned int
#define uchar unsigned char
uchar code table[]={0x01,0x01,0x04,0x08,0x10,0x20,0x40,0x80};
uchar sum;
void init()
{
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
TR1=1;
SM0=0;
SM1=1;
EA=1;
ES=1;
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void main()
{
uchar num;
init();
while(1)
{
for(num=0;num<8;num++)
{
SBUF=table[num];
sum+=table[num];
while(!TI);
TI=0;
delay(100);
}
SBUF=sum;
while(!TI);
TI=0;
delay(100);
}
}
这个程序为什么发不出去sum这个变量啊 |