无线传输求助
时间:10-02
整理:3721RD
点击:
#include<AT89X52.h>
#define step_moto_port P0
unsigned int speed=1000;
unsigned int speed_change=1000;
unsigned char dir=0;
unsigned char s;
void init()
{
TMOD = 0x20;
TH1 = 250;
TL1 = 250;
TR1 = 1;
PCON = 0x80;
SCON = 0xd0;
}
uchar recvdata()
{
uchar buf;
while(!RI);
buf=SBUF;
RI=0;
return 0;
}
void run()
{
speed=speed_change;
while(speed--)
if(dir==1)
{
if(step_moto_port >=0x80)
step_moto_port=0x01;
else
step_moto_port <<= 1;
}
else
{
if(step_moto_port <=0x01)
step_moto_port=0x08;
else
step_moto_port >>= 1;
}
}
void main(void)
{
RI = 0;
while(!RI);
SBUF=s;
RI = 0;
step_moto_port=0x01;
while(1)
{
if(SBUF==0)
{
dir=0;
P2_0=1;
while(SBUF) run();
}
if(SBUF==3)
{
dir=1;
P2_1=1;
while(SBUF) run();
}
if(SBUF==1)
{
if(speed_change >= 2000)
speed_change = speed_change - 1000;
while(SBUF) run();
}
if(SBUF==2)
{
if(speed_change < 20000)
speed_change = speed_change + 1000;
while(SBUF) run();
}
run();
}
}
这是一段网上的接收机程序 我做了点改动 但是编译HEX的时候 提示如下
这个怪异的分号我已经在很多地方加过 但是都没解决 请问怎么解决?
#define step_moto_port P0
unsigned int speed=1000;
unsigned int speed_change=1000;
unsigned char dir=0;
unsigned char s;
void init()
{
TMOD = 0x20;
TH1 = 250;
TL1 = 250;
TR1 = 1;
PCON = 0x80;
SCON = 0xd0;
}
uchar recvdata()
{
uchar buf;
while(!RI);
buf=SBUF;
RI=0;
return 0;
}
void run()
{
speed=speed_change;
while(speed--)
if(dir==1)
{
if(step_moto_port >=0x80)
step_moto_port=0x01;
else
step_moto_port <<= 1;
}
else
{
if(step_moto_port <=0x01)
step_moto_port=0x08;
else
step_moto_port >>= 1;
}
}
void main(void)
{
RI = 0;
while(!RI);
SBUF=s;
RI = 0;
step_moto_port=0x01;
while(1)
{
if(SBUF==0)
{
dir=0;
P2_0=1;
while(SBUF) run();
}
if(SBUF==3)
{
dir=1;
P2_1=1;
while(SBUF) run();
}
if(SBUF==1)
{
if(speed_change >= 2000)
speed_change = speed_change - 1000;
while(SBUF) run();
}
if(SBUF==2)
{
if(speed_change < 20000)
speed_change = speed_change + 1000;
while(SBUF) run();
}
run();
}
}
这是一段网上的接收机程序 我做了点改动 但是编译HEX的时候 提示如下
这个怪异的分号我已经在很多地方加过 但是都没解决 请问怎么解决?