Sei sulla pagina 1di 16

Serial Communication, USART, SPI

and I2C
Serial Communications

 Outline
 Data Transmission Types
 Parallel vs Serial
 Synchronous vs Asynchronous
 USART
 SPI
 I2C

Wednesday, May 15, 2019 2


Data Transmission Types
 Full Duplex
 Communication is possible in both directions, but can transmit and
receive in the same time.

Wednesday, May 15, 2019 3


Parallel Communication

 The process of sending several bits as a whole, on a link


with several parallel channels.
 It requires a separate channel for each bit to be transmitted
 A parallel link use simpler hardware as there is no need for
a serializer/deserializer.
 Usually used for very short distances.

Wednesday, May 15, 2019 4


Serial Communication

 The process of sending data bit by bit sequentially, over a


single channel between sender and receiver.
 For correct data transmission, there has to be some form of
synchronization between transmitter and receiver.
 Cost of cable and synchronization difficulties make parallel
communication impractical.

Wednesday, May 15, 2019 5


Basic of Serial Communication

 To convert parallel data from a computer bus to serial bits, or to


receive serial data we need to use two kinds of shift registers:
Transmitter:
 A parallel-in, serial-out

shift register.

Receiver:
 A serial-in, parallel-out

shift register.

 For each clock pulse,


the data is shifted in or out.

Wednesday, May 15, 2019 6


Synchronous vs Asynchronous

 Synchronous Transmission

 Asynchronous Transmission

Wednesday, May 15, 2019 7


USART (Universal Synchronous
Asynchronous Receiver Transmitter)
 The USART module is a full duplex, serial I/O communication
peripheral.
 It contains all shift registers, clock generators and data buffers
needed for
 It can work in synchronous mode, or in asynchronous mode.
 The USART uses two I/O pins to transmit and receive serial
data. Both transmission and reception can occur at the same
time i.e. ‘full duplex’ operation.

Wednesday, May 15, 2019 8


USART
 To send a byte, the application writes the byte to the transmit
buffer.
 The USART module is a full duplex, serial I/O communication
peripheral.
 In a similar way, the UART stores received bytes in a buffer.
 Then the UART can generate an interrupt to notify the
application or software can poll the port to find out if data has
arrived.

Wednesday, May 15, 2019 9


SPI (Serial Peripheral Interface)
 SPI
 SPI, or Serial to Peripheral Interface, is a very low power
four-wire serial communication interface designed for IC
controllers and peripherals to communicate with each
other.
 Two types of devices, masters and slaves.
 We’ll consider only one master, but multiple slaves
 Signals
 SCLK: Serial CLocK, set by Master
 MOSI: Master Out, Slave In
 MISO: Master In, Slave Out
 ~SS: Slave Selec

Wednesday, May 15, 2019 10


SPI (Serial Peripheral Interface)
 Pull slave select line low to select device.
 First bit of data gets put on MISO and MOSI
(so a byte goes both ways)
 Data gets shifted out (typically 8 bits, but
 Not necessarily)
 The data gets put on bus on falling edge of clock.
 The data gets read on the rising edge of clock

Wednesday, May 15, 2019 11


I2C (Inter‐Integrated Circuit)
 I2C
 As with SPI a master‐slave system.
 Also called a 2‐wire bus. It has only clock and data, with
pull‐up resistors (Rp in diagram).
 Lines can be pulled low by any device, and are high
when all devices release them.
 There are no “slave‐select” lines – instead the devices
have “addresses” that are sent as part of the
transmission protocol.
 Four max speeds (100 kbS (standard), 400 kbS (fast),1
MbS (fast plus), and 3.4 MbS (high‐speed)

Wednesday, May 15, 2019 12


I2C (Inter‐Integrated Circuit)
 I2C
 As with SPI a master‐slave system.

Wednesday, May 15, 2019 13


I2C (Inter‐Integrated Circuit)
 I2C write a single byte
1. All: allow SDA, SCL start high
2. Master: SDA low to signal start
3. Master: Send out SCL, and 7 bit address followed by 0(~W) on
SDA
4. Slave: Pull SDA low to signify ACKnowledge
5. Master: Send out 8 data bits on SDA
6. Slave: Ack
7. All: allow SDA to go high when SCL is high (stop)

Wednesday, May 15, 2019 14


I2C (Inter‐Integrated Circuit)
 For Read
3. Master: Address following by 1(R) on SDA
5. Master: Send out 8 data bits on SDA
6. Slave: Ack

Wednesday, May 15, 2019 15


UART, I2C and SPI

Wednesday, May 15, 2019 16

Potrebbero piacerti anche