Part Number Hot Search : 
5931B S1205 C705SP7S 5931B 6KE7V5 203411 AD7581L MAX453
Product Description
Full Text Search
 

To Download AN971 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  AN971/0102 1/7 AN971 application note i 2 c communication between st7 and m24cxx eeprom by microcontroller division application introduction the goal of this application note is to present an practical example of communication using the i 2 c peripheral of the st7. it shows a basic single master communication between a st7 mi- crocontroller and an m24cxx i 2 c bus eeprom. the purpose is to implement, from the st7 through the i 2 c interface, a write and a read to the external eeprom without error manage- ment. 1
2/7 i2c communication between st7 and m24cxx eeprom 1 st7 i 2 c interface the st7 i 2 c peripheral allows multi master and slave communication with bus error manage- ment. in this application, only single master mode is used without error management. as polling mode is the most difficult mode to implement, the application is based on this mode, but it can be easily adapted for interrupt management. the i 2 c synchronous communication needs only two signals: scl (serial clock line) and sda (serial data line). the corresponding port pins have to be configured as floating inputs. please refer to the st7 datasheet for more details. 1.1 communication speed the st7 i 2 c peripheral allows a large range of communication speeds. it is able to work in standard and fast i 2 c modes. in master mode the communication speed is given by the clock control register (ccr). an example is given in table 1 . table 1. example of possible i 2 c communication speeds (f cpu =8 mhz) 1.2 start, stop condition and acknowledge generation in master mode, the start and stop conditions can be generated by setting the start and stop bits in the control register (cr). an acknowledge is sent after an address or a data byte is received when the ack bit is set in the control register (cr). standard mode fast mode speed [khz] 15.5 25.00 50.00 70.00 100.00 167.00 190.00 333.00 ccr [hex] ec 9e 4e 37 26 8e 8c 86 2
3/7 i2c communication between st7 and m24cxx eeprom 2 st7 / m24cxx i 2 c communication application 2.1 hardware configuration the st7 / m24cxx i 2 c communication application hardware consists of a st72264 microcon- troller which communicates with an external m24c08 eeprom through an i 2 c bus interface. figure 1. st7 / eeprom i2c communications application 2.2 st7 i 2 c peripheral basic drivers in this chapter all registers refer to the st7 i 2 c peripheral (unless otherwise specified). 2.3 initialize the i 2 c peripheral in this application the initialization of the st7 i 2 c peripheral is done completely by software without taking into account the hardware reset status. first the control register (cr) is cleared and the data (dr) and status (sr1,sr2) registers are touched to clear any pending events. then, the peripheral is enabled through the control register (cr). this action needs to write twice in the register due to the fact that the control register (cr) bits can be set only when the pe enable bit is already set. to allow the peripheral to acknowledge the received data the ack bit of the control register (cr) is set. as the st24c08 eeprom is specified with a maximum i 2 c clock speed at 100khz, the st7 i 2 c peripheral is set to this speed (ccr=26h) in the application. st72264 i 2 c v dd v ss scl 5v 2x100 w sda 2x27k w m24c08 scl sda address=a0h e
4/7 i2c communication between st7 and m24cxx eeprom 2.4 initiating a communication on the i 2 c bus to initiate an i 2 c communication, first a start condition has to be generated and then the se- lected slave address has to be sent, both by the master. in the st7 i 2 c peripheral this action is done by setting the start bit of the control register (cr) followed by writing the slave address in the data register (dr) with the least significant bit correctly set (0 = transmission, 1 = reception). 2.5 sending a data byte on the i 2 c bus to transmit a new data byte from the st7 i 2 c peripheral on the i 2 c bus, the address or data byte previously transmitted has to be completed correctly. this previous byte transmission check is done by a polling loop on the btf flag of the status register 1 (sr1). if during this loop an error is detected in the status registers (sr1,sr2) then the application goes into an infinite loop (no error management). when the previous data transmission is over, the application writes the new data byte to be transmitted in the data register (dr). note: if the data byte to be transmitted is the first one after the slave address, a dummy write in the control register (cr) has to be performed to allow the setting of the btf bit (see st7 datasheet for more details). in this application, this dummy write is done by setting the pe bit for each data byte transmission (see description of ev6 in the transfer sequencing diagram in i 2 c datasheet description. 2.6 receiving a data byte on the i 2 c bus to receive a new data byte in the st7 i 2 c peripheral from the i 2 c bus, the data byte to receive has to be completed correctly. this byte reception check is done by a polling loop on the btf flag of the status register 1 (sr1). if during this loop an error is detected in the status regis- ters (sr1, sr2) then the application goes in an infinite loop (no error management). when the data reception is finalized, the application reads the new data byte received in the data register (dr). note: if the data byte to be transmitted is the first one after the slave address, a dummy write in the control register (cr) has to be performed to allow the setting of the btf bit (see st7 datasheet for more details). in this application, this dummy write is done by setting the pe bit for each data byte transmission (see description of ev6 in the transfer sequencing diagram in i 2 c datasheet description.
5/7 i2c communication between st7 and m24cxx eeprom 2.7 communicating with the i 2 c eeprom the communication protocol between the st7 and the external m24cxx eeprom is given in figure 2. for more details, please refer to the st24c08 datasheet. figure 2. i 2 c communication protocol the st7 / m24cxx communication application is based on two steps: C write the content of an output buffer (from the st7 rom) in the m24cxx eeprom C read this written buffer from the m24cxx eeprom to the st7 ram. figure 3. shows the flowchart of these two steps. figure 3. communication application flowchart ack start eeprom @ sub @ ack data 1 ack data 2 ack data n-1 data n stop ack start eeprom @ sub @ ack data 1 ack data n nack stop ack start eeprom @ ack write data from st7 to eeprom read data from eeprom to st7 send sub @ data initiate transmission (start + slave @) end of buffer yes no send next buffer data send sub @ data initiate transmission (start + slave @) initiate reception (start + slave @ with lsb set) last data to receive yes no receive next buffer data set the stop condition bit set the stop condition bit clear acknowledge bit no yes write data from st7 to eeprom read data from eeprom to st7 end of reception
6/7 i2c communication between st7 and m24cxx eeprom 3 software all the source files in assembly code are given in zip file with this application note. the source files are for guidance only. stmicroelectronics shall not be held liable for any di- rect, indirect or consequential damages with respect to any claims arising from use of this soft- ware. to adapt this polling software to interrupt management, replace the polling waiting loop by an interrupt event.
7/7 i2c communication between st7 and m24cxx eeprom the present note which is for guidance only aims at providing customers with information regarding their products in order for them to save time. as a result, stmicroelectronics shall not be held liable for any direct, indirect or consequential damages with respect to any claims arising from the content of such a note and/or the use made by customers of the information contained herein in connexion with their products. information furnished is believed to be accurate and reliable. however, stmicroelectronics assumes no responsibility for the co nsequences 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. specifications mentioned in this publicati on are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics prod ucts are not authorized for use as critical components in life support devices or systems without the express written approval of stmicroele ctronics. the st logo is a registered trademark of stmicroelectronics ? 2002 stmicroelectronics - all rights reserved. purchase of i 2 c components by stmicroelectronics conveys a license under the philips i 2 c patent. rights to use these components in an i 2 c system is granted provided that the system conforms to the i 2 c standard specification as defined by philips. stmicroelectronics group of companies australia - brazil - canada - china - finland - france - germany - hong kong - india - israel - italy - japan malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - u.s.a. http://www.st.com


▲Up To Search▲   

 
Price & Availability of AN971

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X