Posts

Showing posts with the label serial communication

Serial data transmission using 8051

Image
SOFTWARE:   KEIL MICRO VISION 4.0 SIMULATOR:   PROTEUS 8.0 CIRCUIT DIAGRAM: WORKING: Here in this project, I have transmitted the data to the virtual terminal. When all the data gets transmitted, the TI flag in the SCON register becomes equal to 1 which indicates the complete transmission of data(8 bit). Data which needs to be transmitted is first placed into the SBUF register and after that the further procedure is performed as mentioned below.I have used a 9600 baud rate. All the serial communication is done using TXD and RXD pin of 8051. PROGRAM: #include<reg51.h> int main() { unsigned char *d="WELCOME TO THE EMBEDDED SYSTEM"; // data which gets transmitted to the virtual terminal TMOD=0x20; // timer 1 in mode 2 SCON=0x50; // mode 1,8 bit data,1 stop bit,1 start bit TH1=0xfd; // 9600 baud rate TR1=1; // start timer 1 TI=0;   // clear transmit flag while(*d!='\0') { SBUF=*d; // send data to serial buffer d++; while(TI==0); // wait untill transmission is comple

Serial data reception using 8051

Image
SOFTWARE: KEIL MICRO VISION 4.0 SIMULATOR: PROTEUS 8.0 CIRCUIT DIAGRAM: WORKING: Here in this project, I have received the data from the virtual terminal and displayed the received data on an lcd.When all the data get received, the RI flag in the SCON register becomes equal to 1 which indicates the complete reception of data(8 bit). Received data gets stored into the SBUF register. I have taken the received data from the SBUF register and send this data on an lcd. I have used a 9600 baud rate.All the serial communication is done using TXD and RXD pin of 8051. PROGRAM: #include<reg51.h> sbit RS = P2^0;  sbit EN = P2^2; void lcd_init(void); // lcd initialization function void lcd_command(unsigned char c);// lcd command function void lcd_data(unsigned char d);// lcd data function void delay(unsigned int t); // delay function int main() { unsigned char r; lcd_init(); // lcd initialization TMOD=0x20; // timer 1 in mode 2 SCON=0x50; // mode 1,8 bit data,1 stop bit,1 start bit TH1=0xf