SERIAL PORT (RS232) INTERFACING TO 8051
RS232 standards
8051 connections
Serial Communication Registers
BAUD RATE
Steps to send data serially in serial port communication
Steps to receive data serially in serial port communication
PROGRAMMING FOR SERILA PORT-8051
TMOD=0x20; //use Timer 1, mode 2 TH1=0xFA; //4800 baud rate SCON=0x50; TR1=1; while (1)
{
SBUF=‘A’; //place value in buffer while (TI==0); TI=0;
}
}
Program to send data serially
#include<reg51.h>
void SerTx(unsigned char);
void main(void)
{
TMOD=0x20; //use Timer 1, mode 2
TH1=0xFD; //9600 baud rate
SCON=0x50;
TR1=1; //start timer
while (1) {
SerTx(‘Y’);
SerTx(‘E’);
SerTx(‘S’);
}
}
void SerTx(unsigned char x){
SBUF=x; //place value in buffer
while (TI==0); //wait until transmitted
TI=0;
}
BLOCK DIAGRAM
CIRCUIT DIAGRAM
THANK YOU