EEPROMs Interfacing

24LC512 is a 64K x 8 (512 Kbit) Serial Electrically Erasable PROM (EEPROMs), from Microchip Technology Inc. (see the product page). It has been developed for advanced, low-power applications such as personal communications and data acquisition. This device also has a page write capability of up to 128 bytes of data.
This device is capable of both random and sequential reads up to the 512K boundary. Functional address lines allow up to eight devices on the same bus, for up to 4 Mbit address space.
This is an example how to interface 24XXX EEPROMs with 8051. I use SDCC as C Compiler. My schematic is shown below.
Schematic: 8051 interface to 24XXX EEPROMs
Datasheet
- 24LC512 [pdf]
Source Code (For SDCC)
- 24xx512.h
- test_eeprom.c
Related Links
-24LC512 Products Page
-Interfacing I2C EEPROM (24LC256) with MCS-51 (KEIL C51)

hi..
i try to write with:
unsigned int i;
for(i=0×000; i<0x0FFF; i++)
{
// Write to EEPROM
}
but it just write until FF only why it become like that?
Thank You
Hi,
Could you please explain more about your problem.
0x0FFF is the maximum number of iterations. That is not the value you write to EEPROM.
Thanks for your comment anyway.
Thank You for your reply, actually i use your source code to write in the EEPROM512, so address start from 0×0000 until 0xXXXX depend to the eeprom… so i want to write it continuously (Example: i want to collect 2000 data), so i’m just write it use this code:
“
unsigned int i;
for(i=0×000; i<0x0FFF (here can be 2000 data); i++)
{
// Write to EEPROM
}
”
But after finish the write i’m try to read it back… but it only read until 0xFF… for read i’m also using:
“
unsigned int i;
for(i=0×000; i<0x0FFF (here can be 2000 data); i++)
{
// Read from EEPROM
}
“
So, can you help me!
Thank You…
I’ve understood your problem. But, I can’t explore the cause of the error. So, I’d like suggest you try something like,
unsigned int i;
for(i=0; i<2000); i++)
{
// Write to EEPROM
}
and …
for(i=0; i<2000; i++)
{
// Read from EEPROM
}
Thank you.. i will try soon…
i’ll be back!
hai any one can send the C code for interfacing 24c04 with 8051
i can send the data “hello”,but while reading only first character is read
nice post, but I think that the delays with loops are not very profi and secure
Thanks for your suggestions, Sandu.
By the way, if you have the improvements, please free to report to it support thread
http://forum.mcuprogramming.com/80518052-b4/download-p89v51-code-for-sdcc/0/
I will Doug, but my code was written using Keil IDE, for AT89C5131 A-M, but I think can be applied to all MCS-51 family.
This chip from Atmel in particular has an I2C controller integrate but it allows only 8 bits addressing, which reduces the memory space that can be addressed, so I had to implemeted on software like you did here.
About delays I will submit my improvements, my main observation is that you should of used timers (0 , 1, 2) to generate precise delays.
That sounds good, Sandu.
Another, if you would like to contribute some of your work, please fee free to post in our tutorial section
http://forum.mcuprogramming.com/tutorials/0/