#include <REGX51.H>
char serialsend(unsigned char);
unsigned char serialread();
void delay(int);
void delay(int s)
{
int i,j;
for(i=0;i<1275;i++)
for(j=0;j<s;j++);
}
void intuart()
{
SCON=0x50;
TMOD=0x20;
TH1=0xFD;
TL1=0x00;
TR1=1;
}
char serialsend(unsigned char d)
{
SBUF=d;
while(TI==0);
TI=0;
}
unsigned char serialread()
{
unsigned char buf;
while(RI==1)
{
buf=SBUF;
RI=0;
}
return buf;
RI=0;
}
void main()
{
intuart();
delay(50);
serialsend('o');
serialsend('k');
delay(10);
while(1)
{
unsigned char r;
r=serialread();
delay(10);
serialsend(r);
delay(10);
}
}
char serialsend(unsigned char);
unsigned char serialread();
void delay(int);
void delay(int s)
{
int i,j;
for(i=0;i<1275;i++)
for(j=0;j<s;j++);
}
void intuart()
{
SCON=0x50;
TMOD=0x20;
TH1=0xFD;
TL1=0x00;
TR1=1;
}
char serialsend(unsigned char d)
{
SBUF=d;
while(TI==0);
TI=0;
}
unsigned char serialread()
{
unsigned char buf;
while(RI==1)
{
buf=SBUF;
RI=0;
}
return buf;
RI=0;
}
void main()
{
intuart();
delay(50);
serialsend('o');
serialsend('k');
delay(10);
while(1)
{
unsigned char r;
r=serialread();
delay(10);
serialsend(r);
delay(10);
}
}
No comments:
Post a Comment