Lecture 25 March 23, 2012 Introduction to Serial Communications

Similar documents
Introduction the Serial Communications Parallel Communications Parallel Communications with Handshaking Serial Communications

Parallel Data Transfer. Suppose you need to transfer data from one HCS12 to another. How can you do this?

PARALLEL COMMUNICATIONS

Introduction the Serial Communications Huang Sections 9.2, 10.2 SCI Block User Guide SPI Block User Guide

Introduction to I2C & SPI. Chapter 22

The MC9S12 IIC Interface

Review for Exam III. Analog/Digital Converters. The MC9S12 has two 10-bit successive approximation A/D converters - can be used in 8-bit mode

Microcontrollers and Interfacing

Serial versus Parallel Data Transfers

Dallas Semiconductor DS1307 Real Time Clock. The DS 1307 is a real-time clock with 56 bytes of NV (nonvolatile)

Communication interfaces

Serial Peripheral Interface. What is it? Basic SPI. Capabilities. Protocol. Pros and Cons. Uses

Interfacing Techniques in Embedded Systems

or between microcontrollers)

Part 1 Using Serial EEPROMs

McMaster University Embedded Systems. Computer Engineering 4DS4 Lecture 6 Serial Peripherals Amin Vali Feb. 2016

Serial Communications

Raspberry Pi - I/O Interfaces

The I2C BUS Interface

Embedded Systems and Software. Serial Interconnect Buses I 2 C (SMB) and SPI

1.3inch OLED User Manual

The 9S12 Serial Peripheral Inteface (SPI) Huang Section 10.2 through 10.6 SPI Block User Guide

GIGAVAC Contactors I 2 C Communication

DESIGNING OF INTER INTEGRATED CIRCUIT USING VERILOG

FPGA Implementation Of SPI To I2C Bridge

Real-Time Embedded Systems. CpE-450 Spring 06

Tutorial for I 2 C Serial Protocol

SILICON MICROSTRUCTURES

Temperature Sensor TMP2 PMOD Part 1

17. I 2 C communication channel

IV B.Tech. I Sem (R13) ECE : Embedded Systems : UNIT -4 1 UNIT 4

By: Haron Abdel-Raziq

Serial Buses in Industrial and Automotive Applications

Review for Exam 3. Write 0x05 to ATD0CTL4 to set at fastest conversion speed and 10-bit conversions

Lecture 5: Computing Platforms. Asbjørn Djupdal ARM Norway, IDI NTNU 2013 TDT

Serial Communications

Serial Communication. Spring, 2018 Prof. Jungkeun Park

Growing Together Globally Serial Communication Design In Embedded System

Digital Storage Oscilloscope

Development and research of different architectures of I 2 C bus controller. E. Vasiliev, MIET

MICROCONTROLLER S PROGRAMMER

Handson Technology. I2C Specification and Devices. 1

Freescale Semiconductor, Inc.

I 2 C Slave Controller. I 2 C Master o_timeout_intr

Digital Storage Oscilloscope

Laboratory 5 Communication Interfaces

19.1. Unit 19. Serial Communications

18-349: Introduction to Embedded Real-Time Systems

EEM336 Microprocessors I. I/O Interface

EE 456 Fall, Table 1 SPI bus signals. Figure 1 SPI Bus exchange of information between a master and a slave.

ECE 1160/2160 Embedded Systems Design. Midterm Review. Wei Gao. ECE 1160/2160 Embedded Systems Design

Serial Communication. Simplex Half-Duplex Duplex

More on the 9S12 SPI Using the Dallas Semiconductor DS1302 Real Time Clock with the 9S12 SPI

COMP 273 Winter asynchronous I/O April 5, 2012

Microcontroller Systems. ELET 3232 Topic 23: The I 2 C Bus

USER GUIDE EDBG. Description

Level Shifter. for. Hardware User s Manual.

ECE 4510/5530 Microcontroller Applications Week 10

CprE 488 Embedded Systems Design. Lecture 4 Interfacing Technologies

I2C a learn.sparkfun.com tutorial

Universität Dortmund. IO and Peripheral Interfaces

Section 16. Basic Sychronous Serial Port (BSSP)

GT24C02. 2-Wire. 2Kb Serial EEPROM (Smart Card application)

MIKROPROCESORY PRO VÝKONOVÉ SYSTÉMY. Serial Data Transmission (Stručný přehled) České vysoké učení technické Fakulta elektrotechnická

ELE492 Embedded System Design

More on IO: The Universal Serial Bus (USB)

App Note Application Note: Addressing Multiple FPAAs Using a SPI Interface

How to Implement I 2 C Serial Communication Using Intel MCS-51 Microcontrollers

VZ8(6)9 rev B I2C communication quick manual. SGX Sensortech

Microcontrollers and Interfacing week 10 exercises

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE Microcontroller Based System Design

User-configurable Resolution. 9 to 12 bits (0.5 C to C)

Sender Receiver Sender

ACE24C512C Two-wire serial EEPROM

EE 308 Spring Using the 9S12 SPI

Inter-Integrated Circuit Bus IIC I2C TWI

EDBG. Description. Programmers and Debuggers USER GUIDE

Asynchronous Data Transfer

spi 1 Fri Oct 13 13:04:

Need more memory! What do we do if our 2K of SRAM isn t enough? Doing complex DSP calculations Large matrix math

Embedded Workshop 10/28/15 Rusty Cain

Serial Peripheral Interface (SPI)

White Paper Using the MAX II altufm Megafunction I 2 C Interface

User-configurable Resolution. 9 to 12 bits (0.5 C to C)

Serial Communication Through an Asynchronous FIFO Buffer

SPI Universal Serial Communication Interface SPI Mode

From Datasheets to Digital Logic. synthesizing an FPGA SPI slave from the gates

Sten-SLATE ESP. Accelerometer and I2C Bus

THANG LUONG CAO. Serial bus adapter design for FPGA. Master of Science Thesis

University of Technology

UNIT IV SERIAL COMMUNICATIONS

EECS 373 Design of Microprocessor-Based Systems

Prototyping of On-chip I2C Module for FPGA Spartan 3A series using Verilog

Specification E2 Interface

Unit 19 - Serial Communications 19.1

Potpourri. Serial communication links FFTs RFID Useful Tools Fall 2016 Lecture 13

Section 3 - Backplane Architecture Backplane Designer s Guide

Exercise 2 I 2 C Management 1/7

Basics of UART Communication

Each I2C master has 8-deep transmit and receive FIFOs for efficient data handling. SPI to Dual I2C Masters. Registers

Transcription:

Lecture 25 March 23, 2012 Introduction to Serial Communications Parallel Communications Parallel Communications with Handshaking Serial Communications Asynchronous Serial (e.g., SCI, RS-232) Synchronous Serial (e.g., SPI, IIC) The MC9S12 IIC Subsystem Two bidirectional signals lines: Serial Clock (SCL) and Serial Data (SDA) Device which initiates communications is the Master Master controls SCL line. Master talks to one of many possible slaves Each slave has unique 7-bit address Master sends 7-bit address of slave it wants to talk to Master can either send data to slave or receive data from slave If master sends data to slave, master controls both SCL and SDA If master receives data from slave, master controls SCL and slave controls SDA 1

Parallel Data Transfer Suppose you need to transfer data from one HCS12 to another. How can you do this? You could connect PORTA of the sending computer (set up as an output port) to PORTA of the receiving computer (set up as an input port). The sending computer puts the data on its PORTA, one byte at a time. The receiving computer reads the data on its PORTA. For example, want to sent the five bytes corresponding to the five characters hello : PARALLEL COMMUNICATIONS 0x68 0x65 0x6c 0x6f h e l o Need 9 wires to transmit 8 bits of data How can receiver tell when it should read the data? 2

Parallel Data Transfer The sending computer needs to tell the receiving computer when to read the data. It can do this with another line used as a clock line. On the rising edge of the clock line, the receiving computer should read the data: PARALLEL COMMUNICATIONS 0x68 0x65 0x6c 0x6f h e l l o Need 10 wires to transmit 8 bits of data 3

Parallel Data Transfer How can the sending computer know that the receiving computer has received the data? Can use a method called handshaking. The sending computer uses a Data Valid line to tell the receiving computer that the data on the data lines is valid. The receiving computer uses a Data Received line to tell the sending computer that it has read the current data byte. PARALLEL COMMUNICATIONS DV DR NEW DATA DV DR New data available I ve read the data Use two lines Handshake sender knows when receiver is ready for new data. Need 11 wires to transmit 8 bits of data In the above figure, the sending computer puts the data on the data lines and brings DV low to indicate new data is available. When the receiving computer sees the new data is available (DV goes low) it reads the data on the data lines, then brings DR low to say that it has read the data. When the sending computer sees the recieving computer has read the data (DR goes low), it brings DV high. When the receiving computer sees DV go high, it brings DR high. Both computers are now ready for the next data transfer. 4

Serial Data Transfer Using parallel data transfer you can use 10 wires to transfer one byte at a time from one computer to another. Using 18 wires, you can transfer two bytes (16 bits) at a time. Parallel data transfer is a very fast way to transfer data between two computers. There are two problems with parallel data transfer: It takes a lot of wires between the computers. It uses lots of I/O pins on the computers. Serial data transfer is a slower transfer mechanism, but it uses fewer wires and fewer I/O pins. Serial data transfer sends one bit at a time between two computers: SERIAL COMMUNICATIONS serial out serial in 0 1 0 1 0 h = 0x68 = B"01101000" Can t tell how many ones or zeros there are 5

Types of Serial Data Transfer Asynchronous serial (no clock between devices; uses internal clocks to synchronize data transfer) RS-232 (typically ± 12V), RS-485 (± 6V) Synchronous serial (clock line between devices to synchronize data transfer) SPI (Synchronous Peripheral Interface) IIC or I 2 C (Inter-Integrated Circuit) Differential Serial (Typically ±3 V, clock and signal intermixed on same wires) CAN (Controller Area Network) Ethernet USB (Universal Serial Bus LVDS (Low Voltage Differential Signaling) (±350 mv) LVDS is much faster than other methods, and uses much less power, because voltage swing is much smaller. Firewire Serial ATA PCI Express Many others wave of the future 6

Synchronous Serial Data Transfer To use serial data transfer, you need to have a way for the receiving computer to know when the data bit is valid. There are two ways to do this: Asynchronous Serial Data Transfers (e.g., SCI on the HCS12) Synchronous Serial Data Transfers (e.g., SPI on the HCS12) For Asynchronous Serial Data Transfer, both sides use an internal clock with approximately the same frequency, and a protocol to allow internal synchronization of the data (to be discussed later). Synchronous Serial Data Transfer uses a clock line between the two devices for the sending device to tell the receiving device when each data bit is valid: SYNCHRONOUS SERIAL COMMUNICATIONS serial out serial in 0 1 1 0 1 0 0 0 h = 0x68 = B"01101000" Need 3 wires to transmit 1 bit at a time 7

Synchronous Serial Data Transfer In synchronous serial data transfer, the sending device puts the data byte it wants to send into an internal shift register. The sending device uses a clock to shift the 8 data bits out of the shift register onto an external data pin. The receiving device puts the data from the sending device on the input of an internal shift register. The receiving device uses the clock from the sending device to shift the data into its shift register. After 8 clock ticks, the data has been transfered from the sending device to the receiving device. SYNCHRONOUS SERIAL COMMUNICATIONS shift register shift register 0 1 1 0 1 0 0 0 h = 0x68 = B"01101000" Need 3 wires to transmit 1 bit at a time 8

The HCS12 IIC Interface The SPI requires three lines (Clock, MISO, MOSI), plus another line to select each device to talk to. 1. An SPI bus which controls four slaves will require seven lines. Another popular synchronous serial interface is the Inter-Integrated Circuit (IIC or I 2 C) bus The IIC bus can control multiple devices using only two wire The two wires are Clock and Data The devices connect to the wires using a wired and method The lines are normally high. Any device on the bus can bring them low. Each device on the bus has a unique address An IIC master starts the process by sending out a serial stream with the seven-bit address of the slave it wants to talk to, and an eight bit indicating if it wants to write to the slave or read from the slave If it writes to the slave, it will continue send data on the serial data line (toggling the clock on each data bit) until all the data is sent. If it reads from the slave, it will release the data line, but retain control of the clock line. The slave takes over the data line, and sends out its data in response to the clock provided by the master. After all the data is transfered, the master releases both the clock and the data lines V DD SDA Line SCL Line CLK1 OUT Data1 OUT CLK2 OUT Data2 OUT CLK1 IN Data1 IN CLK2 IN Data2 IN Device 1 Device 2 9

The IIC Interface Normally, both SDA and SCL are high. When the master wants to talk to a slave, it brings SDA low (the Start condition). This gives the master control of the bus The master sends eight bits of data on the SDA bus, and toggles the SCL bus for each bit. The eight bits are the seven-bit address of the slave, and one bit for read-write a low indicates a write, and a high indicates a read. After the eighth data bit, the master releases the SDA line. The master sends a ninth clock pulse. The addressed slave responds with an acknowledge by bringing SDA low. If the master is writing data to the slave, it continues controlling both SDA and SCL. It sends eight bits of data, releases SDA, and waits for an acknowledge from the slave It the master is reading data from the slave, it controls the SCL line and the slave controls the SDA line. The master sends eight clock pulses on the SCL line, and the slave transfers one bit of data on each clock pulse. At the end of the eight bits, the master takes over the SDA bus and sends an acknowledge on all but the last byte it wants. After the last byte, the master sends an NACK (leaves SDA high). After the transfer is complete, the master sends a Stop condition to indicate that it is releasing the bus. The Stop condition is indicated by bringing SDA high which SCL is high. 10

S 7 bit slave address R/W A 8 Data Bits A 8 Data Bits A/A P 0 (Write) Repeat for more data S 7 bit slave address R/W A 8 Data Bits A 8 Data Bits A P 1 (Read) Repeat for more data From master to slave From slave to master A = Acknowledge (SDA low) A = Not Acknowledge (SDA high) S = Start condition P = Stop condition SCL MSB LSB 1 2 3 4 5 6 7 8 MSB LSB 9 1 2 3 4 5 6 7 8 9 SDA AD7 AD6 AD5 AD4 AD3 AD2 AD1 R/W XXX D7 D6 D5 D4 D3 D2 D1 D0 Start Signal Calling Address Read/ Ack Data Byte Write Bit No Ack Bit Stop Signal 11