 Hello and welcome to this presentation on UART serial communication module of 8051 microcontroller. So as we all know serial communication has certain advantages so learning outcome of this presentation will be student will be able to compare serial communication with the parallel communication what are the advantages and drawbacks of each as well at the end student will be able to write assembly language program for serial communication using UART module of microcontroller 8051. So this these are the contents of the presentation we will talk have introduction then we will compare serial and parallel communication then we will go through the UART structure and then various spatial function registers related to the UART and then we will see how we can handle that particular UART module. So this brief introduction for UART so in 8051 we have a UART type of serial communication facility where we can have asynchronous reception and transmission as we know there is a difference between synchronous and asynchronous in asynchronous serial communication what we do is we do framing and then no need to send clock signal from sender to receiver. So it supports UART serial communication supports full duplex serial communication so that we can have transmission as well as reception simultaneously. So as we know in the PIN diagram Rxd and Txd are the two PINs which are related to this UART module whenever you are sending the data so whatever data is sent that goes on to the PIN 3.2 port 3 PIN number 1 and it goes on Txd PIN and whenever you are receiving the data the data will come on to the PIN number 0 of port 3. So let us compare what is serial communication and parallel communication when you go for the serial communication so the line ideally required between sender and receiver is only one so when you go for parallel communication we assume that 8 bit data you are transmitting simultaneously so 8 different lines are required between the sender and receiver. So now you compare what will be the advantage of serial communication if the sender and receiver if you compare distance between sender and receiver if it is more then definitely if you go for serial communication only one wire is required from sender to receiver but if you go for the parallel communication so 8 different lines will be required for that definitely when you go for parallel communication speed of transmission will increase because at a time 8 bit data you are sending here here bit by bit you are sending the data but if the communication speed which is available with this serial communication itself is sufficient for certain application then why to go for this parallel communication which will increase additional hardware cost in the form of number of lines increase or if the senders and receivers are far away then you need to have channel established between the sender and receiver physically. This is block diagram of UART module so there is one register called as ESBUFF register which plays important role in the serial communication. ESBUFF is a single register as far as the programmer is concerned but as far as the hardware is concerned physically there are two separate ESBUFF registers so there is only one special function register address for this but physically there are two ESBUFF registers. Let us talk about how we do transmission using ESBUFF so whenever you want to transmit some data serially on to the TXT pin so on to the data bus you will send the data that data will go to the ESBUFF register and then this ESBUFF register will convert that parallel data received serial on to the TXT pin as well same ESBUFF register is used for reception also so whenever you are receiving some data so some broad broad rate clock generation is done at the receiver side as it is a synchronous communication broad rate clock has to be generated at the receiver side so that is generated and then you receive the data serially that serial to parallel conversion is done by this shift register and then again it goes to the ESBUFF register so whenever you are reading the whenever you are receiving the data the received data is available in ESBUFF register as well when you are transmitting the data data you have to copy into the ESBUFF register so this how basically the UART communication module works for microcontroller 8051 so two pins are there TXD and RXD so whatever data you are sending will go on to TXD pin and whatever data you are receiving will be available through RXD pin on to the internal data bus as we know it is asynchronous communication so frame formation is required for asynchronous communication so this how one way of forming the frame where you are sending some data D0 to D7 are the actual data bits which you want to send so actual frame form contains these data bits along with the redundancy in the form of one start bit which is added as well one stop bit is added so though you are sending 8 bit data actual data send is of 10 bits so this how you are forming the frame and then when you are sending the frame you have to decide certain board rate at what board rate you will be sending the data so let us talk about different special function registers which are related to the serial communication so basically there are three registers used so one important register we will discuss here which is yes con register this is a bit format along with this register one more register which is yes buff which already we discuss and then one more register is there which is pecan register rather it is related to the power control but there is only one bit in that pecan register called as yes mod and which is used for the serial communication board rate selection so this is the bit format this is the special function register for serial communication called as yes con so as we know that serial communication can generate interrupts so this TI and RI are the inter flag bits so whenever transmission is successful automatically this TI flag bit is set and whenever reception is successful when you are acting as a receiver this RI flag bit is set now if you look at this TI and RI flag bits so these are set by hardware but one important thing is these bits has to be cleared by the programmer as far as other interrupts are concerned all those inter flag bits are automatically cleared by the hardware itself by microcontroller itself but now here it will be responsible to the programmer to clear these bits when these bits are set now this TI RI are used for generating the timer the serial communication interrupt now this TB8 and RB8 so when you want to give a facility of error control in the serial communication in the form of adding some sort of parity checked as sort of techniques in that case we know that in the PSW of the microcontroller there is one flag called as parity flag so that parity flag information can be fetched into this TB8 and this TB8 value is used as parity or additional 9 bit which can be used for the transmission so TB8 is the additional 9 bit you will be sending and then if you are sending 9 bit data so that 9th receive data bit at the receiver side will go into the RB8 register of the receivers ESCON register now there is one control bit called as REN REN stands for reception enable so when you want to enable the reception receiver can decide whether it wants to receive the data or not so REN is one so then reception will be enable otherwise it is disabled so those sender is sending the data receiver will not receive that data because REN is disabled so if you look at REN reception enable is the bit available here but there is no T and transmission enable see this is with the intention that whenever user programmer wants to transmit the data then only programmer will write that data into the SBUFF register so no need to have any transmission enable bit there now remaining three bits are for mode selection so this SM2 bit is used for the multi processor communication whenever you are doing communication serial communication that to between two controllers so usually we do communication between peripheral controller but whenever more than two controllers are communicating with each other so that multi processor communication can be handled by this SM2 bit and this SM0 and SM1 are forming four different modes these two bits are used to decide four different modes of operation of this UART module so these are the four modes so SM0 SM1 is equal to 00 then mode 0 so what this mode 0 is it's a shift register mode so this shift register mode can be used for increasing the port capability of the microcontroller so serially you can send the data and then you can connect shift register to the serial communication pin and then that data will be available parallely so you may say that additional port is now available to you like that so mode one of serial communication is 8 bit data transmission but here facility is border it can be very easily varied now mode 2 and mode 3 are using 9 bit data transmission only in mode 2 9 bit transmission but border it is fixed that cannot be varied but in mode 3 what you can have 9 bit transmission along with that border it will be decided by the formula which we use for the mode one so this is one simple code how we can do assembly language coding code for serial transmission so this is all about for selecting the border it so minus 12 is loaded in TH1 to have a border it of 4800 so you set that TR1 bit timer is running so border it is selected and then let us say you want to send four characters EXTC so what I do is I send the character I load that character into A and I call a subroutine called as trans in trans what we do is the contents of accumulator are available in yes buff as we discussed if the contents are available in yes buff register those are serially transmitted at the end just what I check is whether TIBT set or not if TIBT set then it is confirmed that that particular character is serially transmitted successfully then we clear that and then we return back to the main program so first EXTC so all these four characters will be sent actual these things are written in single quotes means it's ASCII value is loaded in the accumulator register and hence after running this particular code you'll find that EXTC these four characters are sent serially so these are the references used for this presentation thank you