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
Before starting USART, some general terms related to communication need to be understood. These terms are explained below.
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.
In this type of communication, both Tx and Rx are synchronized with the same clock and no Start or Stop bits are used.
When either of the devices can send and receive data at the same instant, they are said to have full-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.
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)
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
Current Project / Post can also be found using:
- configure eusart rx on pic18f2550
- how to configure the eusart section in pic
- uart pic 18 f 4550