Serial Peripheral Interface SPI I2C (i-squared cee)

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

INPUT-OUTPUT ORGANIZATION
EXTERNAL COMMUNICATIONS DESIGNING AN EXTERNAL 3 BYTE INTERFACE Mark Neil - Microprocessor Course 1 External Memory & I/O.
ECE 371 Unit 13 - Part 1 Serial Peripheral Interface (SPI)
Bits and Bytes + Controlling 8 LED with 3 Pins Binary Counting and Shift Registers.
Processor System Architecture
SHIFT REGISTERS: CONVERTING BETWEEN SERIAL AND PARALLEL DATA Mark Neil - Microprocessor Course 1 Serial versus Parallel Data Transfers.
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 Communication Buses: I 2 C and SPI By Brody Dunn.
Guitar Effects Processor Critical Design Review October, 07, 2003 Groups Members: Adam Bernstein Hosam Ghaith Jasenko Alagic Matthew Iyer Yousef Alyousef.
Serial Peripheral Interface (SPI)
SPISPI Term Dr Abdelhafid Bouhraoua Term Dr Abdelhafid Bouhraoua.
Unit-5 CO-MPI autonomous
SPI Compatible Devices Design and implementation details on the way to a valid SPI-LCD interface driver.
INPUT-OUTPUT ORGANIZATION
Interfaces A practical approach. Lesson 2 I2C and SPI
Computer Architecture Lecture 08 Fasih ur Rehman.
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.
HD44780 LCD programming From the Hardware Side
Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors.
LSU 10/22/2004Serial I/O1 Programming Unit, Lecture 5.
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,
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.
EE 446 Project Assignment Top Design Sensor Components Pin Assignment and Configuration Completed Physical Setup Project Tasks.
Lecture 20: Communications Lecturers: Professor John Devlin Mr Robert Ross.
University of Calcutta CBM 1 ROC Design Issues Dr. Amlan Chakrabarti, Dr. Sanatan Chattopadhyay & Mr. Suman Sau.
Input/Output 2 What is I/O? How we get the CPU to communicate with devices From the computer’s point of view, it’s just 1’s and 0’s Gets interpreted.
Autonomous Helicopter James LydenEE 496Harris Okazaki.
MODES OF Details of Pins Pin 1GND –Connected Ground Pins 2-16 AD14-AD0–acts as both input/output. Outputs address at the first part of the cycle.
Digital Logic Design.
Network and Systems Laboratory nslab.ee.ntu.edu.tw se.
Computer Hardware A computer is made of internal components Central Processor Unit Internal External and external components.
1 Programming of FPGA in LiCAS ADC for Continuous Data Readout Week 5 Report Tuesday 29 th July 2008 Jack Hickish.
OCRP RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
OCRP RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
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.
Department of Electronic & Electrical Engineering Template program. Input / Output (IO) ● Template program. ● Introduction to IO ● Setting up for IO ●
Department of Electronic & Electrical Engineering LCD character display (parallel interface). How to interface a LCD character display to a PIC.
Department of Electronic & Electrical Engineering Serial interfaces Serial Interfaces allow communication between devices sending one bit at a time. In.
Department of Electronic & Electrical Engineering Lecture 2 ● Introduction to IO ● Using a subroutine ● Driving a 7seg display.
Department of Electronic & Electrical Engineering Further work? Simple Voltmeter. ● Analogue to Digital converter (MCP3001 SPI ) ● Analogue → 10bit binary.
Department of Electronic & Electrical Engineering Digital Lock. (e.g. for sports locker room) Assessment: Plan. Demo. Code.
SHIFT REGISTERS: CONVERTING BETWEEN SERIAL AND PARALLEL DATA Mark Neil - Microprocessor Course 1 Serial versus Parallel Data Transfers.
Department of Electronic & Electrical Engineering Introduction to microcontrollers A microcontroller is a small computer on a single integrated circuit.
Department of Electronic & Electrical Engineering Lecture 4. ➢ Loops ➢ Delays ➢ Conditional instructions ➢ Simple clock example.
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
1. PIC ADC  PIC18F877 has 8 analog input channels i.e. port A pins(RA0 to RA5) and port E pins(RE1 and RE2). These pins are used as Analog input pins.
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 Buses: I2C and SPI
EE 107 Fall 2017 Lecture 5 Serial Buses – UART & SPI
Chapter D – Serial Connections to the RPi and Analog-to-Digital Converters
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
Atmega32 Serial Programming Basics
EEPROM Comparison – Parallel or Serial
Pulse Width Modulation (PWM)
Introduction to Microprocessors and Microcontrollers
Преглед Начин функционисања Имплементације
HD44780 LCD programming From the Hardware Side
HD44780 LCD programming From the Hardware Side
Presentation transcript:

Serial Peripheral Interface SPI I2C (i-squared cee) Serial interfaces Serial Interfaces allow communication between devices sending one bit at a time. In contrast Parallel interfaces have multiple data lines allowing whole words to be sent as a single operation. There are different protocols for serial communication, common examples: Serial Peripheral Interface SPI I2C (i-squared cee)

Serial Peripheral Interface Bus (SPI) - Lots of devices use SPI to communicate - There is always a Master Device (eg. PIC ) and a Slave Device(s) (eg. SPI eeprom OR an ADC) - Many PICs have inbuilt SPI or I2C - The PIC16F84A does not! (need to implement it in software) The SPI protocol uses 4 lines to connect the two devices All slaves have a unique line to select the device. The other lines can be shared.

The SPI bus specifies four logic signals: SCLK: serial clock (used to synchronise serial transfer) MOSI: master output, slave input (used to send data to device) MISO: master input, slave output (used to receive data from device ) SS: slave select (active low, output from master). The names are often different on the device data sheet!

Example with 3 slaves

Voltmeter: Using the MCP3001 Serial digital 12bits (SPI) Parallel interface LCD display PIC ADC SO 3.142 Volts CLK CS Voltage(analogue)

Example Sequence for operation. ADC -- MCP3001 (see DATA SHEET) Start Discard first 3 bits! DATA Time

Example Connections (SPI EEPROM)

We read the next bit from the SO pin. Reading data using SPI. We initiate an operation by taking CS low. loop: We read the next bit from the SO pin. Send a pulse to SCK (low-high-low). We finish an by taking CS high. Writing data works the same way --- set SI high/low

Timing Diagrams Tell us how long it takes the device to respond . . . .

Some typical. Timing values

Timing considerations. PIC instruction is 4 clock cycles @ 4MHz 1 instruction takes 1 uS all critical times < 1uS No need to add delays

Code fragments --- 1. Define some constants ; define the bits of PORTA as constants ; so we can write stuff like: ; bcf PORTA,SPI_CLK ; sets clock low. SPI_SI EQU H'0' ; See diagram in previous slide SPI_CLK EQU H'1' SPI_SO EQU H'2' SPI_CS EQU H'3' ; spi IO registers Used to store values to be sent to/from EEPROM SPI_IN_BUF EQU H'25' SPI_OUT_BUF EQU H'26'

Write a byte to the SPI device SPI_OUT_BUF contains the data. Assume we send the most significant bit first. loop: Set SPI_SI pin according to left most (MSB) of SPI_OUT_BUF Strobe the SPI_CLK to make device read the data Shift SPI_OUT_BUF left ready for writing the next bit. Repeat 8 times for each bit. Carry SPI_OUT_BUF 01101001 TO SPI_SI 11010010 1 10100100

RLF Rotate Left through Carry

Routine to write one bit to the SPI device ;------------------------------------------------------------------------------ ; write left most bit (MSB) of SPI_OUT_BUF to device ; SPI_OUT_BUF is shifted one bit to the left spi_write_bit: rlf SPI_OUT_BUF,f ; rotate to set carry bit if MSB is 1 btfsc STATUS,C ; skip if carry is clear goto set_out_bit ; if carry bit is set bcf PORTA,SPI_SI ; if carry bit is clear (SI pin=0) goto doit_write_bit ; send bit set_out_bit: bsf PORTA,SPI_SI ; if carry (SI pin=1) ; now send bit to device doit_write_bit: call spi_strobe ; advance clock to send bit return

Strobe routine (read/write next bit) ; advance the clock in the serial EEPROM ; no delay needed if running from a 4MHz clock spi_strobe: bsf PORTA,SPI_CLK ; set clock high bcf PORTA,SPI_CLK ; set clock low return

Writing one byte to the SPI device ; routine to write SPI_OUT_BUF reg to the SPI device spi_out: call spi_write_bit ; write MSB and shift SPI_OUT_BUF right call spi_write_bit ; write next bit etc call spi_write_bit return

Routine to read a bit ;------------------------------------------------------------------------------- ; read a single bit from ee-prom into SPI_IN_BUF (right most bit) ; rotate SPI_IN_BUF to the left before reading spi_read_bit rlf SPI_IN_BUF,f ; rotate buffer left btfsc PORTA,SPI_SO ; test the SO pin bsf SPI_IN_BUF,0 ; high? then set bit0 call spi_strobe ; advance the clock return

Outcomes. describe how the SPI protocol can be used to interface devices. describe the sequence of events required to read/write using SPI