Serial Communication Basics

In this tutorial, we will see the Basics of Serial Communication Basics Tutorial.

You can also read the PIC16F877A USART tutorial, RF module interfacing with LPC2148, 8051 UART tutorial, RTOS Basics, and LPC2148 Serial communication.

Serial Communication Basics Tutorial

Introduction

What is mean by communication?

Exchanging the data between two systems is termed as communication. Data can be anything and in any form – they could be written/spoken words, in form of media like audio/video. But what does communication between two microcontrollers mean? It is simple! An exchange of data (bits)! There are many protocols for communication (which would be discussed later) but all of them are based on either serial communication or parallel communication.

Types of communication

Basically, there are two types of communication

  • Parallel communication
  • Serial communication

Parallel communication

Example: Printer

  • It will send one byte at a time (8-bits).
  • Fast, but distance cannot be great.
  • Expensive.

Serial communication

 Example: Telephone line

  • It sends one bit at a time.
  • Long-distance
  • Cheaper

Serial Communication Basics

Types of Serial Communication

There are two methods of Serial Communication.

  1. Synchronous: Transfer block of data (characters) at a time.
  2. Asynchronous: Transfer a single byte at a time.

Serial Communication Terminologies

Now it’s time to learn about some new words. There are many terminologies or ‘keywords’ associated with serial communication. We will discuss all of them one by one:

  1. MSB/LSB: This stands for Most Significant Bit/Least Significant Bit. Since data is transferred bit-by-bit in serial communication, one needs to know which bit is sent out first: MSB or LSB.
  2. Simplex Communication: In this mode of serial communication, data can only be transferred from transmitter to receiver and not vice versa.
  3. Half Duplex Communication: this means that data transmission can occur in only one direction at a time, i.e. either from master to slave, or slave to master, but not both.
  4. Full Duplex Communication: full-duplex communication means that data can be transmitted from the master to the slave, and from slave to the master at the same time!

Serial Communication Basics

  1. Baud Rate: According to Wikipedia, baud is synonymous to symbols per second or pulses per second. It is the unit of symbol rate, also known as baud or modulation rate. However, though technically incorrect, in the case of modem manufacturers baud commonly refers to bits per second.

Importance of Baud Rate

For two microcontrollers to communicate serially they should have the same baud rate, else serial communication won’t work properly. The receiver might receive the junk data. This is because, when you set a baud rate, you telling the microcontroller to transmit/receive the data at that particular rate. So, if you set different baud rates, then the receiver might miss out some bits which the transmitter is sending (because it is configured to receive data and process it with a different speed!).

If you don’t understand still I will tell you a small explanation that will help you. You and I are playing a game which is called catch and throw the ball. So, my task is to throw the ball. Your task to catch those balls which were thrown by me. Ok, this is the game. Here my capacity is I can throw 10 balls per minute. Your capacity is you can catch 10 balls per minute. So I’m throwing the 10 balls. Then you can able to catch the all balls. Can’t you? So, now I drink some energy drinks. My strength got increased. Now I can throw 20 balls per minute. But your capacity is still 10 balls. Now tell me. Can you able to catch the all balls? You can’t, right. So, our strength should be the same to catch-all balls. I hope you got it now. So, here the strength is the baud rate. Balls are data.

Different baud rates are available for use. The most common ones are 2400, 4800, 9600, 19200, 38400, etc. You cannot choose any arbitrary baud rate, there are some fixed values that you must use like 2400, 4800, etc. Please note that the unit of baud rate is bps (bits per second).

Serial Transmission Modes

Serial data can be transferred in two modes – asynchronous and synchronous.

Asynchronous Communication

Data Transfer is called Asynchronous when data bits are not “synchronized” with a clock line, i.e. there is no clock line at all! Whenever we are using the asynchronous mode that time baud rate is important. 

Serial Communication Basics

Synchronous Communication

Synchronous data transfer is when the data bits are “synchronized” with a clock pulse. In synchronous transmission, the clock data is recovered separately from the data stream and no start/stop bits are used. This improves the efficiency of transmission on suitable channels since more of the bits sent are usable data and not character framing.

UART   – Universal Asynchronous Receiver and Transmitter 

USART – Universal Synchronous Asynchronous Receiver and Transmitter

The only difference between them is that UART supports only asynchronous mode, whereas USART supports both asynchronous and synchronous modes. Unlike Ethernet, Firewire, etc., there is no specific port for UART/USART. They are commonly used in conjugation with protocols like RS-232, RS-434, etc. (we have specific ports for these two!).

Serial Communication Protocols

A variety of communication protocols have been developed based on serial communication in the past few decades. Some of them are:

  1. SPI – Serial Peripheral Interface: It is a three-wire-based communication system. One wire each for Master to slave and Vice-versa, and one for clock pulses. There is an additional SS (Slave Select) line, which is mostly used when we want to send/receive data between multiple ICs.
  2. I2C – Inter-Integrated CircuitPronounced eye-two-see or eye-square-see, this is an advanced form of USART. The transmission speeds can be as high as a whopping 400KHz. The I2C bus has two wires – one for the clock, and the other is the data line, which is bi-directional – this being the reason it is also sometimes (not always – there are a few conditions) called Two Wire Interface (TWI). It is a pretty new and revolutionary technology invented by Philips.
  3. FireWire – Developed by Apple, they are high-speed buses capable of audio/video transmission. The bus contains a number of wires depending upon the port, which can be either a 4-pin one, or a 6-pin one, or an 8-pin one.
  4. Ethernet: Used mostly in LAN connections, the bus consists of 8 lines, or 4 Tx/Rx pairs.
  5. Universal serial bus (USB): This is the most popular of all. Is used for virtually all type of connections. The bus has 4 lines: VCC, Ground, Data+, and Data-.
  6. RS-232 – Recommended Standard 232: The RS-232 is typically connected using a DB9 connector, which has 9 pins, out of which 5 are input, 3 are output, and one is Ground. You can still find this so-called “Serial” port in some old PCs. In our upcoming posts, we will discuss mainly RS232 and USART of AVR microcontrollers.

RS232:

RS232 was set by the Electronics Industries Association (EIA) in 1960.

  1. 1963: RS232A

  2. 1965: RS232B

  3. 1969: RS232C

  4. RS232 is a serial I/O interfacing standard; however, since the standard was set long before the advent of the TTL logic family, its input and output voltage levels are not TTL compatible.

  5. TTL is the Transistor-Transistor Logic family (Bipolar transistor) in 1968.

Line Driver: MAX232:

  1. RS232 is not compatible with TTL. For this reason, to connect any RS232 to a microcontroller system, we must use “Voltage Converters” such as MAX232 to convert the TTL logic levels to the RS232 voltage levels, and vice versa.

  2. MAX232 IC chips are referred to as “Line Driver”.

RS232 Connector: (DB-9):

Thanks for reading. If you have any doubts please ask us by commenting below.

You can also read the below tutorials.

Linux Device Driver TutorialsC Programming Tutorials
FreeRTOS TutorialsNuttX RTOS Tutorials
RTX RTOS TutorialsInterrupts Basics
I2C Protocol – Part 1 (Basics)I2C Protocol – Part 2 (Advanced Topics)
STM32 TutorialsLPC2148 (ARM7) Tutorials
PIC16F877A Tutorials8051 Tutorials
Unit Testing in C TutorialsESP32-IDF Tutorials
Raspberry Pi TutorialsEmbedded Interview Topics
Reset Sequence in ARM Cortex-M4BLE Basics
VIC and NVIC in ARMSPI – Serial Peripheral Interface Protocol
STM32F7 Bootloader TutorialsRaspberry PI Pico Tutorials
STM32F103 Bootloader TutorialsRT-Thread RTOS Tutorials
Zephyr RTOS Tutorials - STM32Zephyr RTOS Tutorials - ESP32
AUTOSAR TutorialsUDS Protocol Tutorials
Product ReviewsSTM32 MikroC Bootloader Tutorial
VHDL Tutorials
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Table of Contents