0% found this document useful (0 votes)
367 views4 pages

SPI Communication

SPI (Serial Peripheral Interface) is a synchronous serial communication protocol used for short-distance communication. It uses a master-slave architecture and can have one master communicating with one or more slaves. SPI uses four wires for communication - MOSI, MISO, SCLK, and CS/SS. The master device controls the communication by selecting the slave device using the CS/SS line and generating the clock signal on SCLK.

Uploaded by

Krishanu Modak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
367 views4 pages

SPI Communication

SPI (Serial Peripheral Interface) is a synchronous serial communication protocol used for short-distance communication. It uses a master-slave architecture and can have one master communicating with one or more slaves. SPI uses four wires for communication - MOSI, MISO, SCLK, and CS/SS. The master device controls the communication by selecting the slave device using the CS/SS line and generating the clock signal on SCLK.

Uploaded by

Krishanu Modak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

SPI Communication

SPI stands for Serial Peripheral Interface works on Master-slave concept.It is a synchronous serial
communication used for short distance communication.

It is a full-duplex communication protocol as it has two separate lines for transmission(MOSI) and


reception(MISO).SPI communication could be possible with a single master and a single slave as well as a
single master with multiple slaves.

In multi-slave communication, Master will select a slave to establish communication through slave select (SS)
line or chip select line(CS) by pulling it down.

It is also known as 4 wire protocol as it has 4 wire interface.

1. MOSI (MTSR) – Master Out Slave In OR Master Transmit Slave Recieve


2. MISO (MRST) – Master In Slave Out OR Master Recieve Slave Transmit
3. SCLK (SCK)   – Serial clock
4. CS(SS)           – Chip select or Slave Select(Active low Pin)

The diagram shows the Interface and Direction between Master and Slave.

SPI COMMUNICATION CONCEPT


Following Steps should be followed in SPI Communication.

Master should select Slave device through Slave select line by making it low—-SS

Master device con gures the SPI peripheral clock supported by Slave also.——SCLK

Data availability on Data out(MOSI) and Data in(MISO) line controlled by the master generated Clock
Pulse(SCLK).

Master generated clock pulse polarity(CPOL) and phase(CPHA) decides the data drive on the data line. see the
below image.

CPOL: Decides the polarity of Clock.

CPHA: Determines the timing of the data bits relative to the clock pulse.
HARDWARE CONFIGURATION
For SPI Communication you need to con gure following peripheral in MCU.

1. Port Pins
2. MCU clock
3. SPI Peripheral Engine

Note: Here I am not Discussing DMA.

Port Pins: 

Direction and alternate function need to con gure for the Port Pins those are used by SPI module. Suppose
Following GPIO Pins are xed by the manufacturer for SPI communication as an alternate function. See the
following table –

MCU Clock:

We need to Con gure the MCU clock and peripheral Clock to x the SCLK frequency.

SPI Peripheral MODULE:


Serial Peripheral Module is Inbuilt peripheral to con gure following things:

1. SPI Hardware module (Some controllers have multiple SPI modules)


2. SPI channel use for Communication
3. SPI JOB and Sequence Con guration
SPI Hardware module :
Some microcontroller has multiple SPI modules. For Example, there are 5 SPI modules in In neon Tricore
microcontroller TC297X QSPI0, QSPI1, QSPI2…QPSI4.

We need to con gure one of them to work as a Master or Slave through the API as per the
Microcontroller Speci c User Manual.

SPI channel Con guration:


Here channel refers to a Slave select line. Every SPI module has multiple channels i.e multiple Slave select
lines i.e Master can communicate multiple slaves.

In below gure, three slave select lines(Channels) are present and each one is connected with different-2
slaves.

Master will take control of this slave select line and master can select or deselect the slave through SS line.

SPI JOB and Sequence Con guration:


Let’s take an example, suppose an MCU wants to save the data and Read that Data to/from Flash Memory. so
here MCU as Master and Flash memory as a slave will perform following Jobs-

JOB1: Save Data into Flash memory

JOB2: Read the Data from ash memory

JOB1: Save Data into Flash memory

To accomplish this job following Data shall be transferred through MOSI.

1. Write Command
2. Address
3. Data to write

slave select line must be low until above three data does not transfer completely.

let ,

1. write command=0x12
2. Address =0x00000000
3. Data ={0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}

JOB2: Save Data into Flash memory

To accomplish this job following Data shall be transferred through MOSI.

1. Read Command
2. Address

slave select line must be low until above three data does not transfer completely.

let ,

1. Read command=0x13
2. Address =0x00000000

You might also like