What Is an SBUF or SCON Register?

30 Apr 2023 Balmiki Mandal 0 Embedded C

SBUF and SCON Registers in Microcontrollers

The SBUF (Serial Buffer) and SCON (Serial Port Control and Status) registers are crucial components for handling serial communication in microcontrollers, particularly the popular 8051 family.

SBUF Register:

  • Acts as a temporary storage for data being transmitted or received through the serial port.
  • Holds 8 bits of data (one byte).
  • When transmitting, data written to SBUF is shifted out serially through the TXD pin.
  • When receiving, data received through the RXD pin is stored in SBUF.

SCON Register:

  • Controls the various aspects of serial communication, including:
    • Mode: Selects the type of serial communication, such as asynchronous or synchronous.
    • Data bits: Determines the number of data bits (5, 6, 7, or 8) sent and received per frame.
    • Stop bits: Sets the number of stop bits (1 or 2) added to the end of a data frame.
    • Start bit: Controls the transmission of the start bit that signals the beginning of a data frame.
    • Receive enable: Enables the receiving functionality of the serial port.
    • Transmit enable: Enables the transmission functionality of the serial port.
    • Multiprocessor communication: Used for communication between multiple processors sharing a single serial port.

Understanding the relationship between SBUF and SCON:

  • SBUF stores the data to be transmitted or received.
  • SCON controls how that data is transmitted or received based on the various mode and configuration settings.
  • Both registers work together to enable serial communication in microcontrollers.

Difference between them SBUF or SCON register

In an 8051 microcontroller, SBUF and SCON are two registers used for serial communication. Here are the differences between these two registers:

  1. Function: SBUF (Serial Buffer Register) is used for storing the data to be transmitted or received during serial communication, while SCON (Serial Control Register) is used for configuring the serial communication mode, setting baud rate, enabling interrupts, and other control functions.

  2. Size: SBUF is an 8-bit register, while SCON is a 1-byte (8-bit) register.

  3. Usage: SBUF is read or written to by the program to transmit or receive data during serial communication, while SCON is written to by the program to configure the serial communication mode and other control functions.

  4. Interrupts: SBUF does not generate any interrupts, while SCON can generate interrupts based on the settings of its control bits. For example, the TI (Transmit Interrupt) bit in SCON is set by hardware when the SBUF register is empty, indicating that the transmit buffer is ready for another byte to be transmitted. Similarly, the RI (Receive Interrupt) bit is set by hardware when a byte is received, indicating that new data is available in the receive buffer.

In summary, SBUF is used for storing data during serial communication, while SCON is used for configuring the serial communication mode and generating interrupts based on various conditions. Both registers are important for serial communication in an 8051 microcontroller, and must be used in conjunction with each other to establish a reliable communication link.

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.