Write a program for transmission and reception.


#include<8051.h>
void transmission(unsigned char a);
void trans_init();
unsigned int k;
void reception();
void rec_init();
void lcd_init();
void lcd_cmd(unsigned char b);
void display(unsigned char b);
void delay(unsigned int i)
{
while(i!=0);
{
i–;
}
}
void trans_init()
{
TMOD=0x20;
SCON=0x40;
TH1=0xfd;
TR1=1;
}
void transmission(unsigned char a)
{
SBUF=a;
delay(500);
TI=0;
}
void rec_init()
{
TMOD=0x20;
SCON=0x50;
TH1=0xfd;
TR1=1;
}
void reception()
{
unsigned char r;
r=SBUF;
delay(500);
RI=0;
}
void lcd_init()
{
lcd_cmd(0x38);
lcd_cmd(0x01);
lcd_cmd(0x0c);
}
void lcd_cmd(unsigned char b)
{
P1=b;
delay(300);
P3_3=0;
P3_4=1;
P3_4=0;

}
void display(unsigned char b)
{
P1=b;
delay(300);
P3_3=1;
P3_4=1;
P3_4=0;
}
void main()
{lcd_init();
P1=0x00;

for(k=0;k<=5;k++)
{
trans_init();
transmission(‘a’);
transmission(‘b’);
transmission(‘c’);

delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);

rec_init();
if(RI==1)
{
reception();
delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);

}
}
}

Add Comment