How to configure EUSART in PIC18F4550

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.

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.
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
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

Leave a Comment

= 3 + 6

Read previous post:
ESP8266 ESP-03 Dev Board

This is a small dev board I designed to make experimenting with and deploying the ESP8266 ESP-03 modules a bit easier....

Scroll to top