tweety bird
Jun 30 2009, 11:06 AM
hi,, i was trying to interface 24c16b eeprom to 8051.. however i faced certain problems n doubts..
as 3 pins a0,a1,a2 are no connect in 24c16, so how do i have to address the byte write location..
how to address the memory locations in 24c16 ?? suppose i want to write at mem location 0, so should i pass 16bit address to memwr() routine...as 0x0000 ???
n suppose i wanna write at mem location 999, should i pass 0x03E7 ???
is this routine correct?
start();
i2c_write(0xA0);
i2c_memwr(0x0000);
i2c_data('a');
stop();
???
couldnt find a tutorial for i2c eeprom programmin or any C code ....
plz help
as 3 pins a0,a1,a2 are no connect in 24c16, so how do i have to address the byte write location..
how to address the memory locations in 24c16 ?? suppose i want to write at mem location 0, so should i pass 16bit address to memwr() routine...as 0x0000 ???
n suppose i wanna write at mem location 999, should i pass 0x03E7 ???
is this routine correct?
start();
i2c_write(0xA0);
i2c_memwr(0x0000);
i2c_data('a');
stop();
???
couldnt find a tutorial for i2c eeprom programmin or any C code ....
plz help
gopi
Jun 30 2009, 8:53 PM
The 1K, 2K, 4K, 8K and 16K EEPROM devices all require an 8-bit device address word following a start condition to enable the chip for a read or write operation.
The device address word consists of a mandatory one, zero sequence for the first four most significant bits. This is common to all the EEPROM devices. The next 3 bits are the A2, A1 and A0 device address bits for the 1K/2K EEPROM. These 3 bits must compare to their corresponding hard-wired input pins. The 4K EEPROM only uses the A2 and A1 device address bits with the third bit being a memory page address bit. The two device address bits must compare to their corresponding
hard-wired input pins. The A0 pin is no connect.
The 8K EEPROM only uses the A2 device address bit with the next 2 bits being for
memory page addressing. The A2 bit must compare to its corresponding hard-wired
input pin. The A1 and A0 pins are no connect.
The 16K does not use any device address bits but instead the 3 bits are used for memory
page addressing. These page addressing bits on the 4K, 8K and 16K devices
should be considered the most significant bits of the data word address which follows.
The A0, A1 and A2 pins are no connect.The eighth bit of the device address is the read/write operation select bit. A read operation
is initiated if this bit is high and a write operation is initiated if this bit is low.
Upon a compare of the device address, the EEPROM will output a zero. If a compare is
not made, the chip will return to a standby state.
The device address word consists of a mandatory one, zero sequence for the first four most significant bits. This is common to all the EEPROM devices. The next 3 bits are the A2, A1 and A0 device address bits for the 1K/2K EEPROM. These 3 bits must compare to their corresponding hard-wired input pins. The 4K EEPROM only uses the A2 and A1 device address bits with the third bit being a memory page address bit. The two device address bits must compare to their corresponding
hard-wired input pins. The A0 pin is no connect.
The 8K EEPROM only uses the A2 device address bit with the next 2 bits being for
memory page addressing. The A2 bit must compare to its corresponding hard-wired
input pin. The A1 and A0 pins are no connect.
The 16K does not use any device address bits but instead the 3 bits are used for memory
page addressing. These page addressing bits on the 4K, 8K and 16K devices
should be considered the most significant bits of the data word address which follows.
The A0, A1 and A2 pins are no connect.The eighth bit of the device address is the read/write operation select bit. A read operation
is initiated if this bit is high and a write operation is initiated if this bit is low.
Upon a compare of the device address, the EEPROM will output a zero. If a compare is
not made, the chip will return to a standby state.
tweety bird
Jun 30 2009, 11:53 PM
thx gopi but this i have read in the datasheet..
but i cudnt still understand the mem address format required to access any mem location in 16k memory....
it says 16k requires an 11 bit address...so do i have to use this 11 bit address?? or do i use 3 bits a2,a1,a0 as msbs of the 11 bit address during device address and pass a further 8 bit mem address making a total of 11 bits ???
but i cudnt still understand the mem address format required to access any mem location in 16k memory....
it says 16k requires an 11 bit address...so do i have to use this 11 bit address?? or do i use 3 bits a2,a1,a0 as msbs of the 11 bit address during device address and pass a further 8 bit mem address making a total of 11 bits ???
mangesh
Jul 1 2009, 5:38 AM
Hi..........
Please go through the Datasheet agin read carefully u will find that you can write the data with slave address as
start 1010 B1 B2 B3 R/W B,B2..are the block nos to which u want to write
that mean for writing slave address will become
1010 0000 -> for block 0
check it out wether it works or not
Please go through the Datasheet agin read carefully u will find that you can write the data with slave address as
start 1010 B1 B2 B3 R/W B,B2..are the block nos to which u want to write
that mean for writing slave address will become
1010 0000 -> for block 0
check it out wether it works or not
mangesh
Jul 1 2009, 5:39 AM
also its better to conect the A),A1 A2 to GND
gopi
Jul 1 2009, 7:50 PM
The control byte consists of a 4-bit control code, for the 24C16B this is set as 1010 binary for read and write operations. The next three bits of the control byte are the block select bits (B2, B1, B0). They are used by the master device to select which of the eight 256 word blocks of memory are to be accessed. These bits are in effect the three most significant bits of the word address.
gopi
Jul 1 2009, 7:52 PM
U dont need to worry about the hard-wired A0,A1&A2 pins. You can GND or Connect it to Vcc or Keep it open.
tweety bird
Jul 2 2009, 2:41 AM
ya i got it after some testin...
when i was reading the datasheet, dey said der u need an 11 bit code to address mem space...
so i was confused bw directly sending an 11 bit code or 3+8 bit format..
got it now, by using 3 bits of device address and further sending an 8 bit code to select mem space....
when i was reading the datasheet, dey said der u need an 11 bit code to address mem space...
so i was confused bw directly sending an 11 bit code or 3+8 bit format..
got it now, by using 3 bits of device address and further sending an 8 bit code to select mem space....