Detailed Explanation of 24C02 EEPROM Memory Chip

15 March 2024


Ⅰ. Overview of 24C02

Ⅱ. Functions of 24C02

Ⅲ. Basic operations of 24C02

Ⅳ. Application of 24C02

Ⅴ. 24C02 pinout

Ⅵ. How to protect the data of 24C02?

Ⅶ. How to use 24C02?



EEPROM refers to electrically erasable programmable read-only memory. It is a memory chip that does not lose data after power failure. EEPROM can erase existing information and reprogram it on a computer or special device. This article will introduce a commonly used EEPROM memory chip 24C02.



Ⅰ. Overview of 24C02


4c68bc9df58f53ce8d9c76f645c7e340.png


24C02 is an I2C compatible EEPROM memory produced by Atmel. It has a 2KB storage capacity, uses an 8-pin package, and features low power consumption, low voltage, high durability and high reliability. Additionally, the 24C02 has a write-protect feature that protects stored data from accidental writing or erasing.


In terms of hardware interface, the 24C02 communicates with the microcontroller or microprocessor through the I2C bus. It has two key pins: SDA (serial data bus) and SCL (serial clock bus). Through these two pins, we can perform read and write operations on the memory. In addition, 24C02 is also equipped with two programmable address pins A0 and A1, which are used to distinguish and select different device addresses. In terms of software programming, reading and writing operations on 24C02 using the I2C protocol must follow specific timing requirements. The write operation involves steps such as write cycle, write data, write address and confirmation cycle; while the read operation includes steps such as read cycle, read data and confirmation cycle. The important thing is that before writing data, we must first select the target address to be written, and after the writing operation is completed, corresponding write protection operations must be performed to ensure the security of the data.



Ⅱ. Functions of 24C02


• Low power consumption: 24C02 has very low power consumption in working conditions, making it suitable for use in mobile devices and battery-powered devices.

• Erasable and programmable: 24C02 adopts electronic erasure programmable technology, which can erase and program the stored data.

• Storage capacity: 24C02 has a storage capacity of 2K bits, which is equivalent to 256 bytes. Each byte contains 8 bits of binary data, making it capable of storing large amounts of information.

• High reliability: 24C02 adopts automatic page writing technology, which has high reliability and stability and is suitable for various industrial and consumer electronic products.

• Serial interface: 24C02 uses a serial interface to read and write data, allowing it to communicate with various microprocessors and other peripheral devices.



Ⅲ. Basic operations of 24C02


1. Address setting: 24C02 has a 16-bit address space, which enables it to address 256 bytes of storage. When writing or reading data, we first set the corresponding address. Usually, the address consists of two parts: the first 12 bits represent the chip address, while the last 4 bits represent the memory cell address.

2. Data writing: Before writing data, we need to send the data and address to the chip first. These data and address are sent in 8-bit binary form. When sending, the data is sent from the high bit, followed by the address.

3. Data reading: To read the data, we first need to send the address to the chip. Subsequently, the chip returns the data stored at that address. Similarly, the received data is also presented in the form of 8-bit binary.



Ⅳ. Application of 24C02


• Security system: In security monitoring system, 24C02 can be used to store the configuration parameters, video data, alarm records and other information of the monitoring equipment to support security monitoring and event tracking.


• Medical devices: In medical devices, the 24C02 can be used to store patient medical records, treatment parameters, device calibration data and other information to help healthcare professionals manage patient information and device status.


• Consumer electronics: 24C02 is often used to store configuration data, user settings, software firmware, etc. for consumer electronics. For example, setup parameters and user data in smartphones, tablet PCs, digital cameras and other products can be stored in the 24C02.


• Industrial automation: In the field of industrial automation, the 24C02 can be used to store sensor data, device configurations, production parameters, and so on. It can be used as a lightweight non-volatile storage medium for recording equipment status and production data.


• Home appliances: In home appliances such as smart TVs and smart home devices, 24C02 is commonly used to store data such as device configuration, user settings, firmware updates, etc., in order to provide a personalized user experience and flexible function expansion.


• Smart card and security applications: 24C02 chips can be embedded into smart cards, electronic access control systems, security signs and other products for storing sensitive information such as user identity information, permission data, encryption keys and other sensitive information to achieve secure access and authentication.


• Automotive electronic systems: In automotive electronic systems, the 24C02 can be used to store vehicle configuration information, fault codes, security settings and other data. For example, the 24C02 may be used in an automobile's electronic control unit (ECU) to store information such as engine parameters, vehicle speed data, and other information.



Ⅴ. 24C02 pinout


349cc9d789287094de5fb6f403dcd065.png



Ⅵ. How to protect the data of 24C02?


1. Hardware measures to protect 24C02 data


In some situations where the interference is particularly serious, the 24C02 data may still be washed out. In order to solve this problem most completely, we can use hardware to intervene in the process of writing data. Normally we would disconnect the WP pin from the CPU pin and connect it with the function key. When the function key is not pressed, WP remains high, and writing operations are not allowed at this time; only when the function key is pressed, WP will become low, allowing writing operations. However, the disadvantage of this approach is that we cannot implement certain process quantities that require program control to be stored in 24C02. This is also an inconvenience of using function keys to protect 24C02 data synchronously. If the data written to the 24C02 is related to two buttons, then we can use diodes for isolation. In this way, the two buttons will not affect each other, and pressing any one button can cause WP to become low, thereby making the data writing operation effective. For the case of multi-key correlation, we can analogize and place a few more diodes for isolation.


2. Software measures to protect 24C02 data


(1) It is recommended to store the data in 24C02 in decimal BCD code, which can increase the redundancy of effective data. Specifically, in the storage unit of 24C02, valid data should be limited to the range of 0-9, and data beyond this range is considered invalid. Therefore, before writing data to 24C02, we can insert a verification subroutine to check the data to be written. If the data in RAM has been corrupted, its value is likely to fall in a range greater than 9 (possibility percentage coefficient 246/256). Therefore, when it is detected that the data is greater than 9, we should prohibit the execution of the subroutine that writes 24C02 to avoid incorrect data being written to 24C02. Doing so will not affect parameters that normally need to be modified.


(2) After maintaining data redundancy in 24C02, we also need to check the read data. If it is found that the read data is greater than 9, it means that it is abnormal data, indicating that the data in 24C02 has been disturbed. Such interference values cannot be used. For specific systems, we can take different responses. Taking an incubator with temperature control as an example, if its temperature control range is between 0°C and 50°C, then when the data is wrong, the read value may abnormally become 200°C or higher. This is very dangerous. In response to this situation, we can rigidly set the setting value to a certain safe value, such as 25°C. Since the originally set parameter values cannot be determined, although this is a helpless move, it can ensure the security of the system.


(3) In order to enhance the security of writing to 24C02, we can set a software password for the writing subroutine. Write operations are allowed only if the password matches, otherwise the write operation is denied. The specific steps are as follows:


First, we set up a write password register EPSW. According to the normal execution flow of the CPU program, we need to find out all the paths that must be passed before writing to 24C02. For example, usually after a function key is pressed, after a series of data processing, the parameters that need to be saved will eventually be written to 24C02. In this case, we can set a specific value (for example, 5AH) to the write password register EPSW when a key input is detected in the key scanning subroutine. Then, in the subroutine written to 24C02, immediately after the instruction CLR WP, we need to insert a statement that checks the password. This statement will determine whether the value of EPSW is 5AH. If the value is correct, the write operation is allowed to continue; otherwise, the program returns immediately and the write data is not allowed to proceed. In order to ensure safety, after the subroutine written to 24C02 is correctly executed, we need to clear the EPSW. In addition, we should also add the EPSW clearing instruction at the appropriate location in the main program and execute it repeatedly and redundantly. The advantage of this is that when the program is disturbed, the value of EPSW will be 0 in most cases. Even if the value of EPSW is disturbed, there is a rare chance that it will be exactly 5AH. Therefore, the chance of incorrect data being written abnormally to 24C02 will be greatly reduced.



Ⅶ. How to use 24C02?


The following is a basic 24C02 usage steps:


1. Connect the data line to the I2C interface of the microcontroller (or CPU). This data line is bidirectional and has the function of sending and receiving data. In addition, we also need to ensure that the clock line (SCL) and ground line (GND) are correctly connected. These connections are key to ensuring normal data transmission and stable communication.


2. In order to communicate with the 24C02, we need to set the I2C interface of the microcontroller to work in master controller mode. Most microcontrollers support both master and slave modes of operation. When the microcontroller is in master mode, it is responsible for generating clock signals and controlling the data transfer process.


3. Before preparing to start data transmission, we need to initialize the I2C interface. This usually involves setting the clock rate of the I2C and enabling other features such as interrupts as needed.


4. Write a function to write data to 24C02. This function requires data and address as parameters. First, send the address (including chip address and memory unit address), and then send the data. Note that the data needs to be encoded in binary form when sent.


5. Write a function to read the data. This function requires an address as a parameter. After sending the address, the data will be read from the chip and returned. Likewise, the data needs to be decoded in binary when received.


6. Debugging and testing code. We can check if everything is working fine by modifying the address and data being written and then reading it out.


7. Consider data security and integrity. In many applications, EEPROM is used to save device configuration parameters or system settings. This information is critical to the operation of the device. Therefore, we should ensure that errors do not occur when writing or reading data and regularly check the integrity of the data.




Frequently Asked Questions


1. What is an EEPROM programmer?


Automotive EEPROM programmers are specialized devices used for programming the electronic erasable programmable read-only memory (EEPROM) chips found in modern vehicles.


2. What is the capacity of 24c02?


This IC has the capacity of 2 K-bit, 4 K-bit, 8-K bit and 16 K-bit, and the organization is 256 words×8-bit, 512 words×8-bit, 1024 words×8-bit and 2048 words×8-bit, respectively. Page write and sequential read are available.


3. What is 24C02?


he 24C02/24C04 provides 2048/4096 bits of serial electrically erasable and programmable read-only memory (EEPROM) organized as 256/512 words of 8 bits each The device is optimized for use in many industrial and commercial applications where low-power and low-voltage operation are essential.


4. What is the use of IC 24C02?


The Turbo IC 24C01/24C02 uses the I²C addressing protocol and 2-wire serial interface which includes a bidirectional serial data bus synchronized by a clock. It offers a flexible byte write and a faster 8-byte page write. The Turbo 24C01/24C02 is assembled in either a 8-pin PDIP or 8-pin SOIC package.