Wednesday 13 March 2013

program for Serial communication using 8051


/*************************** Serial communication *************************/

Transmission program
#include <reg51.H>
void main()
{
      unsigned char i, a[]="VENKY NAIDU";
      TMOD=0X20;                                  //timer1 mode2
      TH1=0XFD;                                     //loading the value to generate baud rate 9600
      SCON=0X50;                                    //mode 1 and set REN (Receive enable) bit
      TR1=1;                                                //start the timer
      for(i=0;i<7;i++)
      {         
                  SBUF=a[i];                            //transmit character 'a' through SBUF register           

                  while(TI==0);                          //monitoring TI bit until become 1
                 
                  TI=0;                                       //clear the TI bit
}
    }

No comments:

Post a Comment