Standard EEPROM ICs. Interfacing SLx 24Cxx I 2 C-Bus Serial EEPROMs to 8051 Controller Family, especially to the Siemens C500 Controller Family

Similar documents
Theory of Operation STOP CONDITION

GT24C02. 2-Wire. 2Kb Serial EEPROM (Smart Card application)

Tutorial for I 2 C Serial Protocol

FM24C02A 2-Wire Serial EEPROM

GT24C256 2-WIRE. 256K Bits. Serial EEPROM

FM24C02B/04B/08B/16B 2-Wire Serial EEPROM

GT24C WIRE. 1024K Bits. Serial EEPROM

DS WIRE INTERFACE 11 DECOUPLING CAP GND

DIGITAL HUMIDITY SENSOR HYT-131

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

I2C BUS SERIAL EEPROM

Preliminary Data MOS IC. Type Ordering Code Package SDA Q67100-H5092 P-DIP-8-1

SILICON MICROSTRUCTURES

GT34C02. 2Kb SPD EEPROM


Preliminary Data MOS IC. Type Ordering Code Package SDA Q67100-H5096 P-DIP-8-1

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

GT24C64 2-WIRE. 64K Bits. Serial EEPROM

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

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

LPC1300, FM+, Fast-mode Plus, I 2 C, Cortex-M3

TOP VIEW CLOCK GENERATOR A1 A2 GND CPU SPEED SELECT

ACE24C512C Two-wire serial EEPROM

+Denotes a lead(pb)-free/rohs-compliant package.

SPI Protocol of the TLE941xy family

Application Note, V 1.1, Apr AP08006 C868. Interfacing SPI/I2C Serial EEPROM with C868 Microcontroller. Microcontrollers. Never stop thinking.

Interfacing the NM24C16 Serial EEPROM to the microcontroller. Interfacing the NM24C16 Serial EEPROM to the 8031 Microcontroller AN-957

0.43" Single Character DLO4135/DLG " Single Character DLO7135/DLG x 7 Dot Matrix Intelligent Display Devices with Memory/Decoder/Driver

DS1845 Dual NV Potentiometer and Memory

24C08/24C16. Two-Wire Serial EEPROM. Preliminary datasheet 8K (1024 X 8)/16K (2048 X 8) General Description. Pin Configuration

GT24C32A 2-WIRE. 32K Bits. Serial EEPROM

DS28CM00. I²C/SMBus Silicon Serial Number

AN2672 Application note

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

FXL6408 Fully Configurable 8-Bit I 2 C-Controlled GPIO Expander

FM24C Kb FRAM Serial Memory Features

LE24L042CS-B. Overview. Functions. CMOS IC Two Wire Serial Interface EEPROM (4k EEPROM)

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

Application Note, V1.0, Jul AP XC16x. Interfacing the XC16x Microcontroller to a Serial SPI EEPROM. Microcontrollers

M24M02-A125. Automotive 2-Mbit serial I²C bus EEPROM with 1 MHz clock. Features

ORDERING INFORMATION. OPERATION Measuring Temperature A block diagram of the DS1621 is shown in Figure 1. DESCRIPTION ORDERING PACKAGE

FM24CL04 4Kb FRAM Serial Memory

FT24C K-bit 2-Wire Serial CMOS EEPROM. Description V. Self time write cycle with auto clear

Easy Kit Board Manual

AP16050 SAB C161V/K/O. Emulating an asynchronous serial interface (ASC) via software routines. Microcontrollers. Application Note, V 1.0, Feb.

VBattery 7 VCC V DD IRLED IS31SE5001 SDA SCL INTB SDB. Figure 1 Typical Application Circuit

Not Recommended for New Designs

DS1855 Dual Nonvolatile Digital Potentiometer and Secure Memory

FM24C16C-GTR. 16Kb Serial 5V F-RAM Memory. Features. Description. Pin Configuration NC NC NC VSS VDD WP SCL SDA. Ordering Information.

Two-wire Serial EEPROM Smart Card Modules 128K (16,384 x 8) 256 (32,768 x 8) AT24C128SC AT24C256SC. Features. Description VCC NC

Nuvoton NCT5655Y/W. 16-bit I 2 C-bus and SMBus GPIO controller with interrupt. Revision: 1.0 Date: May, 2016 NCT5655Y/W

RM24C64AF 64-Kbit 1.65V Minimum Non-volatile Fast Write Serial EEPROM I 2 C Bus

2-wire Serial EEPROM Smart Card Modules AT24C32SC AT24C64SC

LE24512AQF. Overview. Functions. CMOS IC Two Wire Serial Interface EEPROM (512k EEPROM)

DS1682 Total-Elapsed-Time Recorder with Alarm

Figure 1 Typical Application Circuit

2-wire Serial EEPROM AT24C512. Preliminary. 2-Wire Serial EEPROM 512K (65,536 x 8) Features. Description. Pin Configurations.

AN F²MC-16FX Family, I2C. Contents. 1 Introduction. This application note describes how to communicate via I2C with a Serial EEPROM.

AD5669R - Microcontroller No-OS Driver

M24C M24C M24C M24C02-125

LE2416RLBXA. Overview. Functions. CMOS IC Two Wire Serial InterfaceEEPROM (16k EEPROM)

Fremont Micro Devices, Inc.

Figure 1: TSSOP-24 ( Top View ) Figure 2: TQFN 4x4-24 ( Top View )

ESD5V3U4RRS. Type Package Configuration Marking ESD5V3U4RRS SOT363 6 pins, uni-directional E8s

INTEGRATED CIRCUITS. PCA bit I 2 C and SMBus I/O port with interrupt. Product data sheet Supersedes data of 2004 Jul 27.

PI4IOE5V bit general purpose outputs for 1MHz I 2 C bus

FM24C16B-GTR. 16Kb Serial 5V F-RAM Memory. Features. Pin Configuration. Description. Ordering Information NC NC NC VSS VDD WP SCL SDA.

PI4IOE5V9675. Remote 16-bit I/O expander for Fm+ I 2 C-bus with interrupt Description. Features. Pin Configuration

Remote 16-bit I/O expander for Fm+ I 2 C-bus with interrupt and reset. Description

X K x 8 Bit 64K. 5MHz SPI Serial E 2 PROM with Block Lock TM Protection

NovalithIC H-Bridge Demo Board

EZ I 2 C Slave. Features. General Description. When to use a EZ I 2 C Slave 1.50

DS1846 NV Tri-Potentiometer, Memory, and MicroMonitor

AN-1159 APPLICATION NOTE

Microtronix Avalon I 2 C

LE2464DXA 64 kb I 2 C CMOS Serial EEPROM

12 Push-Pull Outputs and 4 Inputs

M3H Group(1) Application Note I 2 C Interface (I2C-B)

I 2 C Port Expander with Eight Inputs. Features

Chip Card & Security ICs SLE Intelligent 1024 Byte EEPROM with Write Protection and Programmable Security Code

Security & Chip Card ICs SLE 55R04. Intelligent 770 Byte EEPROM with Contactless Interface complying to ISO/IEC Type A and Security Logic

M3H Group(1) Application Note. I 2 C Interface (I2C-B) MASTER/SLAVE

ACE24AC128 Two-wire Serial EEPROM

Digital Thermometer and Thermostat

ABLIC Inc., Rev.1.6_00

Features. Description PI4IOE5V bit I 2 C-bus I/O Expander

SII Semiconductor Corporation, 2017 Rev.1.1_00

Features. Ordering Information. Selector Guide. Applications. Pin Configurations. I 2 C Port Expander with 8 Open-Drain I/Os

Raspberry Pi - I/O Interfaces

Chip Card & Security ICs SLE Intelligent 256-Byte EEPROM with Write Protection function and Programmable Security Code

INTEGRATED CIRCUITS. PCA bit I 2 C and SMBus I/0 port with reset. Product data Supersedes data of 2002 May Dec 13

2-wire Serial EEPROM AT24C512

USB-to-I2C Basic. Hardware User s Manual.

PI4IOE5V bit I 2 C-bus and SMBus low power I/O port with interrupt and reset

and 8 Open-Drain I/Os

Application Note No. 100

Digital Thermometer and Thermostat

Debounced 8 8 Key-Scan Controller

HDI Series Amplified pressure sensors

FM24C1024A. Apr Data Sheet. Data Sheet FM24C1024A 2-wrie Serial EEPROM Ver 1.1 1

Transcription:

Standard EEPROM ICs Interfacing SLx 24Cxx I 2 CBus Serial EEPROMs to 8051 Controller Family, especially to the Siemens C500 Controller Family Application Note 19990315

Interfacing SLx 24Cxx, Application Note Revision History: Current Version: 19990315 Previous Version: Page (in previous Version) Page (in current Version) Subjects (major changes since last revision) Page Protection Mode is a trademark of Siemens AG. Edition 19990315 Published by Siemens AG, Bereich Halbleiter, Marketing Kommunikation, Balanstraße 73, 81541 München Siemens AG 1999. All Rights Reserved. Attention please! As far as patents or other rights of third parties are concerned, liability is only assumed for components, not for applications, processes and circuits implemented within components or assemblies. The information describes the type of component and shall not be considered as assured characteristics. Terms of delivery and rights to change design reserved. For questions on technology, delivery and prices please contact the Semiconductor Group Offices in Germany or the Siemens Companies and Representatives worldwide (see address list). Due to technical requirements components may contain dangerous substances. For information on the types in question please contact your nearest Siemens Office, Semiconductor Group. Siemens AG is an approved CECC manufacturer. Packing Please use the recycling operators known to you. We can also help you get in touch with your nearest sales office. By agreement we will take packing material back, if it is sorted. You must bear the costs of transport. For packing material that is returned to us unsorted or which we are not obliged to accept, we shall have to invoice you for any costs incurred. Components used in lifesupport devices or systems must be expressly authorized for such purpose! Critical components 1 of the Semiconductor Group of Siemens AG, may only be used in lifesupport devices or systems 2 with the express written approval of the Semiconductor Group of Siemens AG. 1 A critical component is a component used in a lifesupport device or system whose failure can reasonably be expected to cause the failure of that lifesupport device or system, or to affect its safety or effectiveness of that device or system. 2 Life support devices or systems are intended (a) to be implanted in the human body, or (b) to support and/or maintain and sustain human life. If they fail, it is reasonable to assume that the health of the user may be endangered.

Table of Contents Page 1 Introduction................................................4 2 I 2 Cbus....................................................4 2.1 Data Transfer formats.........................................4 2.2 Timing Diagram..............................................6 2.3 Hardware Connection.........................................8 3 Software.........................................9 3.1 Software Concept.............................................9 3.2 of the Software Routines............................11 3.3 Software Compilation........................................22 Semiconductor Group 3 19990315

1 Introduction A lot of applications in the field of consumer electronics, telecommunications, automotive and industrial electronics need nonvolatile memory. Because of their byte level flexibility, low I/O pin requirements, low power consumption, small footprint and low cost, Siemens serial EEPROMs are a popular choice for nonvolatile storage. This application note provides assistance and source code to ease the design process of interfacing a SLx 24Cxx I 2 Cbus serial EEPROM to the 8051 controller family, especially to the Siemens C500 8bit controller family. The source code (24Cxx8b.EXE) as well as the datasheets for SLx 24Cxx EEPROMs are also available in the Siemens World Wide site at address: http://www.siemens.de/semiconductor/products/ics/31/316.htm. 2 I 2 CBus SLx 24Cxx serial EEPROMs use the industry standard I 2 Cbus protocol for data transfer. The I 2 Cbus or InterIntegrated Circuit bus has been developed by Philips. It allows integrated circuits to communicate directly with each other via a simple bidirectional 2 wirebus. The two bus lines are serial clock line (SCL), and serial data line (SDA). Nowadays, the I 2 Cbus becomes a standard bus system which is used in consumer electronics, telecommunications and industrial electronics. This software for interfacing a SLx 24Cxx I 2 Cbus serial EEPROM to the 8051 controller family by I 2 Cbus emulation supports the single master protocol only. It is using the CP time to generate clock, and transmit or receive the data. The clock frequency of the I 2 Cbus can achieve up to 400 khz. 2.1 Data Transfer Formats The I 2 Cbus protocol allows several devices to share the same bus. In this software the microcontroller serves as the master, initiating and terminating data transfers, generating the clock which regulates the flow of data, transmitting and receiving data. EEPROMs can only serve as slaves, receiving and transmitting data. General information about data transfer formats for devices on the I 2 Cbus will be given now, for more detailed information regarding SLx 24Cxx please refer to the datasheets. The master initiates a data transfer by generating a start condition (SDA going low while SCL high). The master terminates the data transfer by generating a stop condition (SDA going high while SCL high). Every data put on the SDA line must be 8 bits long. The number of data bytes transferred between the START and STOP condition is not limited by the I 2 Cbus protocol. The data on the SDA line must be stable during the HIGH period of the clock. Data can only change during the low phase of the clock. The data byte is transferred serially with the most significant bit first, and followed by an acknowledge bit on every 9th clock pulse (see figure 1). Semiconductor Group 4 19990315

SCL 1 2 8 9 1 9 SDA ACK ACK START Condition Data allowed Acknowledge STOP Condition to Change IED02128 Figure 1 Data Transfer Conventions The receiver is obliged to generate an acknowledge bit after each byte of data that has been received. If the master is receiving data, it must signal the end of data transfer to the slave by not generating an acknowledge bit on the last byte of data received (see figure 2). Then, the slave must release the data line to allow the master to generate the STOP condition. Figure 3 shows the I 2 Cbus data transfer format of writing data from master to the slave device. The 8th of the command byte is a data direction bit (R/W). The 0 for data direction bit indicates a transmission (WRITE). A 1 indicates a request for data (READ). Figure 2 shows the data transfer format of reading data from the slave device. Bus Activity Master S T A R T Command Byte CSR S T O P SDA Line S 1 P Bus Activity EEPROM A C K Data Byte IED02132 Figure 2 Read Sequence Semiconductor Group 5 19990315

Bus Activity Master S T A R T Command Byte CSW EEPROM Address EEA Data Byte S T O P SDA Line S 0 P Bus Activity EEPROM A C K A C K A C K IED02129 Figure 3 Write Sequence 2.2 Timing Diagram The clock frequency of SCL is in the range of 0 up to 400 khz. Occasionally, slave devices may slow down the transmission by holding the clock line low after receiving a byte of data from the microcontroller. This event is defined as a WAIT condition. Therefore, the master needs to switch the SCL output to high impedance and read the SCL line before transmitting another byte of data to the slave device. Figure 4 shows the data transfer timing requirements in detail. The description of the used abbreviations is shown in the table 1. The minimum timing requirements are needed to be fulfilled in order for I 2 Cbus to operate properly. t R t F t LOW t HIGH SCL t S.STA t S.DAT t HD.STA t HD.DAT t S.STO t BF SDA In Start Condition t AA t DH Stop Condition SDA Out IED02127 Figure 4 Bus Timing Semiconductor Group 6 19990315

Table 1 Symbol Standard Mode I 2 Cbus Fast Mode I 2 Cbus min. max. min. max. SCL clock frequency f SCL 100 400 khz Clock pulse width low t low 4.7 1.2 µs Clock pulse width high t high 4.0 0.6 µs SDA and SCL rise time t R 1000 300 ns SDA and SCL fall time t F 300 300 ns Start setup time t S.STA 4.7 0.6 µs Start hold time t HD.STA 4.0 0.6 µs Data in setup time t S.DAT 200 100 ns Data in hold time t HD.DAT 0 0 µs SCL low to SDA data out t AA 0.1 4.5 0.1 0.9 µs valid Data out hold time t DH 100 50 ns Stop setup time t S.STO 4.0 0.6 µs Time the bus must be free t BF 4.7 1.2 µs before a new transmission can start Capacitive load for each bus line C b 400 400 pf nits Semiconductor Group 7 19990315

2.3 Hardware Connection. Every device connected to the I 2 Cbus must have an open drain/open collector output for both the clock (SCL) and data (SDA) lines. Each of the lines is connected to the V CC supply via a common pullup resistor. The connection among master and many slave devices is shown in figure 5. The number of devices that can be connected to the I 2 C bus is limited only by the maximum bus load capacitance of 400 pf. Theoretically up to 8 serial EEPROMs can be connected to the same I 2 Cbus. Not all types of the SLx 24Cxx family support this feature, please refer to the datasheets. V CC Slave 1 Slave 2 Slave 3 Slave 4 Master SCL SDA Slave 5 Slave 6 Slave 7 Slave 8 V CC IES02183 Figure 5 Bus Configuration Semiconductor Group 8 19990315

3 Software 3.1 Software Concept Table 2 Device Type Directory I 2 CBus module SLx 24C01 SLx 24C02 SLx 24C04 SLx 24C08 SLx 24C16 SLx 24C164 SLx 24C01/P SLx 24C02/P SLx 24C04/P SLx 24C08/P SLx 24C16/P SLx 24C164/P SLx 24C32 SLx 24C64 SLx 24C32/P SLx 24C64/P 2401_8B 2401_8BP 2404_8BP 2432_8B 2432_8BP I 2 C_SW8B.C I 2 C_SW8B.H I 2 C_8B.DEF I 2 C_SW8B.C I 2 C_SW8B.H I 2 C_8B.DEF I 2 C_SW8B.C I 2 C_SW8B.H I 2 C_8B.DEF I 2 C_SW8B.C I 2 C_SW8B.H I 2 C_8B.DEF I 2 C_SW8B.C I 2 C_SW8B.H I 2 C_8B.DEF EEPROM module 24SW01.C 24SW01.H 24SW01P.C 24SW01P.H 24SW01P.C 24SW01P.H 24SW32.C 24SW32.H 24SW32P.C 24SW32P.H Demo program 24dem01.C 24dem01P.C 24dem04P.C 24dem32.C 24dem32P.C The software for each device type (e.g. Slx 24C01) consists of 1 basic I 2 Cbus module, 1 control module with EEPROM routines and 1 demo program. The I 2 Cbus module contains subroutines for the I 2 Cbus protocol. The EEPROM module uses these subroutines to implement command sequences for SLx 24Cxx devices. The demo program shows how the modules can be used in an application program. Table 2 gives an overview which modules and demo program have to be used for the different device types and in which directory of the 24Cxx8b.EXE these files can be found. In the first module (I2C_SW8B.C) the clock and data of the I 2 Cbus are generated by using CP time of the 8051 microcontroller. The clock frequency of the I 2 Cbus is approximately 100 khz with 20 MHz CP and 300 ns for a onecycle instruction. The time delay is realized with NOP commands. If the CP clock is less or more than 20 MHz or an onecycle instruction takes more or less than 300 ns, this software module can be modified to achieve the 100 or 400 khz of SCL frequency. Semiconductor Group 9 19990315

The software modification involves reducing or eliminating the time delay. In addition, check for WAIT condition before every byte is sent or received rather than checking for WAIT condition before every bit is sent or received. Be aware of the fact that this software module can be interrupted by others software modules that are involved in hardware interrupts. In other words, this software module is equivalent to those software modules with lowest priority interrupt level. The advantage of using the CP time to generate clock and data is that only use 2 port pins and no other hardware peripheral of the 8051 microcontroller are used. Therefore, those hardware peripherals can be reserved for other time critical software application. The I2C_SW8B.C software module is divided into 5 software subroutines which can be accessed by an external programs. These 5 software basic subroutines are used to construct the data transfer format of the I 2 Cbus: I2cInit, I2cStart, I2cMasterWrite, I2cMasterRead and I2cStop. The second module (24SWxx.C)shows the whole functionality of SLx 24Cxx I 2 Cbus serial EEPROMs using the basic subroutines of the first module (I2C_SW8B.C). All 24SWxx.C software modules are divided into 7 software subroutines which can be accessed by external programs: ByteWriteE2prom, PageWriteE2prom, Ack_pol_r, Ack_pol_w, RandomReadE2prom, CurrentReadE2prom and SequentialReadE2prom. The routines Ack_pol_r and Ack_pol_w contain time critical wait cycles that are calculated for 20 MHz CP and 300 ns for a onecycle instruction. If the CP clock is less or more than 20 MHz or an onecycle instruction takes more or less than 300ns, these routines might be modified. For devices with Page Protection Mode TM (SLx 24Cxx.../P) the software modules 24SWxxP.C contain additionally to the 7 basic subroutines 3 routines especially for the Page Protection Mode TM : PPMWriteE2prom, PPMEraseE2prom and PPMReadE2prom. The third part of this software package contains demo programs for devices without (24demxx.C) and with Page Protection Mode TM (24demxxP.C). These demo programs demonstrate how the software modules 24SWxx.C/24SWxxP.C can be used in an application program. Semiconductor Group 10 19990315

3.2 of the Software Routines I 2 CBS Software Module Source file: I2C_SW8B.C Header file: I2C_SW8B.H ser definition file: I2C_8B.DEF The I 2 Cbus module simulates a standard I 2 Cbus single master protocol by using CP time of the 8051 microcontroller. The clock as well as transmit/receive data are handled by the CP time delay. The 2 port pins of the microcontroller which are used for clock and transmit/receive data are defined in I2C_8B.DEF. Module Subroutines 1. void CheckClock(); 2. unsigned char Check_SCL(); 3.unsigned char I2cInit(); 4.void I2cStart(); 5.unsigned char I2cMasterWrite(unsigned char input_byte); 6.unsigned char I2cMasterRead(unsigned char ack); 7.unsigned char I2cStop(); void CheckClock() Send HIGH and read the SCL line. It will wait until the line has been released from slave device (SLx 24Cxx) for every bit of data to be sent or received. None Semiconductor Group 11 19990315

unsigned char Check_SCL() Send HIGH and read the SCL line. It will wait until the line has been released from slave device (SLx 24Cxx) with the timeout of approximately 10 ms. None The return value is 0 if the clock and data lines have no problem. Otherwise, the return value will be 1. unsigned char I2cInit() Check clock and data lines for any bus faulty like no pullup resistor on SDA/SCL or pulldown to low by the slave device. None The return value is 0 if the clock and data lines have no problem. Otherwise, the return value will be 1. void I2cStart() Generate a START condition on I 2 Cbus. None Semiconductor Group 12 19990315

unsigned char I2cMasterWrite(unsigned char input_byte) Output one byte of data to the slave device. Check for WAIT condition before every bit is sent. unsigned char input_byte one byte of data to be sent to slave device. If the return value is 0, write sequence is received from slave device (SLx 24Cxx) sucessfully. Otherwise, write sequence is needed to be sent again because there is no acknowledge from the slave device. unsigned char I2cMasterRead(unsigned char ack) Read one byte of data from the slave device. Check for WAIT condition before every bit is received. unsigned char ack 0 generate LOW output by the master after a byte of data is received. 1 generate HIGH output by the master after a byte of data is received. If the return value is 0, reading one byte of data from slave device (SLx 24Cxx) is successfully. Otherwise, one byte of data is needed to be received again, because there is no acknowledge from the slave device. Semiconductor Group 13 19990315

unsigned char I2cStop() Generate a STOP condition on the I 2 Cbus. In addition, it will generate clock pulses until the line is released by the slave device (SLx 24Cxx) and the timeout is approximately 10 ms before returning a HIGH value indicating an error. None The return value is 0 if the clock and data lines have no problem. Otherwise, the return value will be 1. I 2 CBus EEPROM Software Source file: 24SW01P.C Header file: 24SW01P.H The EEPROM module 24SW01P.C shows the whole functionality of SLx 24Cxx EEPROMs and contains additionally 3 subroutines for Page Protection Mode TM using the I 2 Cbus module (I2C_SW8B.C). Table gives a short overview about the main differences between the module 24SW01P.C and the other EEPROM modules. Table 3 EEPROM modules 24SW01.C 24SW032.C 24SW32P.C Main differences to module 24SW01P.C only subroutines 17 are included only subroutines 17 are included, instead of 1 address byte (unsigned char address) for addressing, 2 address bytes are used (unsigned char addresshi, unsigned addresslo) instead of 1 address byte (unsigned char address) for addressing, 2 address bytes are used (unsigned char addresshi, unsigned addresslo) Semiconductor Group 14 19990315

Software routines 1. unsigned char ByteWriteE2prom(unsigned char command, unsigned char address,unsigned char *buffer); 2. unsigned char PageWriteE2prom (unsigned char command, unsigned char address, unsigned char *buffer, unsigned char count); 3. unsigned char Ack_pol_r(unsigned char command); 4. unsigned char Ack_pol_w(unsigned char command); 5. unsigned char RandomReadE2prom (unsigned char command, unsigned char address, unsigned char *buffer); 6. unsigned char CurrentReadE2prom (unsigned char command, unsigned char *buffer); 7. unsigned char SequentialReadE2prom(unsigned char command, unsigned char address, unsigned char *buffer, unsigned char count); These routines are only for SLx 24Cxx/P with Page Protection Mode TM : 8. unsigned char PPMWriteE2prom(unsigned char command, unsigned char address, unsigned char *buffer, unsigned char count); 9. unsigned char PPMEraseE2prom(unsigned char command, unsigned char address, unsigned char *buffer, unsigned char count); 10.unsigned char PPMReadE2prom(unsigned char command, unsigned char address, unsigned char *buffer, unsigned char count); Semiconductor Group 15 19990315

unsigned char ByteWriteE2prom(unsigned char command, unsigned char address, unsigned char *buffer) Write 1 data byte to E 2 PROM. The flow of this subroutine is derived from the data format of writing as shown in figure 3. None If the return value is 0, the programming of E 2 PROM is started. Otherwise, the data is needed to be sent again because there is no acknowledge from slave device. unsigned char PageWriteE2prom(unsigned char command, unsigned char address,unsigned char *buffer,unsigned char count) Write number of data bytes to E 2 PROM. unsigned char command unsigned char address unsigned char *buffer unsigned char count specifies the command byte specifies the EEPROM address point to the location of data to be sent number of bytes to be sent If the return value is 0, the programming of E 2 PROM is started. Otherwise, the data is needed to be sent again because there is no acknowledge from slave device. Semiconductor Group 16 19990315

unsigned char Ack_pol_r(unsigned char command) Check for the completion of programming by sending read commands. If the programming is completed, the acknowledge bit will be 0. unsigned char command specifies the command byte If the return value is 0, the programming of E 2 PROM is considered to be done. Otherwise, the programming last much more than 8 ms (CP clock 20 MHz and 200 ns for a onecycle instruction) and an error occurred. unsigned char Ack_pol_w(unsigned char command); Check for the completion of programming by sending write commands. If the programming is completed, the acknowledge bit will be 0. unsigned char command specifies the command byte If the return value is 0, the programming of E 2 PROM is considered to be done. Otherwise, the programming last much more than 8 ms (CP clock 20 MHz and 200 ns for a onecycle instruction) and an error occurred. Semiconductor Group 17 19990315

unsigned char RandomReadE2prom(unsigned char command, unsigned char address,unsigned char *buffer) Read 1 data byte from E 2 PROM. unsigned char command unsigned char address unsigned char *buffer specifies the command byte specifies the EEPROM address point to the location of data to be stored If the return value is 0, the reading of E 2 PROM is completed. Otherwise, the data is needed to be sent again, because there is no acknowledge from slave device. unsigned char CurrentReadE2prom (unsigned char command, unsigned char *buffer) Read 1 data byte from the current E 2 PROM address. The flow of this subroutine is derived from the data format of reading from the E 2 PROM as in the Figure 3. unsigned char command unsigned char *buffer specifies the command byte point to the location of data to be stored If the return value is 0, the reading of E 2 PROM is completed. Otherwise, the data is needed to be sent again, because there is no acknowledge from slave device. Semiconductor Group 18 19990315

unsigned char SequentialReadE2prom (unsigned char command, unsigned char address,unsigned char *buffer, unsigned char count) Read number of data bytes from the E 2 PROM. unsigned char command unsigned char address unsigned char *buffer unsigned char count specifies the command byte specifies the EEPROM address point to the location of data to be sent number of bytes to be sent If the return value is 0, the reading of E 2 PROM is completed. Otherwise, the data is needed to be sent again, because there is no acknowledge from slave device. unsigned char PPMWriteE2prom(unsigned char command, unsigned char address, unsigned char *buffer, unsigned char count) Protect one page. Therefore the PPM bit is set to 0. unsigned char command unsigned char address unsigned char *buffer unsigned char count specifies the command byte specifies the EEPROM address point to the location of data to be sent byte number of one page to be sent If the return value is 0, the programming of the PPM bit is started. Otherwise, the data is needed to be sent again because there is no acknowledge from slave device. Semiconductor Group 19 19990315

unsigned char PPMEraseE2prom(unsigned char command, unsigned char address,unsigned char *buffer,unsigned char count) nprotects one page. Therefore the PPM bit is set to "1". unsigned char command unsigned char address unsigned char *buffer unsigned char count specifies the command byte specifies the EEPROM address point to the location of data to be sent byte number of one page to be sent If the return value is 0, the programming of the PPM bit is started. Otherwise, the data is needed to be sent again because there is no acknowledge from slave device. unsigned char PPMReadE2prom(unsigned char command, unsigned char address,unsigned char *buffer, unsigned char count) Read status of PPM bits from the E 2 PROM. unsigned char command unsigned char address unsigned char *buffer unsigned char count specifies the command byte specifies the EEPROM address point to the location of data to be stored number of PPM bits to be read If the return value is 0, the reading of E 2 PROM is completed. Otherwise, the data is needed to be sent again because there is no acknowledge from slave device. Semiconductor Group 20 19990315

I 2 CBS EEPROM Demonstration Program The demo program shows how the 24SWxx.C/24SWxxP.C software modules can be used in an application program. To verify whether all routines of the demo program runs successfully, table and show the memory content before/after running the demo program. Table 4 address Initial memory content Memory content after running demo program 24dem01.C 000 008 24dem32.C 000 008 07 01 02 03 04 05 03 07 07 01 02 03 04 05 03 07 07 01 02 03 04 05 03 07 07 01 02 03 04 05 03 07 Table 5 address 1) Initial memory content 1) Memory content after running demo program 24dem01P.C 000 008 P 07 01 02 03 04 05 03 07 07 01 02 03 04 05 03 07 0 2) 0 2) 1 2) FF FF FF FF FF 24dem04P.C 000 008 010 018 020 24dem32P.C 000 008 010 018 020 028 030 038 040 P 07 01 02 03 04 05 03 07 07 01 02 03 04 05 03 07 0 2) 0 2) 1 2) FF FF FF FF FF 07 01 02 03 04 05 03 07 07 01 02 03 04 05 03 07 0 2) 0 2) 1 2) FF FF FF FF FF P 1) 2) = protection bit 1, page is unprotected; P = protection bit 0, page is protected Only the MSB bit is specified to 0 or 1 ( e.g. 0 = 7F or 08, ; e.g. 1 =8F or A5, ) Semiconductor Group 21 19990315

3.3 Software Compilation The compilation of this software is using the KEIL C8051 compiler. First of all, open µvision/51 from Keil. nder the PROJECT menu click on New Project and enter the project name. Then add the I 2 Cbus module, an EEPROM module and a demo program to the project according to table 2 (e.g. I2C_SW8B.C, 24sw01P.C and 24dem01P.C)and save the project. To complete the compilation also the header and definition files are necessary (e.g. I2C_SW8.H, 24sw01P.H,I2C_8B.DEF) Now the project is ready to compile and link all the object files. The compiling and linking of the project can be done by clicking the icon BILD ALL. The 24Cxx8b.EXE is a compressed file containing 5 directories. Each directory contains all header, definition and C files which are needed to run the demo program for a special device type (see table 2). Semiconductor Group 22 19990315