I 2 C bus (Inter-Integrated Circuit)

Similar documents
AN2824 Application note

The I2C Bus. NXP Semiconductors: UM10204 I2C-bus specification and user manual HAW - Arduino 1

NB3H5150 I2C Programming Guide. I2C/SMBus Custom Configuration Application Note

Elettronica dei Sistemi Digitali Costantino Giaconia SERIAL I/O COMMON PROTOCOLS

Hello, and welcome to this presentation of the STM32 SDMMC controller module. It covers the main features of the controller which is used to connect

AN141 SMBUS COMMUNICATION FOR SMALL FORM FACTOR DEVICE FAMILIES. 1. Introduction. 2. Overview of the SMBus Specification. 2.1.

USB2.0 <=> I2C V4.4. Konverter Kabel und Box mit Galvanischetrennung

AND8336. Design Examples of On Board Dual Supply Voltage Logic Translators. Prepared by: Jim Lepkowski ON Semiconductor.

Serial port interface for microcontroller embedded into integrated power meter

UM I 2 C-bus specification and user manual. Document information

DS1621 Digital Thermometer and Thermostat

AVR315: Using the TWI Module as I2C Master. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

I 2 C Master Mode Overview and Use of the PICmicro MSSP I 2 C Interface with a 24xx01x EEPROM

Atmel Norway XMEGA Introduction

AVR311: Using the TWI Module as I2C Slave. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

Next Generation Intelligent LCDs

Software User Guide UG-461

DS1307ZN. 64 x 8 Serial Real-Time Clock

Hello, and welcome to this presentation of the STM32 Serial Audio Interface. I will present the features of this interface, which is used to connect

Serial Communications

DS1621 Digital Thermometer and Thermostat

AN736. An I 2 C TM Network Protocol for Environmental Monitoring THE I 2 C BUS SPECIFICATION INTRODUCTION

SPI I2C LIN Ethernet. u Today: Wired embedded networks. u Next lecture: CAN bus u Then: wireless embedded network

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

Section 24. Inter-Integrated Circuit (I 2 C )

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

Web Site: Forums: forums.parallax.com Sales: Technical:

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

Hello, and welcome to this presentation of the STM32L4 reset and clock controller.

THE I 2 C-BUS SPECIFICATION VERSION 2.1 JANUARY document order number:

DS Wire Digital Thermometer and Thermostat

Implementing SPI Master and Slave Functionality Using the Z8 Encore! F083A

Microprocessor & Assembly Language

Definitions and Documents

Chapter 13. PIC Family Microcontroller

Raspberry Pi. Hans- Petter Halvorsen, M.Sc.

The I 2 C-bus and how to use it (including specifications)

Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

Welcome to the Introduction to Controller Area Network web seminar My name is William Stuart, and I am a Applications Engineer for the Automotive

Below is a diagram explaining the data packet and the timing related to the mouse clock while receiving a byte from the PS-2 mouse:

Arbitration and Switching Between Bus Masters

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

Computer Systems Structure Input/Output

ARM Thumb Microcontrollers. Application Note. Software ISO 7816 I/O Line Implementation. Features. Introduction

- 35mA Standby, mA Speaking pre-defined phrases with up to 1925 total characters.

The FT6x06 series ICs include FT6206 /FT6306, the difference of their specifications will be listed individually in this datasheet.

FM75 Low-Voltage Two-Wire Digital Temperature Sensor with Thermal Alarm

29035 Laboratorio di ARCHITETTURE E PROGRAMMAZIONE DEI SISTEMI ELETTRONICI INDUSTRIALI T-A

USER GUIDE EDBG. Description

7 OUT1 8 OUT2 9 OUT3 10 OUT4 11 OUT5 12 OUT6 13 OUT7 14 OUT8 15 OUT9 16 OUT10 17 OUT11 18 OUT12 19 OUT13 20 OUT14 21 OUT15 22 OUT16 OUT17 23 OUT18

A DIY Hardware Packet Sniffer

Serial Communications

MODULE BOUSSOLE ÉLECTRONIQUE CMPS03 Référence :

Local Interconnect Network Training. Local Interconnect Network Training. Overview

Objectives. Basics of Serial Communication. Simplex vs Duplex. CMPE328 Microprocessors (Spring ) Serial Interfacing. By Dr.

Chapter 02: Computer Organization. Lesson 04: Functional units and components in a computer organization Part 3 Bus Structures

AN4646 Application note

AN111: Using 8-Bit MCUs in 5 Volt Systems

Internal Oscillator. I 2 C Interface. SPI Interface. Controller. Internal Registers Port Controller. Eight I/O Pins. Figure 1.

HDMM01 V1.0. Dual-axis Magnetic Sensor Module With I 2 C Interface FEATURES. Signal Path X

RS-485 Protocol Manual

ARM Cortex STM series

Allows the user to protect against inadvertent write operations. Device select and address bytes are Acknowledged Data Bytes are not Acknowledged

TDA CHANNEL VOLUME CONTROLLER 1 FEATURES 2 DESCRIPTION. Figure 1. Package

SafeSPI - Serial Peripheral Interface for Automotive Safety

LIN (Local Interconnect Network):

Embedded Systems Design Course Applying the mbed microcontroller

TURBO PROGRAMMER USB, MMC, SIM DEVELOPMENT KIT

Designing VM2 Application Boards

User Manual. AS-Interface Programmer

Lesson 16 Analog-to-Digital Converter (ADC)

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: EC Microprocessor & Microcontroller Year/Sem : II/IV

Wireless Temperature

What is a bus? A Bus is: Advantages of Buses. Disadvantage of Buses. Master versus Slave. The General Organization of a Bus

The Secrets of RS-485 Half-duplex Communication

Figure 1.Block diagram of inventory management system using Proximity sensors.

AN601 I2C 2.8 Communication Protocol. SM130 SM130 - Mini APPLICATION NOTE

ES_LPC4357/53/37/33. Errata sheet LPC4357/53/37/33. Document information

Application Note 132. Introduction. Voice Video and Data Communications using a 2-Port Switch and Generic Bus Interface KSZ MQL/MVL

RS-422/485 Multiport Serial PCI Card. RS-422/485 Multiport Serial PCI Card Installation Guide

2.488Gbps Compact Bi-Di SFP Transceiver, 20km Reach 1490nm TX / 1310 nm RX

MicroMag3 3-Axis Magnetic Sensor Module

Programming Interface. for. Bus Master IDE Controller. Revision 1.0

The Programming Interface

STM32 F-2 series High-performance Cortex-M3 MCUs

LINDY ELECTRONICS LIMITED & LINDY-ELEKTRONIK GMBH - SECOND EDITION

Dolphin In-Circuit programming Updating Firmware in the field

Connecting Kinetis MCU with CMOS Sensor Interface through GPIO QQVGA image transfer to Kinetis internal SRAM

A Transport Protocol for Multimedia Wireless Sensor Networks

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

AN3998 Application note

PART B QUESTIONS AND ANSWERS UNIT I

USING I2C WITH PICAXE

Distributed Real-Time Systems (TI-DRTS) Track 2. CAN-BUS Introduction. Version Ref. VECTOR application note & Motorola note

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

Bluetooth Audio Data Transfer between Bluetooth chipset (PMB6752&PMB6625) and TriCore Host TC1920

SC18IS602B. 1. General description. 2. Features and benefits. 3. Applications. I 2 C-bus to SPI bridge

RDF1. RF Receiver Decoder. Features. Applications. Description. Ordering Information. Part Number Description Packages available

Arduino Due Back. Warning: Unlike other Arduino boards, the Arduino Due board runs at 3.3V. The maximum. Overview

Transcription:

I 2 C bus (Inter-Integrated Circuit) Designed for low-cost, medium data rate applications. (Phillips Semiconductor, 1980s) Tutorial: http://www.esacademy.com/faq/i2c/ Characteristics: serial, byte-oriented; multiple-master; fixed-priority arbitration; moderate speeds: standard mode: 100Kbits/s fast mode: 400Kbits/s high speed mode: 3.4 Mbits/s Many microcontrollers come with built-in I 2 C controllers. Serial Buses Information Page: http://www.epanorama.net/links/serialbus.html

I 2 C data link layer Every device has an address Set by device and/or system designer. 7 bits in standard (10 bits in extension). Bit 8 of address signals read (1) or write (0). General call address (0000000) for broadcast. Bus transaction = series of one-byte transmissions Master sends slave address followed by data to or from slave. Good for data-push programming.

I 2 C physical layer Uses only two wires (plus ground) SDL SCL master 1 master 2 data line clock line slave 1 slave 2

I 2 C electrical interface (standard & fast speeds) Open collector/drain drivers (default state high) No global master for clock Source: I2C Specification

I 2 C signaling Bus = wired-and configuration Open collector/drain drivers on SDA & SCL Resistor pulls bus up to logic 1. Any sender can pull the bus down to 0, even if other senders are trying to drive the bus to 1. Sender releases SDA by disabling its driver, allowing SDA to be pulled up to logic 1 Data on SDA must be stable while SCL high Data on SDA is sampled while SCL is high SDA may change only while SCL low Exceptions: SDA 1->0 while SCL=1 signals START condition SDA 0->1 while SCL=1 signals STOP condition

I 2 C data format Start: SDA 1->0 while SCL=1 Stop: SDA 0->1 while SCL=1 SCL...... SDA MSB... ack start SDA stable while SCL=1 stop

Clock synchronization Master generates its own clock on SCL during data xfer Clock synchronization uses wired-and Driving low pulls SCL low, resetting all clock counters SCL remains low while any driver pulls it low SCL low time = slowest clock (others in wait states) First device to finish high state pulls SCL low Source: I2C Specification

Four I2C device operating modes Master-sender Module issues START and ADDRESS, and then transmits data to the addressed slave device Master-receiver Module issues START and ADDRESS, and receives data from the addressed slave device Slave-sender Another master issues START and the ADDRESS of this module, which then sends data to the master Slave-receiver Another master issues START and the ADDRESS of this module, which then receives data from the master. Some devices only support slave modes sensors, memories, etc.

I 2 C bus arbitration Master may start sending if bus free 2 or more may generate START at same time Sender listens while sending. Test SDA while SCL high Sender stops transmitting if arbitration lost Transmit 1 and hear 0 on SDA. Arbitration continues through address & ack bits, and then data & ack bits if necessary

Arbitration example Source: I2C Specification

Data transfer Send 8-bit byte (MSB first) Each byte followed by acknowledge bit master releases SDA line (high) during ack clock slave must pull SDA low for proper acknowledge if SDA left high, master may stop or repeat start if master is receiving from slave, slave releases SDA to allow master to pull SDA low for ack Slave can hold SCL low to force wait time between bytes

Basic data formats Master transmitting data to slave Master receiving data from slave

I 2 C transmissions (ACKs not shown) multi-byte write S adrs 0 data data P read from slave S adrs 1 data P write, then read S adrs 0 data S adrs 1 data P Re-start without giving up the bus

STM32 I 2 C Module (3 in STM32F407) Standard I 2 C compliant bus interface. All I 2 C bus-specific sequencing, protocol, arbitration, timing 7-bit and 10-bit addressing Standard ( 100KHz) or Fast ( 400KHz) speed modes Multi-master capability use as master or slave Also supports standards: SMBus (System Management Bus) PMBus (Power Management Bus) DMA support between memory and data register 2 interrupt vectors data transfer complete and errors

STM32 I 2 C Module Serial data Serial clock

STM32 I 2 C registers I2C_DR I 2 C data register byte to be transmitted (start on DR write) byte received (RxNE=1) I2C_OAR1 I 2 C own address register 1 ADDMODE 0 = 7-bit ADD[7:1] ; 1 = 10-bit ADD[9:0] (A second own address is also supported)

STM32 I 2 C control register 1 I2C_CR1 PE Peripheral function Enable (1 enables the I 2 C module) STOP Generate after current byte xfer or after start condition sent START Master: repeated start generation, Slave: release bus after byte xfer ACK ACK to be returned after byte received POS If ACK bit = 1: return ACK after current byte (0) or next byte (1) SWRST NOSTRETCH Software reset (or in reset state) Enable/disable clock stretch in slave mode when ADDR or BRG flag set, until reset by software ENGC Enable general call (ACK address 0x00) SMBUS 0 for I 2 C mode; 1 for SMBus mode (other bits for packet error checking (PEC) or SMBus setup)

SRM32 I 2 C control register 2 I2C_CR2 FREQ[5:0] = peripheral clock frequency (in MHz) allowed values [2MHz 42MHz] DMA Control: LAST: 1 = next DMA EOT is the last transfer DMAEN: 1 = DMA requests when TxE=1 or RxNE=1 Interrupt Control (interrupt generation events on next slide) ITBUFEN: 1 = TxE/RxNE event generates Event interrupt ITEVTEN: 1 = Event interrupt enabled ITERREN: 1 = Error interrupt enabled

STM32 I 2 C interrupts

STM32 I 2 C status register 1 (of two) I2C_SR1 ADDR: Master: 1= address sent Slave: 1= received address matched OAR register or gen call SB: Master: 1= Start generated (clear by reading SR1 & DR) TxE: 1= transmitter buffer (DR) empty (can send a new byte) RxNE: 1= receiver buffer (DR) not empty (byte has been received) BTF: 1= data byte transfer finished successfully RxNE=1 & DR not read yet; TxE=1 & DR not written yet ARLO: 1= arbitration lost detected (this device lost to another) STOPF: 1= slave detected stop condition after ACK OVR: 1= DR register overrun/underrun (data lost) AF: 1= ACK failure (no ACK returned) BERR: 1= bus error (misplaced Start/Stop condition) ADD10: 1= master sent 1 st byte of 10-bit address

STM32 I 2 C status register 2 I2C_SR2 BUSY: MSL: TRA: 1= communication ongoing on the bus (cleared by Stop) 0= slave mode (default) 1= master mode (START has been sent) From R/W address bit: 1= data bytes to be TRAnsmitted 0= data bytes to be received DUALF: Received address matches OAR1 (0) or OAR2 (1) GENCALL: General call address (0x00) received when ENARP=1 (Other bits for PEC or SMBus)

STM32 I2C bus events (from flags) Master modes: EV5: Start bit sent BUSY MSL SB EV6: Slave acknowledged address BUSY MSL ADDR EV8: DR ready for new byte to transmit BUSY MSL TXE (transmit buffer empty) EV9: new byte received in the DR BUSY MSL RXNE (receive buffer not empty)

STM32 I2C bus events (from flags) Slave modes: EV1: Own address received, data to be received from master BUSY ADDR (MSL=0, TRA=0) EV1: Own address received, data to be sent to master BUSY ADDR TRA (MSL=0) EV2: Slave byte received BUSY RNXE (receive buffer not empty) EV3: Slave byte transmitted BUSY TRA - TXE (transmit buffer empty) BUSY TRA TXE - BTF (transmit buffer empty and byte transfer finished)

I 2 C clock control register I2C_CCR F/S 0=standard mode ( 100KHz), 1=fast mode ( 400KHz) Standard Mode: T high = T low = CCR * T PCLK1 Fast Mode, DUTY = 0 T high = T low = CCR * T PCLK1 Fast Mode, DUTY = 1 (to reach 400KHz) T high = 9 * CCR * T PCLK1 T low = 16 * CCR * T PCLK1 Ex: To generate 100KHz SCL in standard mode. If FREQR = 08, T PCLK1 = 125ns Set CCR = 40 (0x28) T high = T low = 40*125ns = 5000ns FREQR in CR2

Hierarchical/modular software design Application API Codec driver Virtual uc to Codec link Codec registers I2C driver Virtual I2C link I2C module GPIO pins Replace Application/Codec with other functions that use I2C driver GPIO pins SCL SDA

STM32 I2C peripheral driver functions Configure control registers, etc. I2C_Init() initialize control registers, clock, etc. I2C_Cmd() enable the I2C module Other functions to set/clear individual control bits Bus management functions I2C_GenerateStart() signal START on the bus I2C_Send7bitAddress() send slave address I2C_GenerateStop() - signal STOP on the bus Data transfer functions I2C_SendData() send one byte to DR I2C_ReceiveData() get one byte from DR Bus monitoring functions I2C_CheckEvent() test status flags for a bus event I2C_GetFlagStatus() test one flag in status register

Typical master-to-slave transfer Codec_WriteRegister(RegAddr,RegValue) I2C_GetFlagStatus() check flag BUSY=0 I2C_GenerateStart() signal START on the bus I2C_CheckEvent() test EV5 flags (start correct) I2C_Send7bitAddress() send slave address I2C_CheckEvent() test EV6 flags (slave address ACK) I2C_SendData() send first byte (register address) to DR I2C_CheckEvent() test EV8 flags (data sending, DR ready for byte) I2C_SendData() send second byte (register value) to DR I2C_GetFlagStatus() check flag BTF=1 (byte transfer finished) I2C_GenerateStop() - signal STOP on the bus

Audio Code driver: key functions Codec_Init() all related device/module initialization: Codec_GPIO_Init() Enable clocks in RCC and all GPIO pins for I2C, I2S, DAC Codec_Reset() reset the Codec (RESET pin) Codec_CtrlInterface_Init() Calls I2C_Init() with required parameters Configure all Codec registers via I2C functions Codec_AudioInterfaceInit() Initialize DAC and I2S modules Codec_WriteRegister() write value to a code register Codec_ReadRegister() read value from a code register

STM32F4-Discovery Software STM32F407VG peripheral drivers added to project from Pack (I2C, SPI, DAC, etc.) stm32f4xx_i2c.c => all I2C control/access functions Discovery board chip drivers in..\stm32f4discovery_fw\utilities\stm32f4-discovery\ stm32f4_discovery_audio_codec.c Initialize and control audio codec chip Calls functions from I2C, I2S, GPIO, RCC module drivers

Cirrus Logic CS43L22 Portable Audio DAC with Integrated Class D Speaker Driver

Discovery CS43L22 schematic