UART Communication in 8051 Microcontroller: Registers, Modes & Programming

Introduction: Understanding UART Communication in the 8051 Microcontroller

Serial communication is one of the most essential features of modern embedded systems, enabling microcontrollers to exchange data with computers, sensors, communication modules, and other electronic devices. Among the various serial communication protocols available, UART (Universal Asynchronous Receiver/Transmitter) is one of the simplest, most reliable, and widely used communication methods. The 8051 microcontroller includes an integrated UART module that supports efficient full-duplex serial communication, making it a popular choice for embedded systems applications.

Unlike synchronous communication protocols such as SPI and I²C, UART does not require a separate clock signal. Instead, both the transmitter and receiver operate at the same baud rate, allowing data to be transmitted asynchronously using only two communication lines: Transmit (Tx) and Receive (Rx). This simplicity makes UART ideal for applications such as PC communication, GPS modules, GSM modems, Bluetooth devices, Wi-Fi modules, RFID readers, Zigbee modules, sensor interfacing, and industrial automation systems.

Understanding concepts such as serial communication, UART protocol, baud rate calculation, SCON register, SBUF register, PCON register, Timer 1 configuration, UART modes, interrupt-driven communication, embedded C programming, data transmission, data reception, RS-232 communication, and microcontroller interfacing is essential for students and professionals working in electronics, embedded systems, Internet of Things (IoT), and automation.

As industries increasingly adopt Internet of Things (IoT), smart devices, robotics, automotive electronics, industrial control systems, medical equipment, and wireless communication, mastering UART programming has become a valuable skill for embedded engineers.

To help students build strong practical knowledge, Embedded Tech Development Academy (ETDA) offers industry-oriented embedded systems training with hands-on laboratory sessions, real-time projects, and practical exposure to microcontroller programming, UART communication, sensor interfacing, Internet of Things (IoT) development, PCB design, and embedded C programming. Through project-based learning, Embedded Tech Development Academy (ETDA) equips students with the skills needed to succeed in the embedded systems and electronics industries.

In this article, you’ll learn the fundamentals of UART communication in the 8051 microcontroller, UART registers, operating modes, baud rate calculation, programming examples, practical applications, and best practices for reliable serial communication.

What is UART Communication?

UART (Universal Asynchronous Receiver/Transmitter) is a hardware communication protocol that enables serial data transfer between two electronic devices without using a clock signal.

It supports full-duplex communication, meaning data can be transmitted and received simultaneously.

Key Features of UART

  • Asynchronous communication
  • Full-duplex transmission
  • Simple two-wire interface
  • Low hardware complexity
  • Reliable serial communication
  • Widely supported by microcontrollers

How UART Work

UART communication transfers data one bit at a time in a predefined format.

UART Data Frame

A standard UART frame consists of:

  • Start Bit (0)
  • 8 Data Bits
  • Optional Parity Bit
  • Stop Bit (1)

Communication Pins

The 8051 uses:

  • P3.1 (TxD) → Transmit Data
  • P3.0 (RxD) → Receive Data
H5: UART Communication Flow

Microcontroller → UART Transmitter → Serial Line → UART Receiver → Destination Device

UART vs SPI vs I²C

Different communication protocols serve different purposes.

Feature UART SPI I²C
Communication Type Asynchronous Synchronous Synchronous
Communication Pins Tx, Rx MOSI, MISO, SCK, SS SDA, SCL
Speed 9600–115200 bps (Typical) Up to Several MHz 100–400 kHz (Standard)
Communication Style Point-to-Point Multi-Slave Multi-Master & Multi-Slave

Why Choose UART?

UART is preferred because:

  • Simple hardware design
  • Easy debugging
  • Reliable communication
  • Ideal for long-distance serial communication

UART Registers in the 8051

The UART module is controlled using dedicated Special Function Registers (SFRs).

1. SCON (Serial Control Register)

The SCON register controls UART communication.

Important Bits

Bit Name Function
SM0, SM1 Serial Mode Select UART operating mode
SM2 Multiprocessor Communication Used in Modes 2 & 3
REN Receive Enable Enables UART Receiver
TB8 Transmit Bit 8 Used in 9-bit modes
RB8 Receive Bit 8 Used in 9-bit modes
TI Transmit Interrupt Flag Indicates transmission complete
RI Receive Interrupt Flag Indicates data received
Purpose of SCON

SCON configures UART operation and controls data transmission and reception.

2. PCON (Power Control Register)

The PCON register contains the SMOD bit.

SMOD Bit

  • SMOD = 1 → Doubles UART baud rate
  • SMOD = 0 → Normal baud rate

3. SBUF (Serial Buffer Register)

The SBUF register stores:

  • Data to be transmitted
  • Received serial data

Writing to SBUF starts transmission.

Reading SBUF retrieves received data.

UART Operating Modes

The 8051 supports four UART operating modes.

Mode Description Baud Rate
Mode 0 Shift Register Mode Fixed (Fosc/12)
Mode 1 8-bit UART Variable
Mode 2 9-bit UART Fixed
Mode 3 9-bit UART Variable

Mode 1

The most commonly used UART mode.

Features include:

  • 8-bit data
  • Variable baud rate
  • Timer 1 controlled

Applications include:

  • PC communication
  • GPS
  • GSM
  • Bluetooth

Baud Rate Calculation

In Mode 1 and Mode 3, Timer 1 operating in Mode 2 (8-bit Auto Reload) generates the baud rate.

Baud Rate Formula

Baud Rate = (2^SMOD / 32) × (Oscillator Frequency / (12 × (256 − TH1)))

Where:

  • TH1 = Timer reload value
  • SMOD = PCON register bit

Example

For:

  • Crystal = 11.0592 MHz
  • Baud Rate = 9600 bps

TH1 = FDH

This configuration is commonly used in embedded applications.

UART Programming Example

Basic UART Initialization

Typical UART programming involves:

  • Configure Timer 1
  • Configure SCON
  • Load TH1
  • Start Timer 1
  • Enable receiver
  • Transmit or receive data using SBUF

Basic Programming Steps

  • Configure TMOD
  • Load TH1
  • Configure SCON
  • Start Timer 1
  • Write data into SBUF
  • Wait for TI flag
  • Clear TI
  • Receive data using RI

Applications of UART Communication

UART is widely used in embedded systems.

Common Applications

  • PC communication
  • GPS modules
  • GSM modem interfacing
  • Bluetooth communication
  • Wi-Fi modules
  • Zigbee communication
  • RFID readers
  • Sensor data logging
  • Industrial automation
  • Medical devices
  • Internet of Things (IoT) devices
  • Robotics

Advantages of UART

Benefits

  • Simple hardware interface
  • Low implementation cost
  • Full-duplex communication
  • Easy debugging
  • Reliable data transmission
  • Broad industry support

Programming Tip

Always ensure both communicating devices are configured with the same baud rate, data bits, parity, and stop bits to avoid communication errors.


Best Practices for UART Programming

Design Recommendations

  • Match baud rates correctly.
  • Enable UART interrupts when required.
  • Clear TI and RI flags after use.
  • Verify oscillator frequency.
  • Use shielding for long communication cables.
  • Test communication using serial terminal software such as PuTTY.

Frequently Asked Questions (FAQs)

What is UART in the 8051 microcontroller?

UART (Universal Asynchronous Receiver/Transmitter) is a built-in serial communication peripheral in the 8051 microcontroller that enables full-duplex data transmission and reception without requiring a clock signal.

The 8051 uses P3.1 (TxD) for transmitting data and P3.0 (RxD) for receiving data during UART communication.

The SCON (Serial Control) register configures the UART operating mode, enables data transmission and reception, and manages transmit (TI) and receive (RI) status flags.

In UART Modes 1 and 3, the baud rate is generated using Timer 1 configured in Mode 2 (8-bit Auto Reload). The baud rate depends on the oscillator frequency and the TH1 reload value.

UART is commonly used for PC communication, GPS interfacing, GSM modules, Bluetooth devices, Wi-Fi modules, Zigbee communication, RFID readers, sensor data logging, industrial automation, IoT systems, and embedded debugging.

Conclusion

UART communication remains one of the most widely used serial communication protocols because of its simplicity, flexibility, and reliability. By understanding UART protocol, serial communication, SCON register, SBUF register, PCON register, Timer 1 configuration, baud rate calculation, interrupt-driven communication, data framing, embedded C programming, and asynchronous communication, developers can build efficient embedded systems capable of communicating with a wide range of external devices.

From GPS receivers, GSM modules, Bluetooth devices, Wi-Fi modules, RFID readers, industrial automation systems, medical instruments, Internet of Things (IoT) devices, robotics, consumer electronics, and smart embedded products, UART continues to play a critical role in modern electronics. A solid understanding of 8051 UART programming, microcontroller interfacing, serial communication protocols, baud rate optimization, and hardware debugging enables engineers to develop reliable and high-performance embedded applications.

At Embedded Tech Development Academy (ETDA), students gain practical expertise in UART communication through hands-on embedded laboratories, real-time microcontroller projects, sensor interfacing, Internet of Things (IoT) development, PCB design, and embedded C programming. ETDA‘s industry-focused training approach helps learners bridge the gap between academic theory and industrial practice, preparing them for successful careers in embedded systems, electronics design, semiconductor industries, and automation.

Whether you are an engineering student, electronics enthusiast, or aspiring embedded systems engineer, mastering UART communication in the 8051 microcontroller is a fundamental step toward building intelligent and connected embedded systems.

Author: ETDA Trainers
Experience: 10+ Years of Industry Experience in Embedded Systems, IoT, and Embedded C Programming