 Welcome to all of you, myself Ravindra Chauhan, Assistant Professor, Department of Electronics Engineering, Walsh and Insta of Technology, Solar Board. So today in this session we will discuss the serial communication in 8051. The learning outcome of this session is, after this session student will be able to design the system which supports the serial data transfer and receive using the microcontroller 8051. Outline of our discussions is like this, first we will go through the basics of the serial communication. First we will see how the 8051 supports the serial communication and third one is we will write the algorithm for serial data transfer and receive. The first you should know what do you mean by data communication. Now in the processor based system data communication means the exchange of data or exchange of information between the devices. Now this information can be exchanged in number of ways that is called the types of different communication. The way in which the data is transmitted or received depending upon that the classification is done like simplex communication, half duplex communication, full duplex communication. In simplex communication the transmitter and the receivers are fixed. The transmitter is transmitting the information all the times and the receiver is receiving the information all the times. The best example of this type of communication is the radio broadcasting. The next communication type is called the half duplex communication. In half duplex communication the device can be worked either as a transmitter or the receiver. Means data can be sent in both the directions but only in one direction at the same time. So the example of half duplex communication you will find in the device walkie-talkie. Where the device normally we are using the telephone which supports the full duplex communication. In full duplex communication data can be transmitted and the received in both the direction at the same time. Another classification of the data transfer is done how the data is transferred. So first type is called the parallel data transfer, second is called the serial data transfer. In parallel data transfer the number of lines wires are drawn between the transmitter and the receiver. Normally in the controller based system the eight or more wires are used to transfer or receive the data. It is the parallel data transfer is used for data transfer over short distance that is few feet away because the more number of lines or wires are required. But here as the number of bits can be transferred or received at the same time the parallel data transfer is the faster one. And in serial data transfer only one wire is sufficient to transmit the data between transmitter and receiver. Now in serial data transfer only one bit is transferred at the same time. Now serial data transfer mainly it is preferable while transferring the data over long distance. Now in this data transfer only one bit is transmitted at the same time that is why serial data transfer is slower compared to the parallel data transfer. Now the serial data transfer are classified mainly in two categories one is called the synchronous data transfer and second is called asynchronous data transfer. When synchronous data transfer before sending the actual data or the information the predefined sync characters are exchanged between transmitter and the receiver. And when transmitter and receiver are get synchronized to each other then the block of data is transferred at a time. Since one by one all the characters or bytes are transferred. In asynchronous data transfer the data transfer takes the character whites if it will send the one character after that the second character and so on. Now to transfer the one character in asynchronous data transfer the frame is designed which contains the start bit then the 8 bit of the characters to be transferred or normally to transfer the data serially or the characters serially its ASCII value is to be used. So 8 bit ASCII value of the character to be transferred and lastly the stop bit. So for each character one frame is designed and then these frames are sent one by one. Now in the serial data transfer in 805 for that the two pins are provided called the Rxd and Txd which are multiplexed with the port pin P3.0 and P3.1 respectively. P3.0 that is the receive pin is used to receive the one bit of information at a time and one bit of a information can be transmitted through the pin P3.1 that is called the Txd pin and this 805 one supports only the asynchronous data transfer. For one character to be transferred a frame is designed which is shown below. The first bit is called the start bit then the 8 bit ASCII value of character which is actually to be transmitted and lastly the stop bits. In 805 one the start bit is kept at logic 0 and stop bit is kept at logic 1. Now for the serial data transfer in 805 one the two special function registers are provided the one is called S buff and second one is called S call. The S buff register is used to store the actual character to be transferred via the Txd line. So whenever you are going to transfer the character serially it requires to put that character first in the S buff register. Whenever we are putting the any character in S buff register the transmission will start and whatever the character received through Rxd pin that character is also get stored into the S buff register. Now internally this S buff are the two different entities, two different registers but we are accessing these registers with the same address same name that is the S buff but these two registers are differentiated by their operation. The one used for transmission that S buff is always written by the controller and the S buff which receives the received character that S buff register is also is always read by the 805 one. Next special function register is provided which is named as S con register. S con register is used to configure the modes of operation of serial communication and the bit format defined for the S con registers are shown below. The three MSB bits SM0, SM1 and SM2 these three bits are used to decide the actual mode of operation like this. So when SM0 is 0, SM1 is 0 we are saying that the 805 one is operating in mode 0. Similarly when SM0 is 0 SM1 is 1 we are selecting the mode 1 operation of the 805 one and so on. Now the mode 0 is work as simply 8 bit shift register mode. So normally the peoples are not going for the use of the mode 0 then the widely used mode of operation is the 8 bit UART for that SM0 must be 0 and SM1 must be 1 and SM2 bit enables the multiprocessing capability of the 805 one in mode 2 and mode 3. As far as the data transfer rate that is the board rate is concerned the board rate is variable in mode 1 and mode 3 where in mode 0 and the mode 2 the board rate is fixed. Now the last two bits which is called the flag bits TI transmit interrupt flag and RI stands for receive interrupt flag. Now this TI flag is set when 805 one completes the transmission of a character to indicate that now the 805 one is ready to transfer the next byte or the next character. RI flag is set when 805 one receive the character and placed in the SBUFF register and it indicates that this byte has been received and should be read before it is lost. Now to enable the receiver of the 805 one REN bit is to be set. If REN bit is 0 the receiver is disabled and TB8 and RB8 are used when you are designing the frame with the 11 bits where the 11 bit is used as a parity bit which is used for parity or the error detection. Then the algorithm for to transfer the data serially as far as the 805 one is concerned first initialize the timer one in mode 2 timer mode to decide the data transfer rate that is the board rate. Now you pause the video and recall how to initialize the timer one. Now to initialize the timer one load the T-MOD register with the value 20H to operate timer one in mode 2 timer mode. Internally only the timer one is associating with the serial communication that's why to decide the board rate all the times timer one is to be used. After initializing the timer one in mode 2 timer mode. Next step is load the TH1 register with one of the values to set the board rate for serial data transfer. Now how will you find the TH1 value for that use the formula that is board rate is equal to 2 raised to S mod divided by 32 whole multiplied by oscillator frequency divided by 12 into 256 minus TH1. Now the board rate we are deciding so board rate it is always known quantity. So only unknown quantity is TH1 so from this you find the TH1 value to get the required board rate and put in the TH1 register. This S mod bit is from the pecan register by default S mod bit is reset. So this bit is provided to double the board rate by keeping the same value in TH1 register by setting the S mod bit. Then load the Scon register with the value 50H to select the mode one with receiver enable where an 8 bit data is framed with start bit and stop bit. So first start bit will be sent then the 8 bit of the actual character and lastly the stop bit will be gates transmitted. Next start the timer so that the clock will be generated then clear the timer interrupt flag to indicate that the previous character has been transmitted then write the character by to be transferred serially into the S buff register. When you are putting the character in the S buff register the transmission will start. Now next you have to wait till the transmission is not completed. For that you continuously monitor the status of TI flag bit to see if the character has been transferred completely or not. If you find TI bit is set that means the character is transferred now you can put the next character into the S buff register. So before that you clear the TI flag and put the next character to be transferred in the S buff register. So references used for this particular topic microcontrollers by Ajay Deshmukh and 8051 and embedded C program by Mazidi and Mazidi. Thank you.