好吧,从头到尾麻烦都详细讲一下吧。。。。
就像//这样的注释。。。。。。。。。。。。。。。。。。
利用上位机串口调试助手发送一个字符,单片机收到字符后返回给上位机“I receive, thanks ”。串口的波特率设为9600bps。
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
unsigned char flag,a,i;
uchar code table1[]=" , thanks ";
uchar code table[]="I receive";
void init()
{
} //设置工作方式,这个懂。
void main()
{
init();
while(1)
{
if(flag==1)
{
ES=0;
for(i=0;i<18;i++)
{
SBUF=table[i];
while(!TI);
TI=0;
}
SBUF=a;
while(!TI);
TI=0;
ES=1;
flag=0;
}
}
}
void serial() interrupt 4
{
RI=0;
a=SBUF;
flag=1;
}
好吧,从头到尾麻烦都详细讲一下吧。。。。
就像//这样的注释。。。。。。。。。。。。。。。。。。
uchar code table1[]=" , thanks ";
uchar code table[]="I receive";
这两句话打错了,应该是
uchar code table[]="I receive, thanks ";
大一学的C语言,大三都忘差不多了...
再加上单片机,更不懂了...
麻烦高手来点详细的解释吧。。。