SPI Protocol Sepehr Naimi www.NicerLand.com.

Slides:



Advertisements
Similar presentations
Anurag Dwivedi Rudra Pratap Suman. Scope of Communica tion Telephones and Cell Phones.
Advertisements

ECE 371 Unit 13 - Part 1 Serial Peripheral Interface (SPI)
SHIFT REGISTERS: CONVERTING BETWEEN SERIAL AND PARALLEL DATA Mark Neil - Microprocessor Course 1 Serial versus Parallel Data Transfers.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Guest Lecturer Pat Pannuto Lecture 10: Serial buses Oct 6, 2011.
Serial Interfaces, Part Deux -I 2 C and SPI December 4, 2002 Presented by Eugene Ho.
SPI Serial Peripheral Interface. SPI Serial Peripheral Interface is communication between two devices, one bit at a time sequential one bit at time over.
Lecture 8: Serial Interfaces
Serial Peripheral Interface [SPI] Controller Area Network [CAN]
SPI on the ATmega SS’ line only used in Slave mode SPDR
Serial Communication Buses: I 2 C and SPI By Brody Dunn.
Serial Peripheral Interface (SPI)
SPISPI Term Dr Abdelhafid Bouhraoua Term Dr Abdelhafid Bouhraoua.
ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 13.
Interfaces A practical approach. Lesson 2 I2C and SPI
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 10: Serial buses Oct 6, 2011.
Serial Peripheral Interface (SPI) Bus. SPI Bus There is no official specification for the SPI bus. It is necessary to consult the data sheets of the devices.
Serial Peripheral Interface Module MTT M SERIAL PERIPHERAL INTERFACE (SPI)
CRKit RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
CRKit RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
4.0 rtos implementation part II
DEVICES AND COMMUNICATION BUSES FOR DEVICES NETWORK–
CRKit RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
CRKit RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
7/23 Inter-chip Serial Communication: SPI and I 2 C Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee.
Chapter 10: 68HC11 Serial Peripheral Interface
Serial I/O and the HC11. Overview General discussion of serial I/O operations oSynchronous vs. asynchronous operations oBaud rate vs. bit rate oTransmission.
Embedded System Design Laboratory October 4, 2002Stanford University - EE281 Lecture #3#1 Lecture #3 Outline Announcements AVR Processor Resources –UART.
1 Synchronous Serial IO Send a separate clock line with data –SPI (serial peripheral interface) protocol –I 2 C (or I2C) protocol Encode a clock with data.
Real-time Systems Lab, Computer Science and Engineering, ASU Quark SPI Interface (ESP – Fall 2014) Computer Science & Engineering Department Arizona State.
ELE22MIC Lecture 11 Serial Peripheral Interface - SPI AS11 PAL/PLD
Network and Systems Laboratory nslab.ee.ntu.edu.tw se.
OCRP RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
HCS12 Technical Training, Rev 2.0 Module 7- SCI, Slide 1 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other.
RX Serial Peripheral Interface (RSPI)
OCRP RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
S4525A Peripherals & Enhanced FLASH 1 © 1999 Microchip Technology Incorporated. All Rights Reserved. S4525A Peripherals & Enhanced FLASH 1 Peripherals.
Essentials of Communication This simple model requires many guarantees. Sender Receiver Communication Link Data.
Revised: Aug 1, ECE263 Embedded System Design Lessons 27, 28 Serial Peripheral Interface.
SHIFT REGISTERS: CONVERTING BETWEEN SERIAL AND PARALLEL DATA Mark Neil - Microprocessor Course 1 Serial versus Parallel Data Transfers.
1 MPC 555: Queued Serial Module. 2 MPC 555 QSM QSPI: Queued Serial Peripheral Interface: full duplex serial, synchronous interface. 160B of queue RAM.
Communicating. The ATmega16 communicates through one of the following ways: Serial Peripheral Interface (SPI) Universal Synchronous and Asynchronous serial.
Embedded Communication Protocols Don Heer 10/18/10 1.
Networked Embedded Systems Sachin Katti & Pengyu Zhang EE107 Spring 2016 Lecture 9 Serial Buses – SPI, I2C.
BIRLA VISHVAKARMA MAHAVIDYALAY SUBJECT: SPI PROTOCOL & MAX7221 DISPLAY INTERFACING SUBMITTED BY: KISHAN AVASTHI( ) MANSI CHANDEGARA( )
میکرو کنترلرهای AVR Serial Interfaces, I2C and SPI
MICROCONTROLLER AND INTERFACING Presented by: Shefali Jethva ( ) Shivali Panchal ( ) Komal Soni ( ) Roll no. :- 14EC308.
1 Serial Peripheral Interface What is it? Basic SPI Capabilities Protocol Pros and Cons Uses Serial Peripheral Interface
©F.M. Rietti Communication Lines Fundamentals. ©F.M. Rietti LM-18 Computer Science SSI Embedded Systems I 2 Communication Lines Generally used to connect.
Serial Communication Originally created by Anurag Dwidedi and Rudra Pratap Suman.
ECE 382 Lesson 15 Lesson Outline S/W Delays Wrap up
Serial Communication Buses: I2C and SPI
Tutorial Introduction
EE 107 Fall 2017 Lecture 5 Serial Buses – UART & SPI
ECE 3430 – Intro to Microcomputer Systems
SERIAL PERIPHERAL INTERFACE
Atmega32 Serial Programming Basics
BJ Furman ME 106 Fundamentals of Mechatronics 15NOV2012
EEPROM Comparison – Parallel or Serial
SPI Protocol and DAC Interfacing
SPI Protocol and DAC Interfacing
SPI Protocol and DAC Interfacing
UART Protocol Chapter 11 Sepehr Naimi
I2C and RTC Chapter 18 Sepehr Naimi
Преглед Начин функционисања Имплементације
AVR Programming in C Chapter 7
ADC and DAC Programming in AVR
Programmable Data Communication Blocks
Serial Communication 19th Han Seung Uk.
Developing a reliable communication between Blackfin and Slave device
Serial Peripheral Interface Bus
Presentation transcript:

SPI Protocol Sepehr Naimi www.NicerLand.com

SPI Protocol Synchronous Full-duplex Serial Fast communication For short distances Pins SDO (Data Out) SDI (Data In) SCLK (shift clock) CE (chip enable)

Master vs. Slave Master begins the communication be pulling down the CE pin of slave. Master makes the clock for communication

SPI internal circuit A shift register in the master and another in the slave By each clock, a bit is shifted out from the master’s shift register into the slave shift register and a bit is shifted from slave to master.

Multi-slave communication

SPI pins in AVR MOSI (Master Out Slave In) MISO (Master In Slave Out) SCK SS

Connecting a slave device to an AVR

AVR registers Control register: Status Register: Data Register: SPCR (SPI Control Register) Status Register: SPSR (SPI Status Register) Data Register: SPDR (SPI Data Register)

SPSR (SPI Status Register) SPIF (SPI Interrupt Flag) A serial transfer is completed. The SS pin is driven low in slave mode WCOL (Write Collision) SPI2X (Double SPI Speed)

SPCR SPIE (SPI Interrupt Enable) SPE (SPI Enable) DORD (Data Order) CPOL CPHA Data Read and Change Time SPI Mode Read on rising edge, changed on a falling edge 1 Read on falling edge, changed on a rising edge 2 3 SPIE (SPI Interrupt Enable) SPE (SPI Enable) DORD (Data Order) MSTR (Master) CPOL (Clock Polarity) CPHA (Clock Phase) SPR1, SPR0 :SPI Clock Rate SPI2X SPR1 SPR0 SCK Freq. Fosc/4 1 Fosc/16 Fosc/64 Fosc/128 Fosc/2 (not recommended) Fosc/8 Fosc/32

Program 1: Sending ‘G’ through SPI as a master #include <avr/io.h> #define MOSI 3 #define SCK 5 #define SS 2 int main (void) { DDRB = (1<<MOSI)|(1<<SCK)|(1<<SS); //MOSI and SCK are output DDRD = 0xFF; //Port D is output SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0); //enable SPI as master while(1) //do for ever PORTB &= ~(1<<SS); //enable slave device SPDR = 'G'; //start transmission while(!(SPSR & (1<<SPIF))); //wait transfer finish PORTD = SPDR; //move received data to PORTD PORTB |= (1<<SS); //disable slave device } return 0;

Program 2: Sending ‘G’ through SPI as a slave #include <avr/io.h> #define MISO 4 int main (void) { DDRD = 0xFF; //Port D is output DDRB = (1<<MISO); //MISO is output SPCR = (1<<SPE); //enable SPI as slave while(1) SPDR = 'G'; while(!(SPSR &(1<<SPIF))); //wait for transfer finish PORTD = SPDR; //move received data to PORTD } return 0;