How to configure EUSART in PIC18F4550

Summary of How to configure EUSART in PIC18F4550


This article explains serial communication concepts and details the PIC18F4550 microcontroller’s EUSART (Enhanced USART), covering asynchronous/synchronous and full-/half-duplex modes. It highlights EUSART features such as automatic baud-rate detection and describes key EUSART registers—focusing on the TXSTA transmit control register and its bits (TRMT, BRGH, SYNC, TXEN, TX9) and their functions for configuring serial transfer.

Parts used in the PIC18F4550 EUSART Project:

  • PIC18F4550 microcontroller

Both, Parallel and Serial modes of communication have certain advantages and disadvantages over one another. The serial communication is a preferred option due to its ability of long distance communication with error detection capability. The microcontrollers consist of an inbuilt hardware unit known as USART (Universal Synchronous Asynchronous Reception and Transmission) to facilitate serial transfer of data. For more details, refer to USART in AVR section.

 EUSART in PIC
This article is based on Serial communication using a PIC microcontroller and explores the programming methods and hardware of PIC18F4550’s USART.

Before starting USART, some general terms related to communication need to be understood. These terms are explained below.

Asynchronous Communication:
In this type of communication, both Transmitter (Tx) and Receiver (Rx) work on different clocks which means that they are not synchronized. Start and Stop bits are also sent with each Data byte to identify the data.
Synchronous Communication:
In this type of communication, both Tx and Rx are synchronized with the same clock and no Start or Stop bits are used.
Full-duplex Communication:
When either of the devices can send and receive data at the same instant, they are said to have full-duplex communication.
 
Half-duplex Communication:
In this type of communication, a device can either behave as Transmitter or Receiver at an instant which means that a device can’t transmit data when it is receiving and vice versa.
 
PIC’s EUSART
PIC18F4550 has an inbuilt EUSART (Enhanced USART). Normally USART can be configured as asynchronous full-duplex communication or synchronous half-duplex communication. EUSART provides additional capabilities as compared to USART, like Automatic Baud-rate Detection. Automatic baud-rate detection means that during reception there is no need to set the baud rate at controller’s side, EUSART sets it on its own which is certainly an advantage over USART. Baud rate and its calculation have been explained later in this article.
Registers of EUSART:
To use the EUSART of PIC18f4550 microcontroller following registers need to be configured.
1. TXSTA (Transmit Status and Control Register)
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
CSRC
TX9
TXEN
SYNC
SENDB
BRGH
TRMT
TX9D
TRMT: This is a read only bit which shows the status of Shift register where data is stored.
            1 = Transmit Shift Register Empty
            0 = Transmit Shift Register Full
BRGH: This bit is configured to decide the speed of Asynchronous serial communication.
            1 = High speed
0 = Low speed
SYNC: The mode of communication is selected by this bit.
            1 = Synchronous mode
0 = Asynchronous mode
TXEN: This bit is set to high to enable the transmission.
TX9:    This bit is set to high while sending 9-bit long data.
            1 = Selects 9-bit transmission
0 = Selects 8-bit transmission

Quick Solutions to Questions related to PIC18F4550 EUSART:

  • What types of serial communication modes are described?
    The article describes asynchronous and synchronous serial communication modes.
  • What is asynchronous communication?
    Asynchronous communication uses different clocks for transmitter and receiver and sends start and stop bits with each data byte.
  • What is synchronous communication?
    Synchronous communication has transmitter and receiver synchronized with the same clock and does not use start or stop bits.
  • What is full-duplex communication?
    Full-duplex communication allows devices to send and receive data simultaneously.
  • What is half-duplex communication?
    Half-duplex communication allows a device to either transmit or receive at an instant, not both.
  • What enhanced feature does EUSART provide over USART?
    EUSART provides automatic baud-rate detection among other enhanced capabilities.
  • Which EUSART register is detailed in the article?
    The TXSTA transmit status and control register is detailed.
  • What does the TRMT bit indicate?
    TRMT indicates the transmit shift register status: 1 means empty, 0 means full.
  • How does the BRGH bit affect communication?
    BRGH selects asynchronous speed: 1 for high speed and 0 for low speed.
  • What do the SYNC and TXEN bits do?
    SYNC selects synchronous (1) or asynchronous (0) mode; TXEN enables transmission when set high.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter