24c04 eeprom's writing/reading

Status
Not open for further replies.

blacksnow

Junior Member level 2
Joined
Mar 1, 2010
Messages
20
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Location
India
Activity points
1,432
I wrote a simple program to write and read 0x99 to address 0x0077 of 24c04 but the simulation does'nt read the value 0x99 from that address instead it reads 0x77 from 0x0077.

In the proteus file i changed the serial eeprom with 24c32, 24c64, 24c128 and 24c256 and it worked fine and written and read the value 0x99 to/from address 0x0077 successfully. But with 24c04 this does'nt work. Please suggest some solution or rectify the problem.

The Proteus Simulation is attached.

Thanks
 

I think 24c04 and 24c32, 24c64, 24c128 have diffr. block address
 

    blacksnow

    Points: 2
    Helpful Answer Positive Rating
for 24c01 to 24c16 (including 24c04) you have only 1 byte for addressing... (works fine with 24c01 and 24c02) for extra addressing you must use the 3 lower bits of I2c-address

so you must chage your writing/readings routines...
{the extra stuff over 0xA0 to the 3bit extra addressing... }
Code:
unsigned char ReadBYTE(unsigned int Addr)
{
   	unsigned char Data;
	Start();
	WriteI2C(0xA0 | ((Addr>>7)&0x0E));
	
	WriteI2C((unsigned char)Addr&0xFF);
	
	Start();
	
	WriteI2C(0xA1);
	Data = ReadI2C();
	
	Stop();
   	return(Data);
}


void WriteBYTE(unsigned int Addr,unsigned char Data)
{
	Start();

	WriteI2C(0xA0  | ((Addr>>7)&0x0E));
	
	WriteI2C((unsigned char)Addr&0xFF);			// send address low	

	WriteI2C(Data);
	Stop();	
}
 
Thanks a lot. It has worked now.
 

    V

    Points: 2
    Helpful Answer Positive Rating
i am using eeprom 24c08, i wanto to store an many strings into eeprom one string is of 4 bytes. but i dont know how to put it in eeprom. can anyone send me the code for 8051 (keil) or PIC (using MIKROC) in C language.....the string is of having 1000 each of 4 bytes. plz send me the code....
thankyou...
email id: ashu_aka88@yahoo.com
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…