Wednesday 13 March 2013

reception program for Serial communication using 8051

/*************************** Serial communication *************************/
Reception Program

#include <REGX51.H>

void main()
{
      unsigned char a [50], i=0;
TMOD=0X20;                                    //timer1 mode2
TH1=0XFD;                                       //baud rate 9600
SCON=0X50;                                     //mode 1 and set REN (Receive enable) bit
TR1=1;                                                //start the timer
 while (1)
{
while (RI==0);                        //monitoring RI bit until rise the bit
                                   //transmit characters ‘a’ through SBUF register
a[i]=SBUF;                      //moving Data from SBUF to array
RI=0;                                //clear the RI bit
SBUF=a[i];                      //array assigned to SBUF register
while (TI==0);                  //monitoring TI bit until rise the bit
TI=0;                                //clear the TI bit
}
}

No comments:

Post a Comment