谢谢你了啊
我按你说的改成如下,发现还不是不行,你能不能在帮我看一下.急用啊!!!!!谢谢!
#include <reg51.h>
sbit p1_7=P1^7;
sbit work_state=P1^0;
unsigned char code address=0x01;
unsigned char data temp_address;
unsigned char data temp_function;
unsigned char data flag_uant;
unsigned char data flag_txd;
unsigned char code on[]="OK!";
unsigned char code off[]="off!";
unsigned char code error[]="command error !";
void init()
{
IE=0;
temp_address=0x00;
temp_function=0x00;
}
void init_uant()
{
PCON&=0X3F;
TMOD=0X20;
TH1=0XFD;
TL1=0XFD;
SCON=0X50;
TR1=1;
flag_uant=0;
flag_txd=1;
ES=1;
EA=1;
}
void serial(void) interrupt 4 using 1
{
if(RI==1)
{
ACC=SBUF;
temp_address=ACC;
if(temp_address==address) flag_uant=2;
else
{
flag_uant=1;
}
RI=0;
}
if(TI==1)
{
TI=0;
flag_txd=1;
}
}
void main()
{
char i;
init();
init_uant();
while(1)
{
if(flag_uant==2)
{
i=0;
while(error[i]!='\0')
{
flag_txd=0;
SBUF=error[i];
while(flag_txd==0);
i++;
}
}
}
}
发表时间:2006年8月2日8:51:13