There are two serial ports in all the systems(computer, laptop) DB-9 and DB-25. You can transfer data serially to PC using these ports, DB-9 has 9 pins and DB-25 has 25 pins, both ports comes in male and female package. Below is pin out of both the male and female connectors
How serial data can be transferred using 8051 microcontroller?
Why use of Level converter – Max232
8051 microcontroller serial data transfer – Project code
Now about the internal registers of 8051 which are used in the code. TMOD (Timer mode) this register is used to initialize the mode of the timer. The only mode which can be used to transfer data serially to pc is 8-bit auto reload. To initialize the timer in this mode use command 0x20 which loads the timer 1 in 8-bit auto reload mode. I am using timer 1 in my program so i used the command 0x20, but if you want to use timer 0 you can use it and the command for it is different its 0x02 take a look at the diagram below.
8051 microcontrollers completes one machine cycle after every 12 clock cycles. So our Instruction execution frequency is crystal frequency/12. Now if our crystal is of 11.0592 MHz then our effective frequency is 11.0592/12 MHz => 921.6 KHz. 8051 UART further divides this frequency (921.6 KHz) by 32 to generate its baud rate. Therefore effective frequency available to generate baud rates is 921.6 KHz/32 = 28800 Hz.
For different baud rates the values of TH1 will be different for Baud Rate 9600 TH1 will be=0xFD because 28800/9600 = 3. 3 is 11 in binary take its two’s complement -3 and load the value in TH1 for 9600 baud rate. Calculate different baud rates for different crystals using the same above formula. Different baud rates with 11.0592 MHz crystal are below.
SCON(serial control) register is used to control the flow of data. This is an 8-bit register and also it is bit addressable You can access its single bit. Here is a diagram of SCON with individual bits and modes which you can specify.TI is Transmit Interrupt flag, When 8051 microcontroller finishes the transfer of 8-bit character, it raises the TI flag to indicate that it is ready to transfer another byte.
RI is Receive Interrupt flag, When 8051 receive data via RxD, it get rid of the start and stop bits and places the byte in the SBUF. Then it raises the RI flag to indicate that a byte has been received and should be picked up before it is lost.
SBUF(serial buffer) is an 8-bit register it is not bit addressable when we have to transfer character we place it in SBUF register and poles the TI flag. When data is received which is sended by some other source it is also placed in SBUF register, and we pick it from here.
Filed Under: 8051 Microcontroller, Microcontroller Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.