

The 25LC040 is a 4 Kbit (512 x 8) serial EEPROM manufactured by Microchip Technology. It is designed for non-volatile data storage, meaning it retains data even when power is removed. The component communicates using the Serial Peripheral Interface (SPI) protocol, making it suitable for a wide range of embedded systems and microcontroller-based applications.








The following table outlines the key technical details of the 25LC040:
| Parameter | Value |
|---|---|
| Memory Size | 4 Kbit (512 x 8) |
| Interface Protocol | SPI (Serial Peripheral Interface) |
| Operating Voltage Range | 2.5V to 5.5V |
| Maximum Clock Frequency | 10 MHz (at 4.5V to 5.5V) |
| Write Cycle Time | 5 ms (typical) |
| Endurance | 1,000,000 write cycles |
| Data Retention | 200 years |
| Operating Temperature | -40°C to +85°C |
| Package Types | PDIP, SOIC, TSSOP, MSOP |
The 25LC040 is typically available in an 8-pin package. The pinout and descriptions are as follows:
| Pin No. | Pin Name | Description |
|---|---|---|
| 1 | CS | Chip Select: Activates the device when pulled low. |
| 2 | SO | Serial Data Output: Outputs data to the SPI master. |
| 3 | WP | Write Protect: Disables write operations when pulled high. |
| 4 | VSS | Ground: Connect to system ground. |
| 5 | SI | Serial Data Input: Receives data from the SPI master. |
| 6 | SCK | Serial Clock: Clock signal for SPI communication. |
| 7 | HOLD | Hold: Pauses communication when pulled low (optional). |
| 8 | VCC | Power Supply: Connect to a voltage source (2.5V to 5.5V). |
Below is an example of how to interface the 25LC040 with an Arduino UNO using the SPI library:
#include <SPI.h>
// Pin definitions
const int CS_PIN = 10; // Chip Select pin connected to Arduino pin 10
void setup() {
// Initialize SPI and Chip Select pin
SPI.begin();
pinMode(CS_PIN, OUTPUT);
digitalWrite(CS_PIN, HIGH); // Deselect the chip
Serial.begin(9600);
}
void loop() {
// Example: Write and read a byte from the 25LC040
byte address = 0x00; // Memory address to write to
byte dataToWrite = 0x55; // Example data to write
byte readData;
// Write data to the EEPROM
writeEEPROM(address, dataToWrite);
// Read data back from the EEPROM
readData = readEEPROM(address);
// Print the read data to the Serial Monitor
Serial.print("Read Data: 0x");
Serial.println(readData, HEX);
delay(1000); // Wait for 1 second
}
void writeEEPROM(byte address, byte data) {
digitalWrite(CS_PIN, LOW); // Select the chip
SPI.transfer(0x02); // Send WRITE instruction
SPI.transfer(address); // Send memory address
SPI.transfer(data); // Send data byte
digitalWrite(CS_PIN, HIGH); // Deselect the chip
delay(5); // Wait for write cycle to complete
}
byte readEEPROM(byte address) {
byte data;
digitalWrite(CS_PIN, LOW); // Select the chip
SPI.transfer(0x03); // Send READ instruction
SPI.transfer(address); // Send memory address
data = SPI.transfer(0x00); // Read data byte
digitalWrite(CS_PIN, HIGH); // Deselect the chip
return data;
}
No Data Read from EEPROM:
Write Operations Not Working:
Corrupted Data:
Q: Can I use the 25LC040 with a 3.3V microcontroller?
A: Yes, the 25LC040 operates within a voltage range of 2.5V to 5.5V, making it compatible with 3.3V systems.
Q: How do I erase data from the EEPROM?
A: The 25LC040 does not have a dedicated erase command. Writing a 0xFF byte to a memory location effectively erases it.
Q: What happens if I exceed the write endurance limit?
A: After 1,000,000 write cycles, the memory cell may become unreliable, leading to potential data corruption.