100% found this document useful (1 vote)
162 views

Serial Communication Basics

The document provides an overview of several common serial communication protocols: UART, SPI, I2C, and USB. It describes the basic operation and characteristics of each protocol, including connection methods, data transmission, advantages and disadvantages. UART uses two wires for asynchronous communication between two devices. SPI is a synchronous protocol that uses separate clock and data lines to communicate from a single master to multiple slaves. I2C is a two-wire interface that allows multi-master communication between chips. USB allows connection of many devices to a computer and uses a tiered addressing system to manage communication between devices.

Uploaded by

John Doe
Copyright
© © All Rights Reserved
100% found this document useful (1 vote)
162 views

Serial Communication Basics

The document provides an overview of several common serial communication protocols: UART, SPI, I2C, and USB. It describes the basic operation and characteristics of each protocol, including connection methods, data transmission, advantages and disadvantages. UART uses two wires for asynchronous communication between two devices. SPI is a synchronous protocol that uses separate clock and data lines to communicate from a single master to multiple slaves. I2C is a two-wire interface that allows multi-master communication between chips. USB allows connection of many devices to a computer and uses a tiered addressing system to manage communication between devices.

Uploaded by

John Doe
Copyright
© © All Rights Reserved
You are on page 1/ 24

Serial

Communication
I2C, SPI, UART and USB

Prepared by
Snehangshu Bhattacharya
Index Introduction to Serial Communication

UART protocol

SPI protocol

I2C protocol

Introduction to USB protocol


What is Serial Communication?

➔ It is a process of sending data over a channel


➔ Data is sent one bit at a time over the communication
channel / bus
Serial
Communication
Types
Serial Parallel
VS
Communication Communication
➔ One bit at a time over a channel / bus ➔ Multiple bit at a time over a channel / bus
➔ Single line Communication ➔ Multi line Communication
➔ Long distance and higher frequency ➔ Short distance and lower frequency
operations operations
➔ Low error and noise ➔ High error and noise
➔ Simple and Low Cost ➔ Complicated and Costly
Why Serial
Is better?
➔ Lower Size
➔ No Cross-Talk
➔ No Out-of-Sync Delay
➔ Hot-Pluggable
UART
Universal Asynchronous Receiver-Transmitter

➔ It is a hardware device that can send/receive data between two devices


serially
➔ Two device communicate directly and must know the speed of
communication
➔ No clock is required to transmit / receive data
Connection

How UART works


Bit Pattern
Baud Rate
➔ Start Bit: 1st bit, Generally Logic Low
The rate at which information is ➔ Data Bits: Next 5-8 bits, carries information
transferred in a communication channel. ➔ Parity Bit: Next 1 bit, carries the parity value
"9600 baud" means that the serial port is for error checking
currently transferring data at speed 9600 ➔ Stop Bit(s): Next 1 or 2 bit(s), stops the data
bits per second frame
Advantages of Disadvantages of
UART UART
➔ Only uses two wires ➔ Size of the data frame is limited to
9 bits (8 data + 1 parity)
➔ Clock not required
➔ Multiple master / slave
➔ Reliable as both transmitter and configuration not possible
receiver are aware of the speed ➔ The baud-rate of transmitter and
aka “baud-rate” receiver must be within 10% of
each other to avoid errors
Live Demo: Chat-Over-UART
A simple μC to μC chat over UART protocol

➔ Devices used: 1 x Arduino UNO , 1 x Arduino MEGA 2560, a pair of wires


➔ Baud Rate Used: 9600 bps
➔ Supporting Softwares: Arduino IDE, Serial Terminal (Serial Monitor)
➔ Source Code: https://github.com/forkbomb-666/chatoveruart
SPI
Serial Peripheral Interface

➔ It is an interface bus commonly used to send data between


microcontrollers and small peripherals such as shift registers, sensors, and
SD cards
➔ It uses separate clock and data lines, along with a select line to choose the
device you wish to talk to
➔ It offers duplex synchronous communication
Connections

How SPI works


Single Master Single Slave
Abbreviations

➔ SCLK: Serial Clock

➔ MOSI: Master Output Slave Input

➔ MISO: Master Input Slave Output

➔ SSn: Slave select line(s) where n = 1, 2, 3, ...

Single Master Multi Slave


1. Master outputs the clock signal
Communication Steps

2. The master switches the SS/CS pin to a low voltage


state, which activates the slave:

How SPI works


Abbreviations 3. The master sends the data one bit at a time to the
slave along the MOSI line. The slave reads the bits as they
are received
➔ SCLK: Serial Clock

➔ MOSI: Master Output Slave Input

➔ MISO: Master Input Slave Output


4. If a response is needed, the slave returns data one bit
➔ SSn: Slave select line(s) where n = 1, 2, 3, ... at a time to the master along the MISO line. The master
reads the bits as they are received
Advantages of Disadvantages of
SPI SPI
➔ Faster than UART ➔ Requires more signal lines than
other communication methods
➔ Cheap, as the receiving hardware
➔ The master must control all
can be a simple shift register
communications (slaves can't talk
➔ Supports multiple slaves directly to each other)
➔ It usually requires separate SS
lines to each slave, which can be
problematic if numerous slaves
are needed.
I2C
Inter - Integrated Circuit Bus
➔ A Small Area Network connecting ICs and other electronic systems
➔ Mainly used in EEPROM,Microcontroller,Interfaced chips
➔ Includes electrical and timing specifications and an associated bus protocol
➔ Two wire serial data & control bus implemented with the serial data (SDA) and
clock (SCL) lines
➔ Unique start and stop condition
➔ Bi-directional data transfer
Connections

How I2C works


Abbreviations Bit Pattern
➔ μC: MicroController
➔ ADC: Analog to Digital converter(sample device) ➔ Start Condition: 1st bit, falling edge triggering
➔ DAC: Digital to Analog converter(sample device) ➔ Address Bits + R/W: Next 7 + 1 bits, carries
➔ SDA: Serial Data Line address of slave with the Read / Write Bit
➔ SCL: Serial Clock Line ➔ ACK / NACK: Acknowledge/ Not-Acknowledge
bit
➔ Data Bits: Next 8 bits, used for data
➔ Stop Condition: Last bit, rising edge triggering
Advantages of Disadvantages of
I2C I2C
➔ Uses two wires ➔ Slower transfer rate than SPI

➔ Supports multi master multi slave ➔ Data frame size is limited to 8 bits
system
➔ More complicated than SPI
➔ Less complicated than UART
➔ Full-duplex not supported, can
➔ Can connect upto 2 ^ 7 - 1 = 127 only communicate in half-duplex
devices from a single master mode
USB
Universal Serial Bus

➔ It is a plug and play interface that allows a computer to communicate with


peripheral and other devices.
➔ Can connect anything from keyboards and mice, to music players and flash
drives
➔ USB may also be used to send power to certain devices, such as
smartphones and tablets, as well as charge their batteries
➔ Connect up to 127 devices from a single root hub
Root Hub Pyramid

The USB
Architecture
USB Root Hub

➔ USB uses 7 bit addressing for I/O

➔ Root Hub is the main controller device with


address 0

➔ Root Hub assigns addresses to I/O devices

➔ This process is known as enumeration.


Data transaction types

➔ Control: Used by the host to send commands or


query parameters. Packet lengths: 8 bytes for Low
The USB speed, 8-64 bytes for Full, and 64 bytes for High
Speed devices.

Architecture ➔ Interrupt: This is often used by devices sending


small amounts of data, e.g. mice or keyboards.

Packet Transactions ➔ Bulk: This USB protocol message is used by


devices like printers for which much larger amounts
of data are required. The maximum length is
64-byte for full speed Devices or 512 bytes for high
speed ones. The data integrity is verified using
cyclic redundancy checking, CRC and an
acknowledgement is sent.
➔ Isochronous: It is used to stream real time data
and is used for applications like live audio channels,
etc. Packet sizes can be up to 1024 bytes.
USB connectors
Other Variants are:
USB Speeds
By version
References:
➔ Image Credits:
circuitbasics.com, wikipedia.org, linustechtips.com
➔ Knowledge Credits:
wikipedia.org, sparkfun.com, mikroe.com
➔ Software Credits:
Google Slides, arduino.cc, github.com
Thank You!

You might also like