尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
Serial Peripheral Interface
By:- Rishu
Master Slave
SCLK
MOSI
MISO
SS
Index
 Introduction
 Overview
 Communication
 Advantages
 Disadvantages
 Applications
Introduction
 Communication Protocol Developed By Motorola
 Four Wire Protocol
 Serial Interface
 Master-Slave Approach
 Synchronous- Data clocked with Clock Signal
 Data Rate-10mbps
 Full Duplex Protocol
 Low power than I2C (no need of Pull ups)
 Supports Single master and multiple slaves
 No hardware slave acknowledgement
Overview
 SPI stands for Serial Peripheral Interface
 Used for moving data simply and quickly from one device to another
 Used to communicate across small distances
 Master-Slave(Multiple Slaves, Single Master)
 Serial Interface
 Synchronous
 Data Exchange
Continue…
 SPI is a Master-Slave protocol
 The Master device controls the clock (SCK)
 No data is transferred unless a clock signal is present
 All slaves are controlled by the master clock
 The slave devices may not manipulate the clock
 Master Set Slave Select low
 Master Generates Clock
 Shift registers shift in and out data
Master Slave
SCLK
MOSI
MISO
SS
Continue…
 Simple SPI Protocol Specifies 4 Signal Wires
 Master Out Slave In (MOSI)
 Master In Slave Out (MISO)
 Serial Clock (SCLK)
 Slave Select (SS)
 MOSI – Carries data out of Master to Slave
 MISO – Carries data from Slave to Master (Both signals happen for every transmission)
 SS – Unique line to select a slave
 SCLK – Master produced clock to synchronize data transfer MOSI
Master Slave
SCLK
MOSI
MISO
SS
Continue…
 SPI is a Synchronous protocol
 The data is clocked along with a clock signal(SCK)
 The clock signal controls when data is changed and when it should be read
 Since SPI is synchronous, the clock rate can vary, unlike RS-232 style communications
Continue…
 SPI is a Data Exchange protocol
 As data is being clocked out, new data is clocked in
 Data is exchanged - no device can just be a transmitter only or receiver only
 the master controls the exchange by manipulating the clock line (SCK)
 Often a signal controls when a device is accessed - this is the CS or SS signal
 CS or SS signal is known as “Chip Select” or “Slave Select” and is frequently an active-low signal.
 Data is only output during the rising or falling edge of SCK
 Data is latched during the opposite edge of SCK
 The opposite edge is used to ensure data is valid at the time of reading
Fig.1 : Two SPI Modules connected in a Master-Slave
Configuration
 Master shifts out data to Slave, and shift in data from Slave
Serial Peripheral Interface(SPI)
 Data is shifted out of the master's MOSI pin and in its MISO pin.
 Data transfer is initiated by simply writing data to the SPI data register.
 All data movement is coordinated by SCK.
 Slave select may or may not be used depending on interfacing device.
 To get input data only you send “junk” data to SPDR to start the clock.
Single Master and Single Slave
Master Slave
SCLK
MOSI
MISO
SS
 Master
• Initiates the Connection
• Controls SCLK and Data transfer
 Slave
• Transmits Data
• Receives Data
Single Master and Multiple independent Slave
Master
SCLK
MOSI
MISO
SS1
SS2
SCLK
MOSI
MISO
SS
SCLK
MOSI
MISO
SS
Master and multiple daisy-chained slaves
How Do They Communicate
 Communication Initiated by Master only
 Master Configures the clock – Frequency less than equal to maximum frequency Slave
Support
 Master Selects Slave – By Pulling chip select(SS) of particular Slave-peripheral to Low State
Data Transmission Mode
SPI Mode CPOL CPHA Shift SCK
Edge
Capture SCK
Edge
0 0 0 Falling Raising
1 0 1 Raising Falling
2 1 0 Raising Falling
3 1 1 Falling Raising
Table : SPI Mode Configuration
SPI Transfer format with CPHA = 0
SPI Transfer format with CPHA = 1
Steps for Master Mode
 Set SPCCR (Clock Counter Register) with appropriate clock frequency
 Set SPCR (Control Register) to desired settings
 Write the data into SPDR (Data Register) of SPI
 Monitor SPIF bit of SPCR register, until it sets to 1(SPIF = 1 means data transfer is complete ).
 Read SPSR (Status Register), this will clear SPIF bit
 Read SPDR (Data Register), reading data register will return data sent by the slave during last
transfer.
Steps for Slave Mode
 Clock will be decided by Master
 Set SPCR (Control Register) to desired settings
 Write dummy data into SPDR (Data Register), so that SPI control block will generate Clock.
 Monitor SPIF bit of SPCR register, until it sets to 1
 Read SPSR (Status Register), this will clear SPIF bit
 Read SPDR (Data Register), reading data register will return data sent by the slave during last
transfer.
SPI Clock Counter Register (SPCCR)
 The SPCCR is used to set data transfer rate (SPI Frequency) It is 8 bit register, and the value
entered in this register is used to calculate frequency
SPI data rate = (PCLK / SPCCR value)
The value entered must be even value, thus LSB must be 0.The value should be greater
than 8.So maximum frequency is 1.875 MHz(PCLK = 15MHz).
SPI Control Register (SPCR)
SPIE SPE LSBF MSTR CPOL CPHA SPR1 SPR0
Bit 7 6 5 4 3 2 1 0
Read/Write
Initial Value
R/W R/W R/W R/W R/W R/W R/W R/W
0 0 0 0 0 0 0 0
SPCR
SPI Control Register (SPCR)
Bit 0&1: SPR0& SPR1
SPI2X SPR1 SPR0 SCLK
0 0 0 fosc/4
0 0 1 fosc/16
0 1 0 fosc/64
0 1 1 fosc/128
1 0 0 fosc/2
1 0 1 fosc/8
1 1 0 fosc/32
1 1 1 fosc/64
In SPSR Clock Rate
SPI Control Register (SPCR)
Bit 2: CPHA
CPHA stands for Clock Phase Control, and plays an important role in deciding the
relation between sampling of data and clock pulse
CPHA = 0 ; data is sampled on first clock edge
CPHA = 1 ; data is sampled on the second rising edge
•The important thing to be considered here is CPHA should be 0 when LPC2148 is used
as a SPI Master.
•It is mentioned in the User Manual of LPC2148 that SSEL signal is inactive during the
data transfer when CPHA is 0, but when CPHA is 1 the SSEL signal becomes active and
immediately transforms itself into slave.
•This results into a Mode Fault and data transfer terminates.
•In this case MODF bit of Status Register will set to 1.
SPI Control Register (SPCR)
Bit 3 : CPOL
•CPOL stands for Clock Polarity Control
•The bit decides the polarity of SPI clock, when set to 1 clock is active low. In that case
first clock will start with negative going pulse
•when set to 0 the clock is active high meaning that the clock will start with positive
going edge
CPOL = 0
CPOL = 1
SPI Control Register (SPCR)
Bit 4 : MSTR
The bit is used to configure SPI block in Master/Slave Mode
MSTR = 0 Slave Mode
MSTR = 1 Master Mode
Bit 5 : DORD or LSBF
The bit decides the direction of bit transfer
LSBF = 0 MSB is transferred first
LSBF = 1 LSB is transferred first
SPI Control Register (SPCR)
Bit 6 : SPE
•The bit is used to enable SPI Interface
SPE = 0 disable SPI Interface
SPE = 1 enable SPI Interface
•It is an interrupt Enable bit,
SPIE = 0 Interrupt are disabled
SPIE = 1 Interrupts are enabled and will occur when SPI/ WCOL bit is set.
Bit 7 : SPIE
SPI Status Register (SPSR)
Bit 0 : SPI2X
Bit 6 : WCOL
•The bit is used to set double clock rate in master mode
SPI2X = 0 normal clock rate
SPI2X = 1 double clock rate
•The bit is used for write collision
WCOL is set if SPDR is written during a receive transfer
SPI Status Register (SPSR)
Bit 7 : SPIF
•The bit is used for interrupt flag
SPIF bit is set when serial transfer is complete.
SPIF WCOL - - - - - SPI2X SPSR
Bit 7 6 5 4 3 2 1 0
Read/Write
Initial Value
R R R R R R R R/W
0 0 0 0 0 0 0 0
SPI Data Register (SPDR)
 It is 16 bit register used in data transfer, the data length is selectable (8 –16bits).
 The data length can be configured by using bit 2 (BitEnable) and bits 11:8 of control register.
 There is no buffer between the data register and the internal shift register.
 A write to the data register goes directly into the internal shift register.
 Therefore, data should only be written to this register when a transmit is not currently in
progress. Otherwise a Collision Error may occur.
 Read data is buffered. When a transfer is complete, the receive data is transferred to a single
byte data buffer, where it is later read.
MSB - - - - - - LSB SPDR
Bit 7 6 5 4 3 2 1 0
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
X X X X X X X X
Advantages
 Full Duplex Communication
 Higher Throughput than I2C
 Not Limited to 8 bit words in case of bit transferring
 Arbitrary choice of message size, content and Purpose
 Low Power
 Fast and easy
 Fast for point-to-point connections
 Easily allows streaming/Constant data inflow
 No addressing/Simple to implement
 Everyone supports it
Disadvantages
 Requires more pins than I2C
 No hardware flow control
 No Slave Acknowledgement ability
 No inherent arbitration
 Multi Master Difficult to Implement
 SS makes multiple slaves very complicated
 Short Distance
SPI Peripherals
 Converters (ADC, DAC)
 Memories (EEPROM, RAM’s, Flash)
 Sensors (Temperature, Humidity, Pressure)
 Real Time Clocks
 Misc.- Potentiometers, LCD controllers, UART’s, USB controller, CAN controller, amplifiers
Some Important Facts
 A read or write of the SPI data register is required in order to clear the SPIF status
bit.
 The prime function of SPSR register is to indicate the completion of data transfer
between two devices. The remaining bits of SPSR register.
 When CPHA = 0, the SSEL signal will always go inactive between data transfers.
This is not guaranteed when CPHA = 1 (the signal can remain active).
Thank You !!!

More Related Content

What's hot

Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
Chirag Parikh
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
Sudhanshu Janwadkar
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
Dhaval Kaneria
 
I2C BUS PROTOCOL
I2C BUS PROTOCOLI2C BUS PROTOCOL
I2C BUS PROTOCOL
Kashyap Mandaliya
 
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
Ankur Soni
 
The I2C Interface
The I2C InterfaceThe I2C Interface
The I2C Interface
Corrado Santoro
 
I2C-SPI-UART Basics || Embedded System || Hariharan K
I2C-SPI-UART Basics || Embedded System || Hariharan KI2C-SPI-UART Basics || Embedded System || Hariharan K
I2C-SPI-UART Basics || Embedded System || Hariharan K
Hariharan Krishnan
 
Uart
UartUart
I2C introduction
I2C introductionI2C introduction
I2C introduction
SUNODH GARLAPATI
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
Anurag Tomar
 
I2 c protocol
I2 c protocolI2 c protocol
I2 c protocol
Azad Mishra
 
SPI.ppt
SPI.pptSPI.ppt
SPI.ppt
LingaReddyC
 
UART
UARTUART
I2 c bus
I2 c busI2 c bus
UART
UARTUART
Communication protocols
Communication protocolsCommunication protocols
Communication protocols
Pantech ProLabs India Pvt Ltd
 
SPI Protocol in LPC2148
SPI  Protocol in LPC2148SPI  Protocol in LPC2148
SPI Protocol in LPC2148
Dnyanesh P. Joshi
 
Spi in arm7(lpc2148)
Spi in arm7(lpc2148)Spi in arm7(lpc2148)
Spi in arm7(lpc2148)
Aarav Soni
 
Spi master core verification
Spi master core verificationSpi master core verification
Spi master core verification
Maulik Suthar
 
Axi
AxiAxi

What's hot (20)

Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
 
I2C BUS PROTOCOL
I2C BUS PROTOCOLI2C BUS PROTOCOL
I2C BUS PROTOCOL
 
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
 
The I2C Interface
The I2C InterfaceThe I2C Interface
The I2C Interface
 
I2C-SPI-UART Basics || Embedded System || Hariharan K
I2C-SPI-UART Basics || Embedded System || Hariharan KI2C-SPI-UART Basics || Embedded System || Hariharan K
I2C-SPI-UART Basics || Embedded System || Hariharan K
 
Uart
UartUart
Uart
 
I2C introduction
I2C introductionI2C introduction
I2C introduction
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
I2 c protocol
I2 c protocolI2 c protocol
I2 c protocol
 
SPI.ppt
SPI.pptSPI.ppt
SPI.ppt
 
UART
UARTUART
UART
 
I2 c bus
I2 c busI2 c bus
I2 c bus
 
UART
UARTUART
UART
 
Communication protocols
Communication protocolsCommunication protocols
Communication protocols
 
SPI Protocol in LPC2148
SPI  Protocol in LPC2148SPI  Protocol in LPC2148
SPI Protocol in LPC2148
 
Spi in arm7(lpc2148)
Spi in arm7(lpc2148)Spi in arm7(lpc2148)
Spi in arm7(lpc2148)
 
Spi master core verification
Spi master core verificationSpi master core verification
Spi master core verification
 
Axi
AxiAxi
Axi
 

Viewers also liked

Object-Oriented Design: Multiple inheritance (C++ and C#)
Object-Oriented Design: Multiple inheritance (C++ and C#)Object-Oriented Design: Multiple inheritance (C++ and C#)
Object-Oriented Design: Multiple inheritance (C++ and C#)
Adair Dingle
 
Arm developement
Arm developementArm developement
Arm developement
hirokiht
 
Compiler in System Programming/Code Optimization techniques in System Program...
Compiler in System Programming/Code Optimization techniques in System Program...Compiler in System Programming/Code Optimization techniques in System Program...
Compiler in System Programming/Code Optimization techniques in System Program...
Janki Shah
 
Arm processor
Arm processorArm processor
Arm processor
SHREEHARI WADAWADAGI
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
adil raja
 
I2C programming with C and Arduino
I2C programming with C and ArduinoI2C programming with C and Arduino
I2C programming with C and Arduino
sato262
 
Protols used in bluetooth
Protols used in bluetoothProtols used in bluetooth
Protols used in bluetooth
Sonali Parab
 
Introduction to Embedded System
Introduction to Embedded SystemIntroduction to Embedded System
Introduction to Embedded System
Emertxe Information Technologies Pvt Ltd
 
Embedded C
Embedded CEmbedded C
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
Ronak Chhajed
 
Embedded C - Optimization techniques
Embedded C - Optimization techniquesEmbedded C - Optimization techniques
Embedded C - Optimization techniques
Emertxe Information Technologies Pvt Ltd
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
Mohamed Abdallah
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
guest9f8315
 
Iot
IotIot

Viewers also liked (14)

Object-Oriented Design: Multiple inheritance (C++ and C#)
Object-Oriented Design: Multiple inheritance (C++ and C#)Object-Oriented Design: Multiple inheritance (C++ and C#)
Object-Oriented Design: Multiple inheritance (C++ and C#)
 
Arm developement
Arm developementArm developement
Arm developement
 
Compiler in System Programming/Code Optimization techniques in System Program...
Compiler in System Programming/Code Optimization techniques in System Program...Compiler in System Programming/Code Optimization techniques in System Program...
Compiler in System Programming/Code Optimization techniques in System Program...
 
Arm processor
Arm processorArm processor
Arm processor
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
 
I2C programming with C and Arduino
I2C programming with C and ArduinoI2C programming with C and Arduino
I2C programming with C and Arduino
 
Protols used in bluetooth
Protols used in bluetoothProtols used in bluetooth
Protols used in bluetooth
 
Introduction to Embedded System
Introduction to Embedded SystemIntroduction to Embedded System
Introduction to Embedded System
 
Embedded C
Embedded CEmbedded C
Embedded C
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
Embedded C - Optimization techniques
Embedded C - Optimization techniquesEmbedded C - Optimization techniques
Embedded C - Optimization techniques
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Iot
IotIot
Iot
 

Similar to Serial Peripheral Interface

Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)
IJERD Editor
 
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
naveen088888
 
I2 c and mpu6050 basics
I2 c and mpu6050 basicsI2 c and mpu6050 basics
I2 c and mpu6050 basics
ironstein1994
 
Serial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System ProtocolSerial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System Protocol
Aditya Porwal
 
Master synchronous serial port (mssp)
Master synchronous serial port (mssp)Master synchronous serial port (mssp)
Master synchronous serial port (mssp)
babak danyal
 
Introduction to embedded systems
Introduction to embedded systemsIntroduction to embedded systems
Introduction to embedded systems
Игорь Медведев
 
Assembler4
Assembler4Assembler4
Assembler4
Omar Sanchez
 
communication interfaces-Embedded real time systems
communication interfaces-Embedded real time systemscommunication interfaces-Embedded real time systems
communication interfaces-Embedded real time systems
Raghunath reddy
 
spi-180501092933-converted.pptx
spi-180501092933-converted.pptxspi-180501092933-converted.pptx
spi-180501092933-converted.pptx
sauryakumar3
 
10_2Starting with serial_II.ppt
10_2Starting with serial_II.ppt10_2Starting with serial_II.ppt
10_2Starting with serial_II.ppt
ABDULRHMANMohammad3
 
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDLDesigning of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Jay Baxi
 
Part-2: Mastering microcontroller with embedded driver development
Part-2: Mastering microcontroller with embedded driver developmentPart-2: Mastering microcontroller with embedded driver development
Part-2: Mastering microcontroller with embedded driver development
FastBit Embedded Brain Academy
 
LPC2148 SPI (Serial Peripheral Interface).pptx
LPC2148 SPI (Serial Peripheral Interface).pptxLPC2148 SPI (Serial Peripheral Interface).pptx
LPC2148 SPI (Serial Peripheral Interface).pptx
dhanashribiradar2
 
Spi (1)
Spi (1)Spi (1)
Spi (1)
sharmila B.S
 
Peripherals and interfacing
Peripherals  and interfacingPeripherals  and interfacing
Peripherals and interfacing
RAMPRAKASHT1
 
8051 serialp port
8051 serialp port8051 serialp port
8051 serialp port
Teju Kotti
 
I2C PRESENTATION.PPT
I2C PRESENTATION.PPTI2C PRESENTATION.PPT
I2C PRESENTATION.PPT
venkatesh405785
 
8051 SERIAL PORTS.pptx
8051 SERIAL PORTS.pptx8051 SERIAL PORTS.pptx
8051 SERIAL PORTS.pptx
maheswariM7
 
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
Mohamed Abdallah
 
Lpc2148 i2c
Lpc2148 i2cLpc2148 i2c
Lpc2148 i2c
anishgoel
 

Similar to Serial Peripheral Interface (20)

Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)
 
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
 
I2 c and mpu6050 basics
I2 c and mpu6050 basicsI2 c and mpu6050 basics
I2 c and mpu6050 basics
 
Serial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System ProtocolSerial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System Protocol
 
Master synchronous serial port (mssp)
Master synchronous serial port (mssp)Master synchronous serial port (mssp)
Master synchronous serial port (mssp)
 
Introduction to embedded systems
Introduction to embedded systemsIntroduction to embedded systems
Introduction to embedded systems
 
Assembler4
Assembler4Assembler4
Assembler4
 
communication interfaces-Embedded real time systems
communication interfaces-Embedded real time systemscommunication interfaces-Embedded real time systems
communication interfaces-Embedded real time systems
 
spi-180501092933-converted.pptx
spi-180501092933-converted.pptxspi-180501092933-converted.pptx
spi-180501092933-converted.pptx
 
10_2Starting with serial_II.ppt
10_2Starting with serial_II.ppt10_2Starting with serial_II.ppt
10_2Starting with serial_II.ppt
 
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDLDesigning of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDL
 
Part-2: Mastering microcontroller with embedded driver development
Part-2: Mastering microcontroller with embedded driver developmentPart-2: Mastering microcontroller with embedded driver development
Part-2: Mastering microcontroller with embedded driver development
 
LPC2148 SPI (Serial Peripheral Interface).pptx
LPC2148 SPI (Serial Peripheral Interface).pptxLPC2148 SPI (Serial Peripheral Interface).pptx
LPC2148 SPI (Serial Peripheral Interface).pptx
 
Spi (1)
Spi (1)Spi (1)
Spi (1)
 
Peripherals and interfacing
Peripherals  and interfacingPeripherals  and interfacing
Peripherals and interfacing
 
8051 serialp port
8051 serialp port8051 serialp port
8051 serialp port
 
I2C PRESENTATION.PPT
I2C PRESENTATION.PPTI2C PRESENTATION.PPT
I2C PRESENTATION.PPT
 
8051 SERIAL PORTS.pptx
8051 SERIAL PORTS.pptx8051 SERIAL PORTS.pptx
8051 SERIAL PORTS.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
 
Lpc2148 i2c
Lpc2148 i2cLpc2148 i2c
Lpc2148 i2c
 

Recently uploaded

Day 4 - Excel Automation and Data Manipulation
Day 4 - Excel Automation and Data ManipulationDay 4 - Excel Automation and Data Manipulation
Day 4 - Excel Automation and Data Manipulation
UiPathCommunity
 
ScyllaDB Real-Time Event Processing with CDC
ScyllaDB Real-Time Event Processing with CDCScyllaDB Real-Time Event Processing with CDC
ScyllaDB Real-Time Event Processing with CDC
ScyllaDB
 
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc
 
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdfLee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
leebarnesutopia
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
UiPathCommunity
 
Introduction to ThousandEyes AMER Webinar
Introduction  to ThousandEyes AMER WebinarIntroduction  to ThousandEyes AMER Webinar
Introduction to ThousandEyes AMER Webinar
ThousandEyes
 
CNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My Identity
CNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My IdentityCNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My Identity
CNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My Identity
Cynthia Thomas
 
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time MLMongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
ScyllaDB
 
Elasticity vs. State? Exploring Kafka Streams Cassandra State Store
Elasticity vs. State? Exploring Kafka Streams Cassandra State StoreElasticity vs. State? Exploring Kafka Streams Cassandra State Store
Elasticity vs. State? Exploring Kafka Streams Cassandra State Store
ScyllaDB
 
Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!
Ortus Solutions, Corp
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
ScyllaDB
 
So You've Lost Quorum: Lessons From Accidental Downtime
So You've Lost Quorum: Lessons From Accidental DowntimeSo You've Lost Quorum: Lessons From Accidental Downtime
So You've Lost Quorum: Lessons From Accidental Downtime
ScyllaDB
 
An All-Around Benchmark of the DBaaS Market
An All-Around Benchmark of the DBaaS MarketAn All-Around Benchmark of the DBaaS Market
An All-Around Benchmark of the DBaaS Market
ScyllaDB
 
Building a Semantic Layer of your Data Platform
Building a Semantic Layer of your Data PlatformBuilding a Semantic Layer of your Data Platform
Building a Semantic Layer of your Data Platform
Enterprise Knowledge
 
intra-mart Accel series 2024 Spring updates_En
intra-mart Accel series 2024 Spring updates_Enintra-mart Accel series 2024 Spring updates_En
intra-mart Accel series 2024 Spring updates_En
NTTDATA INTRAMART
 
DynamoDB to ScyllaDB: Technical Comparison and the Path to Success
DynamoDB to ScyllaDB: Technical Comparison and the Path to SuccessDynamoDB to ScyllaDB: Technical Comparison and the Path to Success
DynamoDB to ScyllaDB: Technical Comparison and the Path to Success
ScyllaDB
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
Discover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched ContentDiscover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched Content
ScyllaDB
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
From NCSA to the National Research Platform
From NCSA to the National Research PlatformFrom NCSA to the National Research Platform
From NCSA to the National Research Platform
Larry Smarr
 

Recently uploaded (20)

Day 4 - Excel Automation and Data Manipulation
Day 4 - Excel Automation and Data ManipulationDay 4 - Excel Automation and Data Manipulation
Day 4 - Excel Automation and Data Manipulation
 
ScyllaDB Real-Time Event Processing with CDC
ScyllaDB Real-Time Event Processing with CDCScyllaDB Real-Time Event Processing with CDC
ScyllaDB Real-Time Event Processing with CDC
 
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
 
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdfLee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
 
Introduction to ThousandEyes AMER Webinar
Introduction  to ThousandEyes AMER WebinarIntroduction  to ThousandEyes AMER Webinar
Introduction to ThousandEyes AMER Webinar
 
CNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My Identity
CNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My IdentityCNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My Identity
CNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My Identity
 
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time MLMongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
 
Elasticity vs. State? Exploring Kafka Streams Cassandra State Store
Elasticity vs. State? Exploring Kafka Streams Cassandra State StoreElasticity vs. State? Exploring Kafka Streams Cassandra State Store
Elasticity vs. State? Exploring Kafka Streams Cassandra State Store
 
Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
 
So You've Lost Quorum: Lessons From Accidental Downtime
So You've Lost Quorum: Lessons From Accidental DowntimeSo You've Lost Quorum: Lessons From Accidental Downtime
So You've Lost Quorum: Lessons From Accidental Downtime
 
An All-Around Benchmark of the DBaaS Market
An All-Around Benchmark of the DBaaS MarketAn All-Around Benchmark of the DBaaS Market
An All-Around Benchmark of the DBaaS Market
 
Building a Semantic Layer of your Data Platform
Building a Semantic Layer of your Data PlatformBuilding a Semantic Layer of your Data Platform
Building a Semantic Layer of your Data Platform
 
intra-mart Accel series 2024 Spring updates_En
intra-mart Accel series 2024 Spring updates_Enintra-mart Accel series 2024 Spring updates_En
intra-mart Accel series 2024 Spring updates_En
 
DynamoDB to ScyllaDB: Technical Comparison and the Path to Success
DynamoDB to ScyllaDB: Technical Comparison and the Path to SuccessDynamoDB to ScyllaDB: Technical Comparison and the Path to Success
DynamoDB to ScyllaDB: Technical Comparison and the Path to Success
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
Discover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched ContentDiscover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched Content
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
From NCSA to the National Research Platform
From NCSA to the National Research PlatformFrom NCSA to the National Research Platform
From NCSA to the National Research Platform
 

Serial Peripheral Interface

  • 1. Serial Peripheral Interface By:- Rishu Master Slave SCLK MOSI MISO SS
  • 2. Index  Introduction  Overview  Communication  Advantages  Disadvantages  Applications
  • 3. Introduction  Communication Protocol Developed By Motorola  Four Wire Protocol  Serial Interface  Master-Slave Approach  Synchronous- Data clocked with Clock Signal  Data Rate-10mbps  Full Duplex Protocol  Low power than I2C (no need of Pull ups)  Supports Single master and multiple slaves  No hardware slave acknowledgement
  • 4. Overview  SPI stands for Serial Peripheral Interface  Used for moving data simply and quickly from one device to another  Used to communicate across small distances  Master-Slave(Multiple Slaves, Single Master)  Serial Interface  Synchronous  Data Exchange
  • 5. Continue…  SPI is a Master-Slave protocol  The Master device controls the clock (SCK)  No data is transferred unless a clock signal is present  All slaves are controlled by the master clock  The slave devices may not manipulate the clock  Master Set Slave Select low  Master Generates Clock  Shift registers shift in and out data Master Slave SCLK MOSI MISO SS
  • 6. Continue…  Simple SPI Protocol Specifies 4 Signal Wires  Master Out Slave In (MOSI)  Master In Slave Out (MISO)  Serial Clock (SCLK)  Slave Select (SS)  MOSI – Carries data out of Master to Slave  MISO – Carries data from Slave to Master (Both signals happen for every transmission)  SS – Unique line to select a slave  SCLK – Master produced clock to synchronize data transfer MOSI Master Slave SCLK MOSI MISO SS
  • 7. Continue…  SPI is a Synchronous protocol  The data is clocked along with a clock signal(SCK)  The clock signal controls when data is changed and when it should be read  Since SPI is synchronous, the clock rate can vary, unlike RS-232 style communications
  • 8. Continue…  SPI is a Data Exchange protocol  As data is being clocked out, new data is clocked in  Data is exchanged - no device can just be a transmitter only or receiver only  the master controls the exchange by manipulating the clock line (SCK)  Often a signal controls when a device is accessed - this is the CS or SS signal  CS or SS signal is known as “Chip Select” or “Slave Select” and is frequently an active-low signal.  Data is only output during the rising or falling edge of SCK  Data is latched during the opposite edge of SCK  The opposite edge is used to ensure data is valid at the time of reading
  • 9. Fig.1 : Two SPI Modules connected in a Master-Slave Configuration  Master shifts out data to Slave, and shift in data from Slave
  • 10. Serial Peripheral Interface(SPI)  Data is shifted out of the master's MOSI pin and in its MISO pin.  Data transfer is initiated by simply writing data to the SPI data register.  All data movement is coordinated by SCK.  Slave select may or may not be used depending on interfacing device.  To get input data only you send “junk” data to SPDR to start the clock.
  • 11. Single Master and Single Slave Master Slave SCLK MOSI MISO SS  Master • Initiates the Connection • Controls SCLK and Data transfer  Slave • Transmits Data • Receives Data
  • 12. Single Master and Multiple independent Slave Master SCLK MOSI MISO SS1 SS2 SCLK MOSI MISO SS SCLK MOSI MISO SS
  • 13. Master and multiple daisy-chained slaves
  • 14. How Do They Communicate  Communication Initiated by Master only  Master Configures the clock – Frequency less than equal to maximum frequency Slave Support  Master Selects Slave – By Pulling chip select(SS) of particular Slave-peripheral to Low State
  • 15. Data Transmission Mode SPI Mode CPOL CPHA Shift SCK Edge Capture SCK Edge 0 0 0 Falling Raising 1 0 1 Raising Falling 2 1 0 Raising Falling 3 1 1 Falling Raising Table : SPI Mode Configuration
  • 16. SPI Transfer format with CPHA = 0
  • 17. SPI Transfer format with CPHA = 1
  • 18.
  • 19. Steps for Master Mode  Set SPCCR (Clock Counter Register) with appropriate clock frequency  Set SPCR (Control Register) to desired settings  Write the data into SPDR (Data Register) of SPI  Monitor SPIF bit of SPCR register, until it sets to 1(SPIF = 1 means data transfer is complete ).  Read SPSR (Status Register), this will clear SPIF bit  Read SPDR (Data Register), reading data register will return data sent by the slave during last transfer.
  • 20. Steps for Slave Mode  Clock will be decided by Master  Set SPCR (Control Register) to desired settings  Write dummy data into SPDR (Data Register), so that SPI control block will generate Clock.  Monitor SPIF bit of SPCR register, until it sets to 1  Read SPSR (Status Register), this will clear SPIF bit  Read SPDR (Data Register), reading data register will return data sent by the slave during last transfer.
  • 21.
  • 22. SPI Clock Counter Register (SPCCR)  The SPCCR is used to set data transfer rate (SPI Frequency) It is 8 bit register, and the value entered in this register is used to calculate frequency SPI data rate = (PCLK / SPCCR value) The value entered must be even value, thus LSB must be 0.The value should be greater than 8.So maximum frequency is 1.875 MHz(PCLK = 15MHz). SPI Control Register (SPCR) SPIE SPE LSBF MSTR CPOL CPHA SPR1 SPR0 Bit 7 6 5 4 3 2 1 0 Read/Write Initial Value R/W R/W R/W R/W R/W R/W R/W R/W 0 0 0 0 0 0 0 0 SPCR
  • 23. SPI Control Register (SPCR) Bit 0&1: SPR0& SPR1 SPI2X SPR1 SPR0 SCLK 0 0 0 fosc/4 0 0 1 fosc/16 0 1 0 fosc/64 0 1 1 fosc/128 1 0 0 fosc/2 1 0 1 fosc/8 1 1 0 fosc/32 1 1 1 fosc/64 In SPSR Clock Rate
  • 24. SPI Control Register (SPCR) Bit 2: CPHA CPHA stands for Clock Phase Control, and plays an important role in deciding the relation between sampling of data and clock pulse CPHA = 0 ; data is sampled on first clock edge CPHA = 1 ; data is sampled on the second rising edge •The important thing to be considered here is CPHA should be 0 when LPC2148 is used as a SPI Master. •It is mentioned in the User Manual of LPC2148 that SSEL signal is inactive during the data transfer when CPHA is 0, but when CPHA is 1 the SSEL signal becomes active and immediately transforms itself into slave. •This results into a Mode Fault and data transfer terminates. •In this case MODF bit of Status Register will set to 1.
  • 25. SPI Control Register (SPCR) Bit 3 : CPOL •CPOL stands for Clock Polarity Control •The bit decides the polarity of SPI clock, when set to 1 clock is active low. In that case first clock will start with negative going pulse •when set to 0 the clock is active high meaning that the clock will start with positive going edge CPOL = 0 CPOL = 1
  • 26. SPI Control Register (SPCR) Bit 4 : MSTR The bit is used to configure SPI block in Master/Slave Mode MSTR = 0 Slave Mode MSTR = 1 Master Mode Bit 5 : DORD or LSBF The bit decides the direction of bit transfer LSBF = 0 MSB is transferred first LSBF = 1 LSB is transferred first
  • 27. SPI Control Register (SPCR) Bit 6 : SPE •The bit is used to enable SPI Interface SPE = 0 disable SPI Interface SPE = 1 enable SPI Interface •It is an interrupt Enable bit, SPIE = 0 Interrupt are disabled SPIE = 1 Interrupts are enabled and will occur when SPI/ WCOL bit is set. Bit 7 : SPIE
  • 28. SPI Status Register (SPSR) Bit 0 : SPI2X Bit 6 : WCOL •The bit is used to set double clock rate in master mode SPI2X = 0 normal clock rate SPI2X = 1 double clock rate •The bit is used for write collision WCOL is set if SPDR is written during a receive transfer
  • 29. SPI Status Register (SPSR) Bit 7 : SPIF •The bit is used for interrupt flag SPIF bit is set when serial transfer is complete. SPIF WCOL - - - - - SPI2X SPSR Bit 7 6 5 4 3 2 1 0 Read/Write Initial Value R R R R R R R R/W 0 0 0 0 0 0 0 0
  • 30. SPI Data Register (SPDR)  It is 16 bit register used in data transfer, the data length is selectable (8 –16bits).  The data length can be configured by using bit 2 (BitEnable) and bits 11:8 of control register.  There is no buffer between the data register and the internal shift register.  A write to the data register goes directly into the internal shift register.  Therefore, data should only be written to this register when a transmit is not currently in progress. Otherwise a Collision Error may occur.  Read data is buffered. When a transfer is complete, the receive data is transferred to a single byte data buffer, where it is later read. MSB - - - - - - LSB SPDR Bit 7 6 5 4 3 2 1 0 Read/Write R/W R/W R/W R/W R/W R/W R/W R/W X X X X X X X X
  • 31. Advantages  Full Duplex Communication  Higher Throughput than I2C  Not Limited to 8 bit words in case of bit transferring  Arbitrary choice of message size, content and Purpose  Low Power  Fast and easy  Fast for point-to-point connections  Easily allows streaming/Constant data inflow  No addressing/Simple to implement  Everyone supports it
  • 32. Disadvantages  Requires more pins than I2C  No hardware flow control  No Slave Acknowledgement ability  No inherent arbitration  Multi Master Difficult to Implement  SS makes multiple slaves very complicated  Short Distance
  • 33. SPI Peripherals  Converters (ADC, DAC)  Memories (EEPROM, RAM’s, Flash)  Sensors (Temperature, Humidity, Pressure)  Real Time Clocks  Misc.- Potentiometers, LCD controllers, UART’s, USB controller, CAN controller, amplifiers
  • 34. Some Important Facts  A read or write of the SPI data register is required in order to clear the SPIF status bit.  The prime function of SPSR register is to indicate the completion of data transfer between two devices. The remaining bits of SPSR register.  When CPHA = 0, the SSEL signal will always go inactive between data transfers. This is not guaranteed when CPHA = 1 (the signal can remain active).
  翻译: