EE 107 Fall 2017 Lecture 7 Serial Buses – I2C Direct Memory Access

Slides:



Advertisements
Similar presentations
Homework Reading Machine Projects Labs
Advertisements

I2C bus Inter Integrated Circuits bus by Philips Semiconductors
Computer Architecture
I/O Organization popo.
1  1998 Morgan Kaufmann Publishers Interfacing Processors and Peripherals.
9/20/6Lecture 3 - Instruction Set - Al1 The Hardware Interface.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 13 Direct Memory Access (DMA)
University College Cork IRELAND Hardware Concepts An understanding of computer hardware is a vital prerequisite for the study of operating systems.
CHAPTER 9: Input / Output
Computer Architecture Lecture 08 Fasih ur Rehman.
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
Chapter 7 Input/Output Luisa Botero Santiago Del Portillo Ivan Vega.
Embedded Bus – i2c David E. Culler Lab 2 Feb 2, 2015
Chapter 10: Input / Output Devices Dr Mohamed Menacer Taibah University
CHAPTER 9: Input / Output
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
I/O Example: Disk Drives To access data: — seek: position head over the proper track (8 to 20 ms. avg.) — rotational latency: wait for desired sector (.5.
Top Level View of Computer Function and Interconnection.
Computer Architecture Lecture10: Input/output devices Piotr Bilski.
DMA Versus Polling or Interrupt Driven I/O
I/O Computer Organization II 1 Interconnecting Components Need interconnections between – CPU, memory, I/O controllers Bus: shared communication channel.
CH10 Input/Output DDDData Transfer EEEExternal Devices IIII/O Modules PPPProgrammed I/O IIIInterrupt-Driven I/O DDDDirect Memory.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
IT3002 Computer Architecture
Processor Memory Processor-memory bus I/O Device Bus Adapter I/O Device I/O Device Bus Adapter I/O Device I/O Device Expansion bus I/O Bus.
Chapter 3 System Buses.  Hardwired systems are inflexible  General purpose hardware can do different tasks, given correct control signals  Instead.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
1 load [2], [9] Transfer contents of memory location 9 to memory location 2. Illegal instruction.
CSCE 385: Computer Architecture Spring 2014 Dr. Mike Turi I/O.
Networked Embedded Systems Pengyu Zhang & Sachin Katti EE107 Spring 2016 Lecture 11 Direct Memory Access.
DIRECT MEMORY ACCESS and Computer Buses
Interconnection Structures
Department of Computer Science and Engineering
Bus Interfacing Processor-Memory Bus Backplane Bus I/O Bus
Everybody.
Microcontrollers & GPIO
EE 107 Fall 2017 Lecture 5 Serial Buses – UART & SPI
Chapter 11: Inter-Integrated Circuit (I2C) Interface
Direct Memory address and 8237 dma controller LECTURE 6
I/O Memory Interface Topics:
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
CS 286 Computer Organization and Architecture
Dr. Michael Nasief Lecture 2
Chapter 3 Top Level View of Computer Function and Interconnection
COMP2121: Microprocessors and Interfacing
I2C PROTOCOL SPECIFICATION
Communication Lines Fundamentals.
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
Computer Architecture
Interfacing Memory Interfacing.
CSCI 315 Operating Systems Design
Input/Output Organization
ECEG-3202 Computer Architecture and Organization
Operating Systems Chapter 5: Input/Output Management
Peng Liu Lecture 14 I/O Peng Liu
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Computer Organization
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Created by Vivi Sahfitri
Wireless Embedded Systems
William Stallings Computer Organization and Architecture 7th Edition
Chapter 13: I/O Systems.
Computer Operation 6/22/2019.
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

EE 107 Fall 2017 Lecture 7 Serial Buses – I2C Direct Memory Access Networked Embedded Systems Sachin Katti

I2C bus in our projects Communication with the camera Pros Cons Read from the camera Write to the camera Pros Simple wire connection Two wires bus that can connect multiple peripherals with the MCU Cons Complexity is a bit higher

How to operate the camera? I2C register 1 register 2 …. MCU I2C pixel array FRAM DMA data SPI SD card

I2C Details Two lines Only two wires for connecting multiple devices Serial data line (SDA) Serial clock line (SCL) Only two wires for connecting multiple devices

I2C Details Each I2C device recognized by a unique address Each I2C device can be either a transmitter or receiver I2C devices can be masters or slaves for a data transfer Master (usually a microcontroller): Initiates a data transfer on the bus, generates the clock signals to permit that transfer, and terminates the transfer Slave: Any device addressed by the master at that time

Bit Transfer on the I2C Bus In normal data transfer, the data line only changes state when the clock is low SDA SCL Data line stable; Data valid Change of data allowed

Start and Stop Conditions A transition of the data line while the clock line is high is defined as either a start or a stop condition. Both start and stop conditions are generated by the bus master The bus is considered busy after a start condition, until a stop condition occurs Start Condition Stop Condition SCL SDA

I2C Addressing Each node has a unique 7 (or 10) bit address Peripherals often have fixed and programmable address portions Addresses starting with 0000 or 1111 have special functions:- 0000000 Is a General Call Address 0000001 Is a Null (CBUS) Address 1111XXX Address Extension 1111111 Address Extension – Next Bytes are the Actual Address

I2C-Connected System Example I2C-connected system with two microcontrollers (Source: I2C Specification, Philips)

Master-Slave Relationships Who is the master? master-transmitters master-receivers Suppose microcontroller A wants to send information to microcontroller B A (master) addresses B (slave) A (master-transmitter), sends data to B (slave-receiver) A terminates the transfer. If microcontroller A wants to receive information from microcontroller B A (master) addresses microcontroller B (slave) A (master-receiver) receives data from B (slave-transmitter) A terminates the transfer In both cases, the master (microcontroller A) generates the timing and terminates the transfer

Exercise: How fast can I2C run? How fast can you run it? Assumptions 0’s are driven 1’s are “pulled up” Some working figures Rp = 10 kΩ Ccap = 100 pF VDD = 5 V Vin_high = 3.5 V Recall for RC circuit Vcap(t) = VDD(1-e-t/τ) Where τ = RC

Exercise: Bus bit rate vs Useful data rate An I2C “transactions” involves the following bits <S><A6:A0><R/W><A><D7:D0><A><F> Which of these actually carries useful data? So, if a bus runs at 400 kHz What is the clock period? What is the data throughput (i.e. data-bits/second)? What is the bus “efficiency”?

Why do we need DMA?

Why do we need DMA? Polling and Interrupt driven I/O concentrates on data transfer between the processor and I/O devices. An instruction to transfer (mov datain,R0) only occurs after the processor determines that the I/O device is ready Either by polling a status flag in the device interface or Waits for the device to send an interrupt request. Considerable overhead is incurred, because several program instructions must be executed for each data word transferred.

Why do we need DMA? Instructions are needed to increment memory address and keeping track of work count. With interrupts, additional overhead associated with saving and restoring the program counter and other state information.

Direct Memory Access (DMA) To transfer large blocks of data at high speed, an alternative approach is used. Blocks of data are transferred between an external device and the main memory, without continuous intervention by the processor.

DMA Controller DMA controller is part of the I/O interface. Performs the functions that would normally be carried out by the processor when access main memory. For each word transferred, it provides the memory address and all the bus signals that control data transfer.

DMA Controller Device wishing to perform DMA asserts the processors bus request signal. Processor completes the current bus cycle and then asserts the bus grant signal to the device. The device then asserts the bus grant ack signal. The DMA device performs the transfer from the source to destination address. Once the DMA operations have been completed, the device releases the bus by asserting the bus release signal. Processor acknowledges the bus release and resumes its bus cycles from the point it left off.

Use of DMA Controllers 2. DMA controller requests transfer to memory RAM GPIOs DMA controller Bus control logic 4. ACK 5. Interrupt when done 3. Data is transferred Processor Storage 1. CPU programs the DMA controller

How is OS involved I/O operations are always performed by the OS in response to a request from an application program. OS is also responsible for suspending the execution of one program and starting another. OS puts the program that requested the transfer in the Blocked state, initiates the DMA operation, starts execution of another program. When the transfer is complete, the DMA controller informs the processor by sending an interrupt request. OS puts suspended program in the Runnable state so that it can be selected by the scheduler to continue execution.

Linear logical memory

Memory Architecture

Physical vs Virtual Memory Two memory “spaces” Virtual memory space ­ what the program “sees” Physical memory space ­ what the program runs in (size of RAM) Virtual memory requires Dedicated hardware on CPU chip called Memory Mgmt Unit (MMU) Cooperation between CPU hardware & operating system 0: 1: M -1: Main memory Physical address (PA) CPU 2: 3: 4: 5: 6: 7: 4 Data word 8: ... MMU Physical address (PA) ... 0: 1: M-1: Main memory Virtual (VA) CPU 2: 3: 4: 5: 6: 7: 4100 Data word 4 CPU chip Address translation Source: Bryant & O’Hallaron

Example: Virtual and Physical Address Space 0x0C 0x10 0x14 0x18 0x1C add r1,r2,r3 0x00 0x04 0x08 0x0C add r1,r2,r3 sub r2,r3,r4 sub r2,r3,r4 lw r2, 0x04 lw r2, 0x04 mult r3,r4,r5 mult r3,r4,r5 bne 0x00 add r10,r1,r2 sub r3,r4,r1 sw r5,0x0c

Cache coherency problems Imagine a CPU equipped with a cache and an external memory that can be accessed directly by devices using DMA. When the CPU accesses location X in the memory, the current value will be stored in the cache. Subsequent operations on X will update the cached copy of X, but not the external memory version of X, assuming a write-back cache. If the cache is not flushed to the memory before the next time a device tries to access X, the device will receive a stale value of X.

Buffers and Arbitration Most DMACs have a data storage buffer – network interfaces receive data from main memory at bus speed, send data onto network at network speed. Bus Arbitration is needed to resolve conflicts with more than one device (2 DMACs or DMA and processor, etc..) try to use the bus to access main memory.

Bus Arbitration Bus Master – the device that is allowed to initiate bus transfers on the bus at any given time. When the current master relinquishes control, another device can acquire this status. Bus Arbitration – the process by which the next device to become bus master is selected and bus mastership is transferred to it.

Arbitration Approaches Centralized – a single arbiter performs the arbitration. Distributed – all devices participate in the selection of the next bus master.