Serial Peripheral Interface: - Nidhi Panchal
Serial Peripheral Interface: - Nidhi Panchal
- Nidhi Panchal
Serial Peripheral Interface
What is it?
Basic SPI
Capabilities
Master-Slave Setup
Signal Function
Protocol Operation
Registers
Pros and Cons
Uses
What is it?
Always full-duplex
Communicates in both directions simultaneously
Transmitted (or received) data may not be meaningful
Multiple Mbps transmission speeds
0-50 MHz clock speeds not uncommon
Transfer data in 4 to 16 bit characters
Supports multiple slaves
Master-Slave Setup
• Single Slave
Multiple Slave Connection:
It can be set up with multiple slaves controlled by a single master. There are two ways to
connect multiple slaves to the master. If the master has multiple slave select pins, the
slaves can be wired in parallel like this:
If only one slave select pin is available, the slaves can be daisy-chained like this:
Each slave is cascaded so that the output
of one slave is the input of another.
When cascading, they are treated as
one slave and connecting
to the same chip select
SPI Signal Functions
- Master-Slave Interconnection
• SPI Registers
1) SPCR :
SPIE (Serial peripheral Interrupt Enable)
When this bit is set, the SPI system can generate an interrupt.
SPE (Serial Peripheral System Enable)
This bit enables SPI communication.
0 – System off
1 – System on
DORD (Data Ordered)
Bit determines which bytes in serial communication are to be sent first:
0 – MSB bit is sent first.
1 – LSB bit is sent first.
MSTR (Master Mode Select )
Bit determines whether the microcontroller is to operate as master or slave.
0 – Operate as slave.
1 – Operate as master.
CPOL (Clock Polarity)
Bit controls the SCK pin logic state when the SPI communication is not in progress:
0 – Pin SCK is cleared.
1 – Pin SCK is set.
CPHA (Clock Phase) This bit along with the CPOL bit controls relation between clock and
data in serial format.
SPR1,SPR0 (SPI Clock Rate Select)
When SPI system operates as master, these two bits determine baud rate.
2) SPSR (SPI Status Register)
Cons
Slave select/chip select makes multiple slaves more complex
No acknowledgement (can’t tell if clocking in garbage)
No inherent arbitration
No flow control (must know slave speed)
Uses
LCDs
Sensors
Radios
Lots of other chips
Microcontrollers
Almost all MCUs have SPI masters
Some have SPI slaves
Thank you