Serial Communication Modes

Serial Communication in 8051

Basics of Serial Communication

  • Computers transfer data in two ways:

serial communication

Difference between serial and Parallel communication

Sr. NoFactorSerialParallel
1No. of bits transmitted per one clock pulseOne bit'n' bits
2No. of line required to transmit 'n' bitsOne line'n' lines
3Speed of data transferSlowFast
4Cost of transmissionLow as only one line is requiredHigher as n lines are required
5ApplicationLong distance communicationSmall disatnce communication
  • Serial data communication uses two methods
  • Synchronous method transfers a block of data at a time

synchronous transmission

Asynchronous – Start & Stop Bit

asynchronous transmission

  • Asynchronous serial data communication is widely used for character-oriented transmissions
    • Each character is placed in between start and stop bits, this is called framing.
  • The start bit is always one bit, but the stop bit can be one or two bits
  • The start bit is always a 0 (low) and the stop bit(s) is 1 (high)
Asynchronous serial communicationSynchronous serial communication
transmitter and  receiver are not synchronized by clock.transmitter and  receiver are synchronized by clock.
Character may arrive at any rate at receiverCharacter is received at constant rate.
Data transfer is character orientedData transfer takes place in blocks.
Start and stop bits are required to establish communication of each character.Start and stop bits are not required to establish communication of each character, however ,synchronization bits are required to transfer the data block.
Used in low-speed transmissionsUsed in high-speed transmission
  • Data Transfer RateThere are special IC’s made by many manufacturers for serial communications.
    • UART (universal asynchronous Receiver transmitter)
    • USART (universal synchronous-asynchronous Receiver-transmitter)
  • The rate of data transfer in serial data communication is stated in bps (bits per second).
  • Another widely used terminology for bps is baud rate.
  • Serial port of 8051 is full duplex, means it can transmit and receive simultaneously.

Interfacing of 8051 to PC using Serial communication

A personal computer has a serial port known as communication port or COM Port used to connect a modem for example or any other device, there could be more then one COM Port in a PC. Serial ports are controlled by a special chip called UART (Universal Asynchronous Receiver Transmitter).

RS 232  standard describes a communication method where information is sent bit by bit on a physical channel. The RS stands for Recommended Standard.The information must be broken up in data words. The length of a data word is variable.  

                    It is one of the popularly known interface standard for serial communication between DTE & DCE. This RS-232-C is the commonly used standard when data are transmitted as voltage .This standard was first developed by Electronic industries association(EIA). For the RS-232C, a 25 pin D type connector is used . DB-25P male and DB-25S female. RS-232 standard was first introduced in 1960’s by Telecommunications Industry Association(TIA).

As the RS-232 standard is developed earlier to TTL devices ,a USART such as 8251 is not directly compatible with these signal levels .Because of this ,voltage transistors called line drivers and line receivers are used to interface TTL logic with RS-232 signals . The line driver MC 1488 is used  to convert RS-232 to TTL.The microcontroller is connected to the PC using the DB9 connector.

serial communication interfacing

The TxD and Rx D pins are connected to the TI in and RI in pins of the MAX 232 IC and the TI out and RI in pins of the MAX IC are connected to the RxD and TxD pins of the DB9 connector as shown in the interface diagram

Baud Rate:-The rate at which the number of bits are transmitted

PC and microcontroller supports various types of Baud rates eg. 19200,9600,4800,2400,1200 etc


TH1=256-[\frac{k* XTAL freq}{384*Baudrate}]


  • TH1=Value to be loaded in TH1 register
  • k=1 when SMOD=0 from PCON register
    k=2 when SMOD=1 from PCON register
    • XTAL freq=11.0592 MHz
      Baud RateTH1 value  in decimalTH1 value in Hex


8051 Registers related to Serial Communication

  1. SBUF Register     -- to hold data
  2. SCON Register    -- controls data communication
  3. PCON Register    --  controls data rates

SBUF Register

  • SBUF is an 8-bit register used  for serial communication.
  • For a byte data to be transferred via the TxD line, it must be placed in the SBUF register.
  • The moment a byte is written into SBUF, it is framed with the start and stop bits and transferred serially via the TxD line.
  • SBUF holds the byte of data when it is received by 8051 RxD line.
  • When the bits are received serially via RxD, the 8051 deframes it by eliminating the stop and start bits, making a byte out of the data received, and then placing it in SBUF.
  • NOTE:   SBUF  is physically two registers . one is write only and is used to hold data to be transmitted out of the 8051 via TXD. The other is read only and holds received data from external sources via RXD. Both mutually exclusive registers use address 99h.

Serial Port Control (SCON)  Register

7SM0Serial port mode bit 0.Set/Cleared by program to select mode
6SM1Serial port mode bit 1.Set/Cleared by program to select mode
5SM2SM2=0;Single processor environment
SM2=1;Multi-Processor environment
4RENREN=0;Microcontroller is not allowed to receive data
REN=1;Microcontroller is allowed to receive data
3TB8TB8=0;Not used
TB8=1;used as 9th data bit(Only in mode-2,mode-3)
2RB8RB8=0; Not used
RB8=1;used as 9th data bit(Only in mode-2,mode-3)
1TITI=0; Indicates transmission is in progress
TI=1; Indicates transmission of 8-bit charater is succesful and 8051 is ready to transmit another byte of data
0RIRI=0; Indicates reception is in progress
RI=1; Indicates reception of 8-bit charater is succesful and 8051 should pick the data before its going to lost
SMO,SM1 bits
00Serial mode 0Shift register; Baud rate=Crystal freq./12
01Serial mode18-BIT UART; Baud rate=Variable
10Serial mode 29-BIT UART; Baud rate=Crystal freq./32 or Crystal freq./64
11Serial mode 310-BIT UART; Baud rate=Variable
8051 Serial Port – Mode 0

The Serial Port in Mode-0 has the following features:

  1.  Serial data enters and exits through RXD
  2. TXD outputs the clock
  3.  8 bits are transmitted / received
  4.  The baud rate is fixed at (1/12) of the oscillator frequency
8051 Serial Port – Mode 1

The Serial Port in Mode-1 has the following features:
 Serial data enters through RXD
Serial data exits through TXD
On receive, the stop bit goes into RB8 in SCON

10 bits are transmitted / received

  1.  Start bit
  2.  Data bits (8)
  3.  Stop Bit

 Baud rate is determined by the Timer 1 over flow rate.

Standard UART data word under mode-1

UART dframe

8051 Serial Port – Mode 2

The Serial Port in Mode-2 has the following features:

  1.  Serial data enters through RXD
  2.  Serial data exits through TXD
  3.  9th data bit (TB8) can be assign value 0 or 1
  4.  On receive, the 9th data  bit goes into RB8 in SCON
  5. 11 bits are transmitted / received
    1. Start bit
    2. Data bits (9)
    3. Stop Bit
  6. Baud rate is programmable

multiprocessor data word

8051 Serial Port – Mode 3

The Serial Port in Mode-3 has the following features:

  1.  Serial data enters through RXD
  2.  Serial data exits through TXD
  3.  9th data bit (TB8) can be assign value 0 or 1
  4.  On receive, the 9th data  bit goes into RB8 in SCON
  5. 11 bits are transmitted / received
    1. Start bit
    2. Data bits (9)
    3. Stop Bit
  6. Baud rate is determined by Timer 1 overflow rate.

Programming 8051 to transmit/receive data serially

Step I: The TMOD register is loaded with value=20H indicating Use of Timer1 in mode 2 i.e 8-bit Auto-reload
Step II: TH1 register is loaded with one of the values to set the baud rate for serial communication
Step III: The SCON register is loaded with the value

  • MOV SCON, #40H ;indicating serial mode 1
  • MOV SCON, #50H ;indicating serial mode 1, Reception enable

Step IV: Start timer1 with instruction setb TR1
Step V: 

  • Here: JNB TI, Here ;The TI flag bit is monitored with the use of instruction
  • Here: JNB RI, Here ;The RI flag bit is monitored with the use of instruction

Step VI: Clear TI flag before transmission of next character

Write an ALP for 8051 to transmit letter 'A' serially at the baud rate 4800 continuosly
org 00H
MOV TH1,#-6
Again: MOV SBUF,#'A'
Here:JNB TI,Here
clr TI
sjmp Again
Doubling Baud Rate
  • There are two ways to increase the baud rate of data transfer
    1. By using a higher frequency crystal
    2. By changing a bit in the PCON register

Power Mode Control (PCON) Register

  • PCON register is an 8-bit SFR.
  • It is byte addressable register.

SMOD: double baud rate bit. When 8051 is powered  up, SMOD bit is at zero value. To double the baud rate SMOD to be set to 1.

Structure of SCON Register

Serial baud rate modify bit, Set
SMOD=1; Baud rate will be doubled
SMOD=0; Baud rate will remain as it is

6-4-Not implemented
3GF1General purpose user flag bit 1
2GF0General purpose user flag bit 0
1PDPD=1;Microcontroller enters into power down mode
0IDLEIDLE=1;Microcontroller enters into IDLE power saving mode

Significance of SMOD bit from PCON Register



TH1=256-[\frac{k* XTAL freq}{384*Baudrate}]


  • TH1=Value to be loaded in TH1 register
  • k=1
  • XTAL freq=11.0592 MHz


TH1=256-[\frac{k* XTAL freq}{384*Baudrate}]


  • TH1=Value to be loaded in TH1 register
  • k=2
  • XTAL freq=11.0592 MHz
  • PD: power down bit . Setting this bit high activates power down mode known also sleep mode. In this mode, the CPU puts the whole chip to sleep by turning off the oscillator. under this mode power consumption becomes minimum.
  • IDL : idle mode, setting this mode bit high activates idle mode. In this mode, the oscillator continues to provide clock to the peripherals, but no clock is provided to the CPU, as the CPU is under sleep state.

Note:  if PD and IDL are set to high at the same time, PD takes precedence


  • Created and edited by Prof.S.M.Wagh,SKNCOE,Pune
  • WikiNote Foundation

Last modified: Tuesday, 17 September 2019, 3:07 PM