要做一个数据采集传输系统,采集以做出,不知道怎样实现串口通信。下面是找的相似的程序,不知怎么改
#include<reg51.h>
unsigned char code Tab[ ]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}
void Send(unsigned char dat)
{
SUBF=dat;
while(TI==0);
TI=0;
}
void dely(void)
{
unsigned char m,n;
for(m=0;m<200;m++)
for(n=0;n<250;n++)
;
}
void main{void}
{
unsigned char i;
TMOD=0x20;
SCON=0x40;
PCON=0x00;
TH1=0xfd;
TL1=0xfd;
TR1=1;
while(1)
{
for=(i=0;i<8;i++)
{
Send(Tab[ i]);
dely();
}
}
}
|