AN1146 STMicroelectronics, AN1146 Datasheet

no-image

AN1146

Manufacturer Part Number
AN1146
Description
I2C COMMUNICATION BETWEEN ST52X301 AND EEPROM
Manufacturer
STMicroelectronics
Datasheet
AN1146
APPLICATION NOTE
®
2
I
C Communication between ST52x301 and EEPROM
Authors: V. Marino, C. Vinci
1. Introduction
This application note shows an example of how to use ST52x301 to communicate with an EEPROM
2
memory with an I
C bus protocol. In this example, an M24C04 EEPROM (4K bit) is taken into account,
but the following considerations can be applied to applications with any kind of M24CXX memory.
Two software routines are proposed, the Byte Write and the Random Read Access, for ST52x301
microcontroller configured in single master communication.
2. Communicating Protocol
The M24CXX is an EEPROM supporting the I²C protocol. The M24CXX can communicate with a
microcontroller, the master, only by a serial data I/O line (SDA) and a serial clock (SCL).
During each data transfer, the M24CXX samples the SDA bus signal on the rising edge of the clock
signal SCL. The SDA signal must be stable during the clock low to high transition and the data must
change only when the SCL line is low. Changes in the data line while the clock is high are interpreted
as a START and STOP conditions.
START is identified by a high to low transition of the SDA line while the clock is stable in the high state.
A START condition must precede any data transfer command.
After the START, ST52x301 sends onto the SDA bus line 8 bits (MSB first): the first 7 bits to select the
device, the last (RW bit) to indicate if it is a read (RW high) or write (RW low) operation.
After sending each 8 bits data stream, the master releases the SDA bus; during the 9th clock pulse
period the receiver pulls the SDA bus low to acknowledge the receipt of the 8 bit data. A complete data
transfer is always terminated by a STOP, identified by a low to high transition of the SDA line while the
clock SCL is stable in the high state.
2
Fig. 1 - I
C Bus Protocol
June 1999
1/14

Related parts for AN1146

AN1146 Summary of contents

Page 1

... SDA bus low to acknowledge the receipt of the 8 bit data. A complete data transfer is always terminated by a STOP, identified by a low to high transition of the SDA line while the clock SCL is stable in the high state. 2 Fig Bus Protocol June 1999 AN1146 APPLICATION NOTE Authors: V. Marino, C. Vinci 1/14 ...

Page 2

... AN1146 - APPLICATION NOTE 3. Hardware Description The connection scheme between ST52x301 and EEPROM is shown in Figure 2. Pin P0 of ST52x301 is used to transfer data to and from the memory (SDA); pin P8 for data syncronization (SCL). In this scheme M24C04 inputs E0, E1 and E2 are tied to Vss (Device Select Code is A0h), therefore, being E0 low, only 256 byte of memory, the low part, can be addressed ...

Page 3

Random Address Read Mode In order to read a byte from an address of the memory, ST52x301 performs a dummy write to load the address, as shown in figure 4. Then, without sending a STOP condition, ST52x301 sends another ...

Page 4

... AN1146 - APPLICATION NOTE 4.1 Byte Write software routine The main flow chart program of ST52x301 Wryte Byte routine, as developed in FUZZYSTUDIO environment, is shown in Figure 5. After the block ‘ initialize ’, where the communication speed, the address and the value of the byte to write are set, the START condition is performed in the block ‘ start bit ’. ...

Page 5

This block performs the START condition: at first, the SDA line is pulled in high state through sending of the number ‘1’ into the parallel port (block ‘data_high’); then the SCL line is pulled high by setting ...

Page 6

... AN1146 - APPLICATION NOTE 4.1.4 ‘Ack’ block After sending 8 bits data, ST52x301 releases the SDA bus, setting the pin P0 in input. REG_CONF0 is used to set each pin of the parallel port in input or in output. During the 9-th clock pulse period, the EEPROM pulls the SDA bus low to acknowledge reception of the data byte: the byte read onto ST52x301 parallel port is stored into an ‘ ...

Page 7

A data transfer is always terminated by a STOP condition, that is identified by a low to high transition of the SDA line while the clock SCL is stable in the high state. This condition is performed ...

Page 8

... AN1146 - APPLICATION NOTE 4.2.1 ‘Read_data’ block To read the eigth bit data sent from the memory, ST52x301 performs a cycle scanned by a variable ‘ cont ’: at each step ‘cont’ is incremented from and one bit of the data is received into pin P0 (block ‘Receive0’) after the rising edge of the clock SCL (pin P8 of ST52x301). ...

Page 9

Appendix 1 Bit_byte Assembler Block This block is designated to write the data byte into the memory; the data is composed of eigth bits, then, in order to write it, a cycle of eight steps is realized (Fig.7). At the ...

Page 10

... AN1146 - APPLICATION NOTE 10/16 ...

Page 11

I C COMMUNICATION BETWEEN ST52x301 AND EEPROM 11/14 ...

Page 12

... AN1146 - APPLICATION NOTE Appendix 2 Bit_data Assembler Block This block is designated to read the data from the memory; the data is composed of eigth bits, then, in order to read it, a cycle of eigth step is realized(Fig.11). At the first step the cycle counter ‘ cont ’ is zero, then the intruction ‘ data-bit7 ’ is executed and the program jumps to label ‘ ...

Page 13

I C COMMUNICATION BETWEEN ST52x301 AND EEPROM 13/14 ...

Page 14

... AN1146 - APPLICATION NOTE Information furnished is believed to be accurate and reliable. However, STMicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted by implication or otherwise under any patent or patent rights of STMicroelectronics. Specification mentioned in this publication are subject to change without notice ...

Related keywords