free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Rickey's World :: Discussion Forums :: Discuss and Learn :: 8051 Discussion Forum
 
<< Previous thread | Next thread >>
i2c eeprom 24c16 8051 interfacing problem..
Moderators: Ajay Bhargav, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph, ExperimenterUK, DavesGarage
Author Post
tweety bird
Tue Jun 30 2009, 11:06AM
 User Offline
Registered Member #7329
Joined: Sat Apr 19 2008, 08:49PM

Posts: 70
Thanked 8 times in 7 posts
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

Back to top

gopi
Tue Jun 30 2009, 08:53PM
 User Offline
Registered Member #9289
Joined: Fri Jul 25 2008, 05:04AM

Posts: 192
Thanked 12 times in 12 posts
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.

Never cry in front of others...........
Don't give them the pleasure of knowing how much they hurt you.
Back to top

tweety bird
Tue Jun 30 2009, 11:53PM
 User Offline
Registered Member #7329
Joined: Sat Apr 19 2008, 08:49PM

Posts: 70
Thanked 8 times in 7 posts
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 ???
Back to top

mangesh.ghugal
Wed Jul 01 2009, 05:38AM
 User Offline
Registered Member #7657
Joined: Mon May 05 2008, 03:27PM

Posts: 24
Thanked 2 times in 2 posts
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
Back to top

mangesh.ghugal
Wed Jul 01 2009, 05:39AM
 User Offline
Registered Member #7657
Joined: Mon May 05 2008, 03:27PM

Posts: 24
Thanked 2 times in 2 posts
also its better to conect the A),A1 A2 to GND
Back to top

gopi
Wed Jul 01 2009, 07:50PM
 User Offline
Registered Member #9289
Joined: Fri Jul 25 2008, 05:04AM

Posts: 192
Thanked 12 times in 12 posts
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.

Never cry in front of others...........
Don't give them the pleasure of knowing how much they hurt you.
Back to top

gopi
Wed Jul 01 2009, 07:52PM
 User Offline
Registered Member #9289
Joined: Fri Jul 25 2008, 05:04AM

Posts: 192
Thanked 12 times in 12 posts
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.

Never cry in front of others...........
Don't give them the pleasure of knowing how much they hurt you.
Back to top

tweety bird
Thu Jul 02 2009, 02:41AM
 User Offline
Registered Member #7329
Joined: Sat Apr 19 2008, 08:49PM

Posts: 70
Thanked 8 times in 7 posts
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....
Back to top

 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems