SlideShare uma empresa Scribd logo
1 de 20
SPI Bus Protocol
20th April 2018
Sudhanshu Janwadkar, SVNIT
Introduction
• The Serial Peripheral Interface bus (SPI) is
 synchronous
 serial communication interface specification
 used for short distance communication
• The interface was developed by Motorola in 1980s
• SPI devices communicate in full duplex mode using
a master-slave architecture with a single master.
 The master device originates the frame for reading
and writing.
 Multiple slave devices are supported through
selection with individual slave select (SS) lines.
The trouble with asynchronous
protocols
• The common serial port, such as UART, is called
“asynchronous” because there is no control over
when data is sent or any guarantee that both sides
are running at precisely the same rate.
• There can be an issue when two systems with
slightly different clocks try to communicate with
each other.
• To mitigate this issue, asynchronous serial
connections add extra start and stop bits to each
byte, so as to help the receiver sync up to data as it
arrives.
• Both sides must also agree on the same baud rate
in advance.
The trouble with asynchronous
protocols
• Asynchronous serial works just fine, but
 has a lot of overhead in both the extra start and
stop bits sent with every byte
 the complex hardware required to send and receive
data
 if both sides aren’t set to the same speed, the
received data will be garbage. This is because the
receiver is sampling the bits at very specific times If
the receiver is looking at the wrong times, it will see
the wrong bits.
How is ‘synchronous’ beneficial?
• A “synchronous” data bus uses separate lines for
data and clock that keeps both sides in perfect
sync.
• The clock is an oscillating signal that tells the
receiver exactly when to sample the bits on the
data line.
 This could be the rising (low to high) or falling (high
to low) edge of the clock signal; the datasheet will
specify which one to use.
• When the receiver detects that edge, it will
immediately look at the data line to read the next bit
• Because the clock is sent along with the data,
specifying the speed isn’t important, although
devices will have a top speed at which they can
operate
The SPI Protocol - basics
• The SPI bus can operate with a single master
device and with one or more slave devices.
• One unique feature of SPI is that data can be
transferred without interruption.
• Any number of bits can be sent or received in
a continuous stream.
 With I2C and UART, data is sent in packets, limited
to a specific number of bits.
 Start and stop conditions define the beginning and
end of each packet, so the data is interrupted
during transmission.
• Devices communicating via SPI are in a master-
slave relationship.
• In SPI, only one side generates the clock signal
 The side that generates the clock is called the
“master”, and the other side is called the “slave”.
• The master is the controlling device (usually a
microcontroller), while the slave (usually a sensor,
display, or memory chip) takes instruction from the
master.
• There is always only one master but there can be
multiple slaves.
The SPI Protocol - basics
The SPI Interface
The SPI bus specifies four logic signals:
 SCLK: Serial Clock (output from master).
 MOSI: Master Output Slave Input (data output from
master).
 MISO: Master Input Slave Output, or Master In Slave
Out (data output from slave).
 SS: Slave Select (often active low, output from
master).
The SPI Interface
Serial Clock (SCLK)
• SPI is a synchronous communication protocol.
• The clock signal synchronizes the output of data
bits from the master with the sampling of bits by the
slave.
• One bit of data is transferred in each clock cycle,
so the speed of data transfer is determined by the
frequency of the clock signal.
• SPI communication is always initiated by the
master since the master configures and generates
the clock signal.
The SPI Interface
Slave Select
• The master can choose which slave it wants to
communicate to by setting the slave’s CS/SS line to
a low voltage level.
• In the idle, non-transmitting state, the slave select
line is kept at a high voltage level.
 Multiple CS/SS pins may be available on the
master, which allows for multiple slaves to be wired
in parallel.
 If only one CS/SS pin is present, multiple slaves
can be wired to the master by daisy-chaining
The SPI Interface
Multiple Slaves
 Multiple CS/SS pins
are available on the
master
Only one CS/SS pin is
present, multiple slaves
are wired to the master by
daisy-chaining
The Protocol
1. To begin communication, the bus master configures
the clock, using a frequency supported by the slave
device, typically up to a few MHz.
2. The master then selects the slave device with a logic
level 0 on the select line.
 If a waiting period is required, such as for an analog-
to-digital conversion, the master must wait for at
least that period of time before issuing clock cycles.
3. During each SPI clock cycle, a full duplex data
transmission occurs.
 The master sends a bit on the MOSI line and the
slave reads it, while the slave sends a bit on the
MISO line and the master reads it.
The Protocol (summary)
1. The master outputs the clock signal
2. The master switches the SS/CS pin to a low voltage
state, which activates the slave:
The Protocol (summary)
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
4. If a response is needed, the slave returns data one
bit at a time to the master along the MISO line. The
master reads the bits as they are received
Data Transmission in SPI
• Transmissions normally involve two shift registers
of some given word size ( may be 8eight bits), one
in the master and one in the slave
• They are connected in a virtual ring topology.
• Data is usually shifted out with the most-significant
bit first. On the clock edge, both master and slave
shift out a bit and output it on the transmission line
to the counterpart.
Data Transmission in SPI
• On the next clock edge, at each receiver the bit is
sampled from the transmission line and set as a
new least-significant bit of the shift register.
• After the register bits have been shifted out and in,
the master and slave have exchanged register
values.
• If more data needs to be exchanged, the shift
registers are reloaded and the process repeats.
• Transmission may continue for any number of clock
cycles.
• When complete, the master stops toggling the
clock signal, and typically deselects the slave.
Advantages of SPI
• Full duplex
• Push-pull drivers (as opposed to open drain)
provide good signal integrity and high speed
• Higher throughput than I²C or SMBus.
• Not limited to any maximum clock speed, enabling
potentially high speed
• Not limited to 8-bit words
• Slaves use the master's clock and do not need
precision oscillators
• Slaves do not need a unique address — unlike I²C
or GPIB or SCSI
Limitations of SPI
• Requires more pins on IC packages than I²C
• No hardware flow control by the slave (but the
master can delay the next clock edge to slow the
transfer rate)
• No hardware slave acknowledgment (the master
could be transmitting to nowhere and not know it)
• Typically supports only one master device
(depends on device's hardware implementation)
• No error-checking protocol is defined
Applications of SPI
SPI is used to talk to a variety of peripherals, such as
• Sensors: temperature, pressure, ADC,
touchscreens, video game controllers
• Control devices: audio codecs, digital
potentiometers, DAC
• Memory: flash and EEPROM
• Real-time clocks
• LCD, sometimes even for managing image data
• Any MMC or SD card
Review Questions
1. Compare and contrast UART, I2C and SPI, citing
the features, advantages and disadvantages of
each.
2. What are the demerits of asynchronous
communication protocols? How are they overcome
in SPI?
3. List out the Interface signals used in SPI protocol
and brief out their significance.
4. List the set of operations involved in completing a
serial communication using SPI protocol. Draw the
hardware interface, in support.
5. List out the advantages and limitations of SPI
protocol. Also, list some of the applications.

Mais conteúdo relacionado

Mais procurados

I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
Varun Mahajan
 
Spi master core verification
Spi master core verificationSpi master core verification
Spi master core verification
Maulik Suthar
 
Challenges in Using UVM at SoC Level
Challenges in Using UVM at SoC LevelChallenges in Using UVM at SoC Level
Challenges in Using UVM at SoC Level
DVClub
 
Session 8,9 PCI Express
Session 8,9 PCI ExpressSession 8,9 PCI Express
Session 8,9 PCI Express
Subhash Iyer
 
Jtag presentation
Jtag presentationJtag presentation
Jtag presentation
klinetik
 

Mais procurados (20)

I2C
I2CI2C
I2C
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
 
I2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolI2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication Protocol
 
Serial peripheral interface
Serial peripheral interfaceSerial peripheral interface
Serial peripheral interface
 
Serial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System ProtocolSerial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System Protocol
 
I2C BUS PROTOCOL
I2C BUS PROTOCOLI2C BUS PROTOCOL
I2C BUS PROTOCOL
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
Advance Peripheral Bus
Advance Peripheral Bus Advance Peripheral Bus
Advance Peripheral Bus
 
axi protocol
axi protocolaxi protocol
axi protocol
 
UART
UARTUART
UART
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
Communication Protocols (UART, SPI,I2C)
Communication Protocols (UART, SPI,I2C)Communication Protocols (UART, SPI,I2C)
Communication Protocols (UART, SPI,I2C)
 
APB protocol v1.0
APB protocol v1.0APB protocol v1.0
APB protocol v1.0
 
Spi master core verification
Spi master core verificationSpi master core verification
Spi master core verification
 
Introduction about APB Protocol
Introduction about APB ProtocolIntroduction about APB Protocol
Introduction about APB Protocol
 
Challenges in Using UVM at SoC Level
Challenges in Using UVM at SoC LevelChallenges in Using UVM at SoC Level
Challenges in Using UVM at SoC Level
 
I2 c bus
I2 c busI2 c bus
I2 c bus
 
Uart
UartUart
Uart
 
Session 8,9 PCI Express
Session 8,9 PCI ExpressSession 8,9 PCI Express
Session 8,9 PCI Express
 
Jtag presentation
Jtag presentationJtag presentation
Jtag presentation
 

Semelhante a SPI Bus Protocol

Input Output Operations
Input Output OperationsInput Output Operations
Input Output Operations
kdisthere
 

Semelhante a SPI Bus Protocol (20)

Deepu Kumar Shah.pptx
Deepu Kumar Shah.pptxDeepu Kumar Shah.pptx
Deepu Kumar Shah.pptx
 
Serial Busses.pptx
Serial Busses.pptxSerial Busses.pptx
Serial Busses.pptx
 
communication interfaces-Embedded real time systems
communication interfaces-Embedded real time systemscommunication interfaces-Embedded real time systems
communication interfaces-Embedded real time systems
 
serial_busses_i2c.pptx
serial_busses_i2c.pptxserial_busses_i2c.pptx
serial_busses_i2c.pptx
 
UNI T 6- SPI_I2C_Lecture8.pptx
UNI                    T 6- SPI_I2C_Lecture8.pptxUNI                    T 6- SPI_I2C_Lecture8.pptx
UNI T 6- SPI_I2C_Lecture8.pptx
 
Raspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication ProtocolsRaspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication Protocols
 
lecture_I2C_SPI.pptx
lecture_I2C_SPI.pptxlecture_I2C_SPI.pptx
lecture_I2C_SPI.pptx
 
serial.ppt
serial.pptserial.ppt
serial.ppt
 
serial.ppt
serial.pptserial.ppt
serial.ppt
 
Embedded networking
Embedded networkingEmbedded networking
Embedded networking
 
USART
USARTUSART
USART
 
Lec 5
Lec 5Lec 5
Lec 5
 
Introduction to embedded systems
Introduction to embedded systemsIntroduction to embedded systems
Introduction to embedded systems
 
SOC Peripheral Components & SOC Tools
SOC Peripheral Components & SOC ToolsSOC Peripheral Components & SOC Tools
SOC Peripheral Components & SOC Tools
 
Spi in arm7(lpc2148)
Spi in arm7(lpc2148)Spi in arm7(lpc2148)
Spi in arm7(lpc2148)
 
SPI AND UART COMMUNICATION PROTOCOLS
SPI AND UART COMMUNICATION PROTOCOLSSPI AND UART COMMUNICATION PROTOCOLS
SPI AND UART COMMUNICATION PROTOCOLS
 
Peripherals and interfacing
Peripherals  and interfacingPeripherals  and interfacing
Peripherals and interfacing
 
Embedded systems and robotics by scmandota
Embedded systems and robotics by scmandotaEmbedded systems and robotics by scmandota
Embedded systems and robotics by scmandota
 
Master synchronous serial port (mssp)
Master synchronous serial port (mssp)Master synchronous serial port (mssp)
Master synchronous serial port (mssp)
 
Input Output Operations
Input Output OperationsInput Output Operations
Input Output Operations
 

Mais de Sudhanshu Janwadkar

Design and Implementation of a GPS based Personal Tracking System
Design and Implementation of a GPS based Personal Tracking SystemDesign and Implementation of a GPS based Personal Tracking System
Design and Implementation of a GPS based Personal Tracking System
Sudhanshu Janwadkar
 

Mais de Sudhanshu Janwadkar (20)

DSP Processors versus ASICs
DSP Processors versus ASICsDSP Processors versus ASICs
DSP Processors versus ASICs
 
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 Microcontroller
 
ASIC design Flow (Digital Design)
ASIC design Flow (Digital Design)ASIC design Flow (Digital Design)
ASIC design Flow (Digital Design)
 
Fpga architectures and applications
Fpga architectures and applicationsFpga architectures and applications
Fpga architectures and applications
 
LCD Interacing with 8051
LCD Interacing with 8051LCD Interacing with 8051
LCD Interacing with 8051
 
Interrupts in 8051
Interrupts in 8051Interrupts in 8051
Interrupts in 8051
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
Introduction to 8051 Timer/Counter
Introduction to 8051 Timer/CounterIntroduction to 8051 Timer/Counter
Introduction to 8051 Timer/Counter
 
Intel 8051 Programming in C
Intel 8051 Programming in CIntel 8051 Programming in C
Intel 8051 Programming in C
 
Hardware View of Intel 8051
Hardware View of Intel 8051Hardware View of Intel 8051
Hardware View of Intel 8051
 
Architecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 MicrocontrollerArchitecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 Microcontroller
 
Introduction to Embedded Systems
Introduction to Embedded SystemsIntroduction to Embedded Systems
Introduction to Embedded Systems
 
CMOS Logic
CMOS LogicCMOS Logic
CMOS Logic
 
Interconnects in Reconfigurable Architectures
Interconnects in Reconfigurable ArchitecturesInterconnects in Reconfigurable Architectures
Interconnects in Reconfigurable Architectures
 
Introduction to FPGAs
Introduction to FPGAsIntroduction to FPGAs
Introduction to FPGAs
 
Design and Implementation of a GPS based Personal Tracking System
Design and Implementation of a GPS based Personal Tracking SystemDesign and Implementation of a GPS based Personal Tracking System
Design and Implementation of a GPS based Personal Tracking System
 
Embedded Logic Flip-Flops: A Conceptual Review
Embedded Logic Flip-Flops: A Conceptual ReviewEmbedded Logic Flip-Flops: A Conceptual Review
Embedded Logic Flip-Flops: A Conceptual Review
 
Pass Transistor Logic
Pass Transistor LogicPass Transistor Logic
Pass Transistor Logic
 
Memory and Processor Testing
Memory and Processor TestingMemory and Processor Testing
Memory and Processor Testing
 
Pass Transistor Logic
Pass Transistor LogicPass Transistor Logic
Pass Transistor Logic
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Último (20)

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 

SPI Bus Protocol

  • 1. SPI Bus Protocol 20th April 2018 Sudhanshu Janwadkar, SVNIT
  • 2. Introduction • The Serial Peripheral Interface bus (SPI) is  synchronous  serial communication interface specification  used for short distance communication • The interface was developed by Motorola in 1980s • SPI devices communicate in full duplex mode using a master-slave architecture with a single master.  The master device originates the frame for reading and writing.  Multiple slave devices are supported through selection with individual slave select (SS) lines.
  • 3. The trouble with asynchronous protocols • The common serial port, such as UART, is called “asynchronous” because there is no control over when data is sent or any guarantee that both sides are running at precisely the same rate. • There can be an issue when two systems with slightly different clocks try to communicate with each other. • To mitigate this issue, asynchronous serial connections add extra start and stop bits to each byte, so as to help the receiver sync up to data as it arrives. • Both sides must also agree on the same baud rate in advance.
  • 4. The trouble with asynchronous protocols • Asynchronous serial works just fine, but  has a lot of overhead in both the extra start and stop bits sent with every byte  the complex hardware required to send and receive data  if both sides aren’t set to the same speed, the received data will be garbage. This is because the receiver is sampling the bits at very specific times If the receiver is looking at the wrong times, it will see the wrong bits.
  • 5. How is ‘synchronous’ beneficial? • A “synchronous” data bus uses separate lines for data and clock that keeps both sides in perfect sync. • The clock is an oscillating signal that tells the receiver exactly when to sample the bits on the data line.  This could be the rising (low to high) or falling (high to low) edge of the clock signal; the datasheet will specify which one to use. • When the receiver detects that edge, it will immediately look at the data line to read the next bit • Because the clock is sent along with the data, specifying the speed isn’t important, although devices will have a top speed at which they can operate
  • 6. The SPI Protocol - basics • The SPI bus can operate with a single master device and with one or more slave devices. • One unique feature of SPI is that data can be transferred without interruption. • Any number of bits can be sent or received in a continuous stream.  With I2C and UART, data is sent in packets, limited to a specific number of bits.  Start and stop conditions define the beginning and end of each packet, so the data is interrupted during transmission.
  • 7. • Devices communicating via SPI are in a master- slave relationship. • In SPI, only one side generates the clock signal  The side that generates the clock is called the “master”, and the other side is called the “slave”. • The master is the controlling device (usually a microcontroller), while the slave (usually a sensor, display, or memory chip) takes instruction from the master. • There is always only one master but there can be multiple slaves. The SPI Protocol - basics
  • 8. The SPI Interface The SPI bus specifies four logic signals:  SCLK: Serial Clock (output from master).  MOSI: Master Output Slave Input (data output from master).  MISO: Master Input Slave Output, or Master In Slave Out (data output from slave).  SS: Slave Select (often active low, output from master).
  • 9. The SPI Interface Serial Clock (SCLK) • SPI is a synchronous communication protocol. • The clock signal synchronizes the output of data bits from the master with the sampling of bits by the slave. • One bit of data is transferred in each clock cycle, so the speed of data transfer is determined by the frequency of the clock signal. • SPI communication is always initiated by the master since the master configures and generates the clock signal.
  • 10. The SPI Interface Slave Select • The master can choose which slave it wants to communicate to by setting the slave’s CS/SS line to a low voltage level. • In the idle, non-transmitting state, the slave select line is kept at a high voltage level.  Multiple CS/SS pins may be available on the master, which allows for multiple slaves to be wired in parallel.  If only one CS/SS pin is present, multiple slaves can be wired to the master by daisy-chaining
  • 11. The SPI Interface Multiple Slaves  Multiple CS/SS pins are available on the master Only one CS/SS pin is present, multiple slaves are wired to the master by daisy-chaining
  • 12. The Protocol 1. To begin communication, the bus master configures the clock, using a frequency supported by the slave device, typically up to a few MHz. 2. The master then selects the slave device with a logic level 0 on the select line.  If a waiting period is required, such as for an analog- to-digital conversion, the master must wait for at least that period of time before issuing clock cycles. 3. During each SPI clock cycle, a full duplex data transmission occurs.  The master sends a bit on the MOSI line and the slave reads it, while the slave sends a bit on the MISO line and the master reads it.
  • 13. The Protocol (summary) 1. The master outputs the clock signal 2. The master switches the SS/CS pin to a low voltage state, which activates the slave:
  • 14. The Protocol (summary) 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 4. If a response is needed, the slave returns data one bit at a time to the master along the MISO line. The master reads the bits as they are received
  • 15. Data Transmission in SPI • Transmissions normally involve two shift registers of some given word size ( may be 8eight bits), one in the master and one in the slave • They are connected in a virtual ring topology. • Data is usually shifted out with the most-significant bit first. On the clock edge, both master and slave shift out a bit and output it on the transmission line to the counterpart.
  • 16. Data Transmission in SPI • On the next clock edge, at each receiver the bit is sampled from the transmission line and set as a new least-significant bit of the shift register. • After the register bits have been shifted out and in, the master and slave have exchanged register values. • If more data needs to be exchanged, the shift registers are reloaded and the process repeats. • Transmission may continue for any number of clock cycles. • When complete, the master stops toggling the clock signal, and typically deselects the slave.
  • 17. Advantages of SPI • Full duplex • Push-pull drivers (as opposed to open drain) provide good signal integrity and high speed • Higher throughput than I²C or SMBus. • Not limited to any maximum clock speed, enabling potentially high speed • Not limited to 8-bit words • Slaves use the master's clock and do not need precision oscillators • Slaves do not need a unique address — unlike I²C or GPIB or SCSI
  • 18. Limitations of SPI • Requires more pins on IC packages than I²C • No hardware flow control by the slave (but the master can delay the next clock edge to slow the transfer rate) • No hardware slave acknowledgment (the master could be transmitting to nowhere and not know it) • Typically supports only one master device (depends on device's hardware implementation) • No error-checking protocol is defined
  • 19. Applications of SPI SPI is used to talk to a variety of peripherals, such as • Sensors: temperature, pressure, ADC, touchscreens, video game controllers • Control devices: audio codecs, digital potentiometers, DAC • Memory: flash and EEPROM • Real-time clocks • LCD, sometimes even for managing image data • Any MMC or SD card
  • 20. Review Questions 1. Compare and contrast UART, I2C and SPI, citing the features, advantages and disadvantages of each. 2. What are the demerits of asynchronous communication protocols? How are they overcome in SPI? 3. List out the Interface signals used in SPI protocol and brief out their significance. 4. List the set of operations involved in completing a serial communication using SPI protocol. Draw the hardware interface, in support. 5. List out the advantages and limitations of SPI protocol. Also, list some of the applications.