Department of Electronic & Electrical Engineering Serial interfaces Serial Interfaces allow communication between devices sending one bit at a time. In.

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.
SHIFT REGISTERS: CONVERTING BETWEEN SERIAL AND PARALLEL DATA Mark Neil - Microprocessor Course 1 Serial versus Parallel Data Transfers.
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 Communication Buses: I 2 C and SPI By Brody Dunn.
Serial Peripheral Interface (SPI)
SPISPI Term Dr Abdelhafid Bouhraoua Term Dr Abdelhafid Bouhraoua.
Unit-5 CO-MPI autonomous
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,
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.
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.
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.
OCRP RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
©2008 R. Gupta, UCSD COSMOS Summer 2008 Peripheral Interfaces Rajesh K. Gupta Computer Science and Engineering University of California, San Diego.
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 ●
Lecture 7: Overview Microprocessors / microcontrollers.
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 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.
Serial Peripheral Interface SPI I2C (i-squared cee)
Input Output Techniques Programmed Interrupt driven Direct Memory Access (DMA)
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
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
Serial Communication Buses: I2C and SPI
Tutorial Introduction
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
I2C PROTOCOL SPECIFICATION
BJ Furman ME 106 Fundamentals of Mechatronics 15NOV2012
EEPROM Comparison – Parallel or Serial
Pulse Width Modulation (PWM)
Introduction to Microprocessors and Microcontrollers
Преглед Начин функционисања Имплементације
HD44780 LCD programming From the Hardware Side
Presentation transcript:

Department of Electronic & Electrical Engineering 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)

Department of Electronic & Electrical Engineering 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.

Department of Electronic & Electrical Engineering 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).slave selectactive low ● The names are often different on the device data sheet!

Department of Electronic & Electrical Engineering Example with 3 slaves

Department of Electronic & Electrical Engineering Voltmeter: Using the MCP3001 ADC PIC Voltage(analogue) Serial digital 12bits (SPI) Volts LCD display Parallel interface SO CLK CS

Department of Electronic & Electrical Engineering Example Sequence for operation. ADC -- MCP3001 (see DATA SHEET) Time Start Discard first 3 bits!DATA

Department of Electronic & Electrical Engineering Example Connections (SPI EEPROM)

Department of Electronic & Electrical Engineering 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

Department of Electronic & Electrical Engineering Timing Diagrams Tell us how long it takes the device to respond....

Department of Electronic & Electrical Engineering Some typical. Timing values

Department of Electronic & Electrical Engineering Timing considerations. ● PIC instruction is 4 clock cycles 4MHz 1 instruction takes 1 uS ● all critical times < 1uS ● No need to add delays

Department of Electronic & Electrical Engineering Code fragments 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'

Department of Electronic & Electrical Engineering 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 TO SPI_SI

Department of Electronic & Electrical Engineering RLF Rotate Left through Carry

Department of Electronic & Electrical Engineering 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

Department of Electronic & Electrical Engineering 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

Department of Electronic & Electrical Engineering 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

Department of Electronic & Electrical Engineering 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

Department of Electronic & Electrical Engineering Serial interfaces I2C ● More complex then SPI. ● Only uses 2 lines ● Slave devices have addresses OPEN DRAIN

Department of Electronic & Electrical Engineering How I2C works Video at: Tutorial and C code at:

Department of Electronic & Electrical Engineering Example I2C devices CMPS03 - Compass Module SRF08 ultrasonic rangefinder Contact-less Infrared Thermopile Sensor Breakout - TMP006