16 September 2006

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

Note: require lcd.h and i2c.h


Related Links
-24LC512 Products Page
-Interfacing I2C EEPROM (24LC256) with MCS-51 (KEIL C51)

15 comments:

Anonymous said...

hi..

i try to write with:
unsigned int i;

for(i=0x000; i<0x0FFF; i++)
{
// Write to EEPROM
}
but it just write until FF only why it become like that?

Thank You

MCU Programmer said...

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.

Anonymous said...

Thank You for your reply, actually i use your source code to write in the EEPROM512, so address start from 0x0000 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=0x000; 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=0x000; i<0x0FFF (here can be 2000 data); i++)
{
// Read from EEPROM
}
"

So, can you help me!

Thank You...

MCU Programmer said...

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
}

Anonymous said...

Thank you.. i will try soon...

i'll be back!

jagadeshwar said...

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

Anonymous said...

I am doing the same thing. How do you write into eeprom.

MCU Programmer said...

I write the EEPROM via I2C bus. I've write the routine in C called

EEPROM_set(address,data)

You can find it in 24xx512.h.

vscheeren said...

Hi,
I think there is a problem in the following lines of the code:
I2C_write(addr&0xF0);
I2C_write(addr&0x0F);
This makes you just send the last byte from addr. Then, you can just write until 0x00FF address. Thats the cause from the problem of anonymous above.
I didnt fix it yet, when i do i will post it here. But, maybe (I didnt test it) you can do:
I2C_write(addr&0xFF00);
I2C_write(addr&0x00FF);

Vinicius Scheeren

Anonymous said...

I tried to use program 24xx512.h
with WinAVR. I was attempting to upload that program to an Atmega8. But I had to use a generic makefile. When I enter make all I get this result: "make.exp no rule to make target '24xx512.elf', needed by 'elf' Stop"
I know this was not intended for AVR microcontrollers, perhaps that is why it doesn't work for me.

Unknown said...

hi ...
I am using above program for 24c64 ic but it can't write above the 0x100 addr. it can only write upto 0xFF why i can't understand plz hepl me..

Unknown said...

hi ...
I am using above program for 24c64 ic but it can't write above the 0x100 addr. it can only write upto 0xFF why i can't understand plz help me..

SAM said...

thank you very much for creating this blog and publishing such a useful information. only thing i didn't know was the write and read address of eeprom and i got it now because of you and one more thing sending address in mask mode. like one address twice with higher and lower bytes. i know this because of you.
thank you very much and god bless you.

Antonio8a said...

I don't understand why you put so:
I2C_write(addr&0xF0);
I2C_write(addr&0x0F);

Can I use your code to 24LC22A or 24LC1025?

Example if I use 24lc1025, Is the maximum address to write 128??
addr=128? and val=xxxx

Please help me!!

Sir Rules said...

please help me...im unable to produce or do function for i2c for the eeprom...please give some idea or just post the code so i can study them...a.s.a.p