The I2C BUS Interface

Similar documents
The Serial Peripheral Interface

Using the Digital I/O interface of STMicroelectronics STM32 Microcontrollers

The Controller Area Network (CAN) Interface

Additional Timer Functionalities. Capture, Compare, PWM

Introduction to L.A.P. 1

The Analog to Digital Converter (ADC)

Lecture 25 March 23, 2012 Introduction to Serial Communications

Using the Special Function Registers of the Digital I/O interface of STM32

Introduction to I2C & SPI. Chapter 22

Microcontrollers and Interfacing

Introduction the Serial Communications Parallel Communications Parallel Communications with Handshaking Serial Communications

Temperature Sensor TMP2 PMOD Part 1

Using Timers of Microchip PIC18F Microcontrollers

Using the Special Function Registers of the Digital I/O interface of STM32

Interfacing Z8 Encore! XP MCUs with an I 2 C-Based Character LCD

Laboratory 5 Communication Interfaces

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

17. I 2 C communication channel

Application Note: AZD025 IQ Switch - ProxSense TM Series I2C Example Code for the IQS222

Tutorial for I 2 C Serial Protocol

The Cubesat Internal bus: The I2C

Implementation of MCU Invariant I2C Slave Driver Using Bit Banging

I2C Demonstration Board I 2 C-bus Master Selector

Handling Asynchronous Events in MCUs A Light Keyboard Driver

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

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

I 2 C Communication. Embedded Systems Interfacing. 25 October 2011

I2C on the HMC6352 Compass

The IIC interface based on ATmega8 realizes the applications of PS/2 keyboard/mouse in the system

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

Codec. WM8731 Audio Codec

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

DESIGNING OF INTER INTEGRATED CIRCUIT USING VERILOG

VORAGO VA108x0 I 2 C programming application note

Functional block diagram AD53x1 (Analog Devices)

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

Errata Sheet RV-8803-C7

1.3inch OLED User Manual

CAN / RS485. Product Description. Technical Reference Note. Interface Adapter. Special Features

Exercise 2 I 2 C Management 1/7

Data Acquisition From Capacitance Sensor AD7746 To Central Monitoring System Using I 2 C Protocol

I2C BUS SERIAL EEPROM

I2C. I2C, sometimes IIC or I 2 C, stands for inter IC. 2-line bus, clock (SCL) and data (SDA) Devices individually addressable

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

CprE 488 Embedded Systems Design. Lecture 4 Interfacing Technologies

THE INTERNATIONAL JOURNAL OF SCIENCE & TECHNOLEDGE

User s Guide. IP-201 I2C Bus Multiplexer Board Revision 1. Micro Computer Control Corporation

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

18-349: Introduction to Embedded Real-Time Systems

Raspberry Pi - I/O Interfaces

ECE 4510/5530 Microcontroller Applications Week 10

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

Embedded Workshop 10/28/15 Rusty Cain

SILICON MICROSTRUCTURES

ArduCAM USB Camera SDK

RX Family APPLICATION NOTE. I 2 C Bus Interface (RIIC) Module Using Firmware Integration Technology. Introduction. Target Device.

Hello, and welcome to this presentation of the STM32 I²C interface. It covers the main features of this communication interface, which is widely used

I2C interface Tutorial

Serial Peripheral Interface (SPI)

Microcontrollers and Interfacing week 10 exercises

Two Wire Interface (TWI) also commonly called I2C

FPGA Implementation Of SPI To I2C Bridge

17. Serial communication - I 2 C

Using the I 2 C Interface on the ATmega328P and MC908JL16

Lesson I2C. I²C (Inter-Integrated Circuit) Lab Assignment: I2C Slave Driver

F28335 I2C MODULE v1.1

Emulating I2C Bus Master by using FlexIO

Inter-Integrated Circuit Bus IIC I2C TWI

Fully Integrated Thermal Accelerometer MXC6225XU

LCD Module with I2C / Serial Interface and Keypad Control «LCD I2C/Serial» User s Guide. Copyright 2008 IMS

Specification E2 Interface

Sten-SLATE ESP. Accelerometer and I2C Bus

RX Family APPLICATION NOTE. Simple I 2 C Module Using Firmware Integration Technology. Introduction. Target Device.

ArduCAM USB Camera SDK

I 2 C Slave Controller. I 2 C Master o_timeout_intr

RL78 Serial interfaces

or between microcontrollers)

Digital Temperature and Humidity Sensor

I2C a learn.sparkfun.com tutorial

Add a Non-Volatile Clock to the MC68HC705J1A. Some applications of using the DS1307 are:

Application note Differential Pressure Sensor Type D6F-PH (Rev 1.0)

2-Wire, 5-Bit DAC with Three Digital Outputs

ADC to I 2 C. Data Sheet. 10 Channel Analog to Digital Converter. with output via I 2 C

I 2 C Application Note in Protocol B

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

Growing Together Globally Serial Communication Design In Embedded System

An Efficient Designing of I2C Bus Controller Using Verilog

ArduCAM-M-5MP Camera Shield

Global GPS NMEA over I²C Software Guide V 1.2

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

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

DESIGN OF WISHBONE INTERFACED I2CMASTER CORE CONTROLLER USING VERILOG

Application Note. Utilising the E2 Interface

By: Haron Abdel-Raziq

Theory of Operation STOP CONDITION

LABORATORIO DI ARCHITETTURE E PROGRAMMAZIONE DEI SISTEMI ELETTRONICI INDUSTRIALI. Laboratory Lesson 9: Serial Peripheral Interface (SPI)

MPX-24794S Serial USB Card

The I2C controller supports only Master function. It supports the 7-bits/10-bits addressing mode and support general call address. The maximum clock f

8. Networks. Why networked embedded systems General network architecture. Networks. Internet-enabled embedded systems Sensor networks

USB-910H API DLL and Include File Reference Manual

Transcription:

The I 2 C BUS Interface ARSLAB - Autonomous and Robotic Systems Laboratory Dipartimento di Matematica e Informatica - Università di Catania, Italy santoro@dmi.unict.it L.S.M. 1 Course

What is I 2 C? I 2 C Bus or IIC Bus is the acronym for Inter-Integrated Circuit Bus. It is a standard digital communication bus designed to interconnect integrated circuits belonging to the same board. It has been introduced by Philips to interconnect integrated circuits in TV-sets in the 80s in the transition from discrete transistors to integrated-circuits. The bus has been initially used in TV-sets and VCRs, and then widely adopted in any integrated device which needs data communication.

I 2 C BUS: Philosophy and Connections I 2 C has a two wires bus which interconnect all devices Devices in a I 2 C network has a role: Master, is the head of the bus and has the responsibility of starting a communication; only one master can be present in a I 2 C network and is - in general - a MCU; Slave, all the other devices which respond to master solicitations.

I 2 C BUS: Philosophy and Connections The I 2 C wires have the following meaning: SDA: Serial DAta, bidirectional; here data bits flow serially (one bit at time) SCL: Serial CLock, undirectional from master to slaves; it holds the timing of the transmission Therefore I 2 C is a synchronous interface which (according to standards) can reach the max speed of 400 Kbps

I 2 C Addressing I2C Master SDA SCL Accelerometer Address = 0xd6 Distance Sensor Address = 0x30 Color Sensor Address = 0x44 Each slave device in I 2 C has a well-know address The standard specifies two types of addresses: 7-bit, widely used 10-bit, used only in some special cases An additional bit (at B0) is added to the address to specify direction of transfer: 0 = write to slave device 1 = read from slave device Example: the accelerometer has address 0xd6: 1 1 0 1 0 1 1 0 = 0xd6 = write to accelerometer 1 1 0 1 0 1 1 1 = 0xd7 = read from accelerometer

I 2 C Addressing I2C Master SDA SCL Accelerometer Address = 0xd6 Name RegAddr Config1 0x00 Config2 0x01...... Data1 0x08 Data2 0x09 Each slave device has also a register map Each register is identified by a 8-bit address and a 8-bit value Each register is used to: Configure the device Send commands to the device Hold a sensed data etc. Each register can be read or written from the master through proper transaction protocols.

I 2 C Transaction Model A Write Transaction uses the following sequence: 1 Master sends the START CONDITION (S) 2 Master sends the device address (with B0 = 0) 3 Master sends the register number to be written 4 Master sends the register data to be written 5 Previous point is repeated for each subsequent register to be written 6 Master sends the STOP CONDITION (P) For each written byte, the Slave replies with an ACKNOWLEDGE, that is a bit 0 sent over SDA line

I 2 C Transaction Model A Read Transaction uses the following sequence: 1 Master sends the START CONDITION (S) 2 Master sends the device address (with B0 = 0) 3 Master sends the register number to be read 4 Master sends a new START CONDITION (S) 5 Master sends the device address (with B0 = 1) 6 Salve sends the register data read 7 Previous point is repeated for each subsequent register to be read 8 Master sends the STOP CONDITION (P) For each byte transmitted over SDA, the peer device (Master or Slave) replies with an ACKNOWLEDGE, that is a bit 0 sent over SDA line

I 2 C: Timing and Bus States BUS IDLE, both SDA and SCL lines are in 1 state. START CONDITION (S) A transition high-to-low in SDA, while SCL is high, is a Start Condition It is used to start communication on the bus It is always initiated by the Master

I 2 C: Data Transfer Data transfer occurs serially MSB-first: 1 The bit value is set on the SDA line 2 A pulse low-to-high-to-low occurs on the SCL line 3 The next bit is sent... After transmission of all the 8 bits, an acknowledge (ACK) is expected: 1 The master generates a 9 th clock pulse 2 The receiving device holds the SDA line low to signal that it has understood the byte sent

I 2 C: Stop Condition When communication is over, a STOP CONDITION (P) is generated: A transition low-to-high in SDA, while SCL is high, is a stop condition It is used to stop any communication on the bus It is always made by the Master After a Stop Condition, the bus goes in the Idle state.

Sending Data to a Slave Device First the Master initiates communication with a Start Condition The Master sends the Write Command, a 8-bit data, composed of: The 7-bit address of the Slave device The R/W bit at 0, which means write-to-slave The addressed Slave acks, by holding SDA line low in the 9 th clock pulse If no Slave exists at that address, the SDA line will remain to high, thus indicating a NACK; this situation is recognised by the Master which stops communication.

Sending Data to a Slave Device After the address, the Master sends a 8-bit data which has the meaning of register number The addressed Slave acks data, by holding SDA line low in the 9 th clock pulse Then the Master sends a 8-bit data which has the meaning of register value The addressed Slave acks data, by holding SDA line low in the 9 th clock pulse The Master closes the transmission by sending a Stop Condition

Receiving Data from a Slave Device First the Master initiates communication with a Start Condition The Master sends the Write Command, a 8-bit data, composed of: The 7-bit address of the Slave device The R/W bit at 0, which means write-to-slave The addressed Slave acks, by holding SDA line low in the 9 th clock pulse

Receiving Data from a Slave Device After the address, the Master sends a 8-bit data which has the meaning of register number The addressed Slave acks data, by holding SDA line low in the 9 th clock pulse The Master sends a new Start Condition. The Master sends the Read Command, a 8-bit data, composed of: The 7-bit address of the Slave device The R/W bit at 1, which means read-from-slave The addressed Slave acks, by holding SDA line low in the 9 th clock pulse

Receiving Data from a Slave Device Slave device is now ready to send bytes The Slave sends a 8 bit data value The Master acks, by holding SDA line low in the 9 th clock pulse The Slave sends the next 8 bit data value (next register value) The Master acks, by holding SDA line low in the 9 th clock pulse When the Master is no more interested to data, it closes the communication by sending a NACK (holding SDA line high in the 9 th clock pulse) and then a Stop Condition.

The I2C functions of the stm32 unict lib Initialize the I2C interface: void I2C init(i2c TypeDef * port, int speed); port, the interface (usually I2C1) speed, clock speed (e.g. 100000, 400000)

The I2C functions of the stm32 unict lib Write a single register: void I2C write register(i2c TypeDef * port, short addr, short reg adr, short reg val); port, the interface (usually I2C1) addr, device address reg adr, register address reg val, register value Read a single register: void I2C read register(i2c TypeDef * port, short addr, short reg adr, short * reg val); port, the interface (usually I2C1) addr, device address reg adr, register address reg val, pointer to the variable that will receive register value

The I2C functions of the stm32 unict lib Write a set of registers: void I2C write buffer(i2c TypeDef * port, short addr, short reg adr, unsigned char * data, int len); port, the interface (usually I2C1) addr, device address reg adr, register address data, the buffer holding register values len, the buffer length (number of registers) Read a set of registers: void I2C read buffer(i2c TypeDef * port, short addr, short reg adr, unsigned char * data, int len); port, the interface (usually I2C1) addr, device address reg adr, register address data, the buffer that will receive register values len, the buffer length (number of registers)

The I 2 C BUS Interface ARSLAB - Autonomous and Robotic Systems Laboratory Dipartimento di Matematica e Informatica - Università di Catania, Italy santoro@dmi.unict.it L.S.M. 1 Course