1
Getting Started: SPI © Date:
SPI
™
SPI
SPI
™
Overview and Use of the
PICmicro Serial Peripheral
Interface
Overview and Use of the
PICmicro Serial Peripheral
Interface
In this presentation, we will look at what the Serial Peripheral Interface, otherwise
known as the SPI, is, and how it is used to communicate data to and from the
PICmicro microcontroller.
SPI is frequently used when few I/O lines are available, but communication between
two or more devices must be fast and easy to implement.
2
Getting Started: SPI © Date:
SPI
SPI
SPI
l Covered Topics:
l Overview of SPI
l Using SPI on the PICmicro
®
MCU
l Example: A code walk-though for an SPI
Master and Slave
l Finding More Information
l Covered Topics:
l Overview of SPI
l Using SPI on the PICmicro
®
MCU
l Example: A code walk-though for an SPI
Master and Slave
l Finding More Information
In this presentation, we will discuss the following topics:
We will first cover an Overview of SPI.
This section of the tutorial will introduce you to SPI and its concepts.
Next, we will examine the use of SPI on the PICmicro MCU.
The details of how SPI is implemented on a PICmicro device will be examined.
Then, a Code Walkthrough will be given.
The walkthough will explore code for both an SPI Master and SPI Slave. The
example will have the Master generate data for sending to the slave.
Finally, there will be a few resources given at the end of the presentation. These
resources will allow you to explore in more detail the SPI interface.
3
Getting Started: SPI © Date:
SPI - Overview
SPI
SPI
-
-
Overview
Overview
l SPI stands for Serial Peripheral Interface
l Used for moving data simply and quickly
from one device to another
l Serial Interface
l Synchronous
l Master-Slave
l Data Exchange
l SPI stands for Serial Peripheral Interface
l Used for moving data simply and quickly
from one device to another
l Serial Interface
l Synchronous
l Master-Slave
l Data Exchange
SPI stands for Serial Peripheral Interface.
SPI is a synchronous protocol that allows a master device to initiate communication
with a slave device. Data is exchanged between these devices. We will look at this
more in detail as we progress though this tutorial.
SPI is implemented in the PICmicro MCU by a hardware module called the
Synchronous Serial Port or the Master Synchronous Serial Port. This module is
built into many different PICmicro devices. It allows serial communication between
two or more devices at a high speed and is reasonably easy to implement.
4
Getting Started: SPI © Date:
SPI - Overview
SPI
SPI
-
-
Overview
Overview
l SPI is a Synchronous protocol
l The data is clocked along with a clock signal
(SCK)
l The clock signal controls when data is changed
and when it should be read
l Since SPI is synchronous, the clock rate can
vary, unlike RS-232 style communications
l SPI is a Synchronous protocol
l The data is clocked along with a clock signal
(SCK)
l The clock signal controls when data is changed
and when it should be read
l Since SPI is synchronous, the clock rate can
vary, unlike RS-232 style communications
SPI is a Synchronous protocol.
The clock signal is provided by the master to provide synchronization. The clock
signal controls when data can change and when it is valid for reading.
Since SPI is synchronous, it has a clock pulse along with the data. RS-232 and other
asynchronous protocols do not use a clock pulse, but the data must be timed very
accurately.
Since SPI has a clock signal, the clock can vary without disrupting the data. The
data rate will simply change along with the changes in the clock rate. This makes
SPI ideal when the microcontroller is being clocked imprecisely, such as by a RC
oscillator.
5
Getting Started: SPI © Date:
SPI - Overview
SPI
SPI
-
-
Overview
Overview
l SPI is a Master-Slave protocol
l The Master device controls the clock (SCK)
l No data is transferred unless a clock signal is
present
l All slaves are controlled by the master clock
l The slave devices may not manipulate the
clock
l SPI is a Master-Slave protocol
l The Master device controls the clock (SCK)
l No data is transferred unless a clock signal is
present
l All slaves are controlled by the master clock
l The slave devices may not manipulate the
clock
SPI is a Master-Slave protocol.
Only the master device can control the clock line, SCK.
No data will be transferred unless the clock is manipulated.
All slaves are controlled by the clock which is manipulated by the master device.
The slaves may not manipulate the clock. The SSP configuration registers will
control how a device will respond to the clock input.