AN2672 Application note

Similar documents
AN2667 Application note

AN2676 Application note

STEVAL-CCM002V1. TFT-LCD panel demonstration board based on the STM32 as LCD controller. Features. Description

AN4113 Application note

STEVAL-SPBT4ATV3. USB dongle for the Bluetooth class 1 SPBT2632C1A.AT2 module. Features. Description

AN2737 Application note Basic in-application programming example using the STM8 I 2 C and SPI peripherals Introduction

AN626 Application note

AN3996 Application Note

AN2673 Application note

STEVAL-PCC010V1. ST802RT1A Ethernet PHY demonstration board with STM32F107 controller add-on board. Features. Description

STM32-MP3NL/DEC. STM32 audio engine MP3 decoder library. Description. Features

AN2855 Application note

AN2470 Application note TS4871 low voltage audio power amplifier Evaluation board user guidelines Features Description

STTS V memory module temperature sensor. Features

AN2143 Application note

UM0401 User manual. User manual for eight bit port expander STMPE801 demonstration board. Introduction

STM8 I 2 C optimized examples

AN3279 Application Note

UM0792 User manual. Demonstration firmware for the DMX-512 communication protocol transmitter based on the STM32F103Zx.

EV-VNQ5E050AK VNQ5E050AK evaluation board

UM1572 User manual. STEVAL-IPE020V1: ST energy meter application based on the Android platform. Introduction

AN3250 Application note

STM3210B-SK/KEIL STR91X-SK/KEI, STR7-SK/KEIL

AN2261 APPLICATION NOTE

AN3354 Application note

ST19NP18-TPM-I2C Trusted Platform Module (TPM) with I²C Interface Features

EVAL6235PD. L6235 three-phase brushless DC motor driver demonstration board. Features. Description

OSPlus USB Extension. OSPlus USB 2.0 extension. Description. Features. Application. TCP/IP stack NexGenOS NexGenIP VFS. FAT Ext2 LVM Device layer

ST19WR08 Dual Contactless Smartcard MCU With RF UART, IART & 8 Kbytes EEPROM Features Contactless specific features

STM32-SK/KEIL STR91X-SK/KEI, STR7-SK/KEIL

UM0693 User manual. 1 Introduction. STM8L101-EVAL demonstration firmware

AN2240 Application note

AN2474 Application note

AN3154 Application note

AN2825 Application Note

AN3965 Application note

STLC2500D. Bluetooth V2.1 "Lisbon" + EDR. Features. Description

AN3980 Application note

STA bit single chip baseband controller for GPS and telematic applications. Features

STM3220G-SK/KEI. Keil starter kit for STM32F2 series microcontrollers (STM32F207IG MCU) Features. Description

UM1488 User manual. STPMC1 evaluation software. Introduction

AN2361 Application note

AN2734 Application note S-Touch design procedure Introduction

SOT23-6L ESDALCL6-2SC6

ST33F1M. Smartcard MCU with 32-bit ARM SecurCore SC300 CPU and 1.25 Mbytes high-density Flash memory. Features. Hardware features.

AN2592 Application note

STEVAL-IHM028V1. 2 kw 3-phase motor control demonstration board featuring the IGBT intelligent power module STGIPS20K60. Features.

STICE CF/Stice_Connect AD/Stice_Connect AS/Stice_Connect

STM32-SK/RAIS,STR91X-SK/RAI,STR7-SK/RAIS STM32-D/RAIS,STR9-D/RAIS,STR7-D/RAIS

Main components USB charging controller with integrated power switch

Main components 1 A, high efficiency adjustable single inductor dual mode buckboost DC-DC converter

AN2408 Application note

AN2557 Application note

ST21NFCB. Near field communication controller. Features. RF communications. Hardware features. Communication interfaces. Electrical characteristics

AN2202 Application note

AN3001 Application note

AN2792 Application note

EMIF01-SMIC01F2 IPAD. Single line EMI filter including ESD protection. Main application. Description. Benefits. Pin configuration (Bump side view)

EMIF02-MIC01F2 2-line IPAD, EMI filter including ESD protection Features Application Description Complies with the standards:

AN2594 Application note

AN3265 Application note

Obsolete Product(s) - Obsolete Product(s)

EMIF02-SPK02F2. 2-line IPAD, EMI filter and ESD protection. Features. Application. Description. Complies with the following standards

AN2781 Application note

STM32 embedded target for MATLAB and Simulink release 3.1. Summary for STM32 embedded target for MATLAB and Simulink release 3.1:

Description SPC564A-DISP. March 2014 DocID Rev 3 1/5

UM1084 User manual. CR95HF development software user guide. Introduction. Reference documents

TN0189 Technical note

Getting started with DfuSe USB device firmware upgrade STMicroelectronics extension

AN4274 Application note

AN4321 Application note

SMP75. Trisil for telecom equipment protection. Features. Description. Applications. Benefits

STMicroelectronics. STxP70-4 assembler. User manual Rev A. October

STM8-SK/RAIS STM8-D/RAIS ST7-SK/RAIS ST7-D/RAIS

AN3362 Application note

ST33F1M, ST33F1M0, ST33F896, ST33F768, ST33F640, ST33F512

LD A very low drop adjustable positive voltage regulator. Description. Features

AN2430 Application note

TN0132 Technical note

AN3988 Application note

RN0046 Release note. 1 Introduction. SimpleMAC library for STM32W108xx kits. About this release note

AN2768 Application note LIS331DL 3-axis digital MEMS accelerometer: translates finger taps into actions Introduction

ST10F271B/E, ST10F272B/E Errata sheet

AN3174 Application note


AN3140 Application note

AN4440 Application note

Description of STM8 LIN software package (STSW-STM8A-LIN) release 4.1. Table 1. Release information. STM8 LIN package

AN2860 Application note

STM8L-PRIMER STM32-PRIMER STMPRIMER

b. Typical values, independent of external clock frequency and supply voltage. a. TCG website:

AN4308 Application note

AN3099 Application note

AN3991 Application note

L6460. SPI configurable stepper and DC multi motor driver. Features. Description

AN3975 Application note

AN2442 Application note

AN3155 Application note

UM0212 User manual. STOTG04 USB OTG full-speed transceiver demonstration board. Introduction

EMIF03-SIM06F3. 3-line IPAD, EMI filter including ESD protection. Description. Features. Application. Complies with the following standards:

Transcription:

Application note I²C application examples Introduction The I 2 C peripheral is very flexible, supporting standard interrupts in both 10-bit and 7-bit addressing modes. As a result, generated events are easier to check and manage. The I 2 C peripheral can also be interfaced with an EEPROM driver which allows greater and more complex communication. This application note is intended to provide five practical application examples of how to use the I 2 C peripheral in devices. The examples are: Aardvark TM I²C - I²C communication using interrupts in 7-bit addressing mode I 2 C - I 2 C communication in 10-bit addressing mode Three examples of I 2 C and MC24C64 EEPROM communication For further information on the family features, pinout, electrical characteristics, mechanical data and ordering information, please refer to the F51xx, F61xx datasheet. For further details on the MC24C64 EEPROM, please consult M24128, M24C64, M24C32 datasheet. This document, its associated firmware, and other such application notes are written to accompany the STM8 firmware library. Please contact STMicroelectronics for information on the STM8 firmware library. June 2008 Rev 2 1/7 www.st.com

Contents AN2672 Contents 1 Aardvark I²C - I²C communication using interrupts in 7-bit addressing mode............................................ 3 1.1 Overview.................................................. 3 1.2 Hardware description......................................... 3 1.3 Firmware description......................................... 3 2 I 2 C - I 2 C communication in 10-bit addressing mode........ 4 2.1 Overview.................................................. 4 2.2 Hardware description......................................... 4 2.3 Firmware description......................................... 4 3 I 2 C and MC24C64 EEPROM communication............... 5 3.1 Overview.................................................. 5 3.2 Hardware description......................................... 5 3.3 Firmware description......................................... 5 4 Revision history............................................ 6 2/7

Aardvark I²C - I²C communication using interrupts in 7-bit addressing mode 1 Aardvark I²C - I²C communication using interrupts in 7-bit addressing mode 1.1 Overview This section describes how to set an I²C - I²C communication from a master transmitter to a slave receiver, using interrupts in 7-bit addressing mode and a clock speed of 100 khz. In the current example, the master I 2 C is an Aardvark external module which emulates the I 2 C protocol. The slave receiver is an device. 1.2 Hardware description Figure 1 shows a typical connection between an Aardvark module used as an I²C interface and an I²C. The Ardvark I²C and device I²C data pins (SDA) and clock pins (SCL) are connected together. A pull-up resistor is connected to each SDA and SCL line. Figure 1. Ardvark I 2 C - I 2 C communication Master Slave Aardvark module ai15022b 1.3 Firmware description The STM8 firmware library includes the I²C driver that supports all I²C communication through a set of functions. The current example is provided as I²C example 4 in the STM8 firmware library. Before enabling the I 2 C peripheral, it has to be configured in 7 bit addressing mode, with a clock speed of 100 khz. The event and buffer interrupts must then be configured to manage the communication. Acting as master, the Aardvark module generates a start condition, and sends the slave address. For data transfer to begin, the slave must acknowledge this address. The Aardvark I 2 C Tx_Buffer is transmitted to the slave and stored in the I 2 C Rx_Buffer. All comminication events are managed in the I 2 C interrupt routine. When data transfer ends, the master generates a stop condition. 3/7

I 2 C - I 2 C communication in 10-bit addressing mode AN2672 2 I 2 C - I 2 C communication in 10-bit addressing mode 2.1 Overview This section describes how to set an I 2 C - I 2 C communication in 10-bit addressing mode with a clock speed of 200 khz. 2.2 Hardware description Figure 2 shows a typical connection between two I 2 Cs. The I 2 C data pins (SDA) and clock pins (SCL) of the master and slave are connected together. A pull-up resistor is connected to each SDA and SCL line. Figure 2. I 2 C - I 2 C communication Master Slave ai15023b 2.3 Firmware description The current example is provided as I²C example 5 in the STM8 firmware library. Before enabling both I 2 C peripherals (which represent master and slave), they have to be configured in 10-bit addressing mode, with a clock speed of 200 khz. The event and buffer interrupts must then be enabled to manage the communication. The master I 2 C generates a start conditon, and after slave address acknowledgement, data transfer in 10-bit addressing mode begins. The Tx_Buffer is transmitted from the master to the slave and stored in the Rx_Buffer. Each master or slave event is managed in the master or slave I 2 C interrupt routine respectively. Transmitted and received buffers are compared to check that data have been correctly transferred. 4/7

I 2 C and MC24C64 EEPROM communication 3 I 2 C and MC24C64 EEPROM communication 3.1 Overview This section describes how to use the I 2 C to communicate with an M24C64 EEPROM. The given example uses most of the I 2 C EEPROM functionality. 3.2 Hardware description Figure 3 shows a typical connection between an I 2 C and an MC24C64 EEPROM. The data pins (SDA) and clock pins (SCA) of the I 2 C and the M24C64 EEPROM are connected together. A pull-up resistor is connected to each SDA and SCL line. The E2, E1, E0, and V SS EEPROM pins are tied to ground and the V CC EEPROM pin is connected to 5 V. Figure 3. I 2 C and M24C64 EEPROM communication SDA SCL V CC E0 EI E2 V SS MC24C64 ai15024b 3.3 Firmware description The STM8 firmware library includes three examples that support all read and write operations through a set of commands. Each example is performed in 7-bit addressing mode with a clock speed of 400 khz. The examples are provided as I²C examples 1, 2, and 3 in the STM8 firmware library. Example 1 shows how to perform a sequential read in the EEPROM Example 2 shows how to perform a random read in the MC24C64 Example 3 shows how to: Write the content of Tx_Buffer Read the content of Tx_Buffer and store it in Rx_Buffer Compare the content of Tx_Buffer and Rx_ Buffer 5/7

Revision history AN2672 4 Revision history Table 1. Document revision history Date Revision Changes 19-Mar-2008 1 Initial release 11-Jun-2008 2 Removed all references to the standard and light versions of the STM8 6/7

Please Read Carefully: Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries ( ST ) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice. All ST products are sold pursuant to ST s terms and conditions of sale. Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no liability whatsoever relating to the choice, selection or use of the ST products and services described herein. No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein. UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY, DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK. Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any liability of ST. ST and the ST logo are trademarks or registered trademarks of ST in various countries. Information in this document supersedes and replaces all information previously supplied. The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners. 2008 STMicroelectronics - All rights reserved STMicroelectronics group of companies Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan - Malaysia - Malta - Morocco - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America www.st.com 7/7