Description
The 24C02N 256 x 8 (2K) EEPROM is used to provide small non-volatile memory storage with easy to access I2C interface.
PACKAGE INCLUDES:
- 24C02N DIP IC
KEY FEATURES OF 24C02N 256 x 8 EEPROM:
- 2K-bit memory organized as 256 x 8 bytes
- I2C Interface
- 5V compatible
The 24C02N provides 2048 bits of serial Electrically Erasable and Programmable Read-Only Memory (EEPROM) organized as 256 words x 8 bits each.
The device communicates via the I2C two-wire serial interface. The base I2C address is 0x50. Three address bits (A2, A1, A0) allow up to 8 devices to be used in the same system. To use a single chip at address 0x50, you can just ground all 3 address bits.
The Write Protect (PW) pin is grounded to allow normal read/write operations. If it is pulled high, the device is write protected and becomes a read only device.
These small memories are sometimes used to store configuration information or data acquisition results.
OUR EVALUATION RESULTS:
These devices and larger versions of them can be useful for adding non-volatile memory storage external to the MCU and are fairly easy to use.
The test program here uses raw I2C commands from the Wire.h library to exercise the device. It first writes the address of the memory locations to each memory address. So 0 is written to address 0 up to 255 being written to address 255. It then reads each of the locations to verify that the memory address and data match to ensure the write / read operation was successful. It then erases the device by writing 0’s to all locations and then verifies that all locations contain 0.
To hook up the device:
- Connect 5V to Vcc pin and ground to ground pin
- Connect I2C by connecting SCL to SCL pin and SDA to SDA pin
- Ground the WP, A0, A1 and A2 pins
24C02 EEPROM Test Program
/* Basic 24C02 EEPROM Test Program Write data 0-255 to addresses 0-255 Read data back out and print to serial monitor window Erase all data Verify data is erased. Print any not erased to serial monitor window */ #include <Wire.h> // for I2C #define I2C_Addr 0x50 // device address byte data = 0; // data to store in or read from the EEPROM bool data_error = false; //=============================================================================== // Initialization - Do everything here since running just once //=============================================================================== void setup() { Serial.begin(9600); // Initialize the serial port Wire.begin(); // wake up the I2C // Write data to entire device Serial.println("Writing data..."); for (int i = 0; i < 256; i++) writeData(i, i); Serial.println("Writing Complete"); delay(1000); // Read data back out and print to Serial Monitor Serial.println("Reading data..."); delay(1000); for (int i = 0; i < 256; i++) { Serial.print(i); Serial.print(" : "); data = readData(i); Serial.println(data, DEC); if (data != i) data_error = true; // Data should match address } if (data_error) { Serial.println("Error in data Write/Read operation, check log above"); data_error = false; } else Serial.println("Write/Read Completed Successfully"); delay(1000); // Erase the entire EEPROM Serial.println("Erasing all data..."); for (int i = 0; i < 256; i++) { writeData(i, 0); // Write zeros to all memory locations } Serial.println("Erasing complete"); delay(1000); //Verify the erase operation Serial.println("Verifing data was erased..."); for (int i = 0; i < 256; i++) { data = readData(i); if (data != 0) { Serial.print(i); // Print all non-zero memory addresses Serial.print(" : "); Serial.println(data, DEC); data_error = true; } } if (data_error) Serial.println("Error(s) in erasing found"); else Serial.println("EEPROM Erase Verified - Test Complete"); data_error = false; } //=============================================================================== // Sub writeData - Writes a byte of data to memory address //=============================================================================== void writeData(unsigned int addr, byte data) { Wire.beginTransmission(I2C_Addr); // set the pointer position //Wire.write((int)(addr >> 8)); Wire.write((int)(addr & 0xFF)); Wire.write(data); Wire.endTransmission(); delay(10); } //=============================================================================== // Sub readData - Reads a byte of data from memory address //=============================================================================== byte readData(unsigned int addr) { byte result; Wire.beginTransmission(I2C_Addr); // set the pointer position //Wire.write((int)(addr >> 8)); Wire.write((int)(addr & 0xFF)); Wire.endTransmission(1); Wire.requestFrom(I2C_Addr, 1); // get the byte of data result = Wire.read(); return result; } //=============================================================================== // Main - Nothing to see here.... //=============================================================================== void loop() { }
Notes:
- None
Technical Specifications
Operational Ratings | ||
Vcc | 5V | |
Write Cycles | Min 500,000 | |
Data Retention | > 40 years | |
Package Type | Plastic body, DIP-8 | |
Mfr | China | |
Datasheet | Typical | 24C02N |