void init_rs232()
{
SCON=0x50;
TMOD=0x20;
TH1=0xfb;
TR1=1;
TI=1;
}
tx_char(unsigned char c)
{
while(1)
{
if(TI==1) break;
}
TI=0;
SBUF=c;
}
main()
{
while(1)
{
unsigned char *title0="I LOVE you!";
init_rs232();
do{tx_char(*title0++);}
while(*title0!='\0');
}
}
pc:
#include <bios.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
extern void clrscr();
extern int getch();
void receive();
main()
{
char c;
bioscom(0,0xe3,0);
clrscr();
puts("---------------------");
puts("com1 <9600 N 8 1>");
puts("---------------------");
c=getch();
receive();
}
void receive()
{
int s;
char c;
while(1)
{
s=bioscom(3,0,0)&0x100;
if(s)
{
c=bioscom(2,0,0);
printf("%c",c);
}
}
}
void send(char *title)
{
int s;
do {
bioscom(1,*title++,0);
while(1)
{
s=bioscom(3,0,0)&0x100;
if(s)
{
if(bioscom(2,0,0)==*title) break;
}
}
}while(*title!='\0');
}