addressing 16K eeprom ??

Thread Starter

hadeedunhaad

Joined Apr 22, 2011
24
I'm interfacing 8052 with 24c16 eeprom. Everything works in charm, suddenly a new problem popped up. I can't address the memory location after 0ffh (255 bytes), for that i need more than 8 bits address. And i tried the following code, in which the 16 bit address is written to the DPTR.
But it doesn't seems to be working. All the subroutines in the below code works perfect.

Can any one point me where exactly am i committing mistake ?


Rich (BB code):
read_data: 
                acall I2C_start
                mov a,#0ah                 ; address of the I2C device
                acall send_data
                mov a,dph                   ; location address
                acall send_data
                mov a,dpl                    ; location address
                acall send_data
              ; acall I2C_delay
                acall I2C_start
                mov a, #0a1h
                acall send_data
                acall  get_data
                acall I2C_stop
                ret
 
Last edited:

hgmjr

Joined Jan 28, 2005
9,027
The 24C16 uses the device pins 1, 2, and 3 to specify which of the 256 byte blocks you are addressing. There are eight 256 byte blocks within the part.

hgmjr
 

Thread Starter

hadeedunhaad

Joined Apr 22, 2011
24
oh ! is it ? I just knew that A0, A1 & A2 are used as device addresses to support multiple devices on the same bus, and since At24c16 doesn't support this all these pins are grounded.

yeah ! i found something now. How did i missed this para ? i found it in its datasheet.



Thank you. I shall get back if i face any further troubles, let me check whether i can read all places well.
 

Thread Starter

hadeedunhaad

Joined Apr 22, 2011
24
from what the data sheet says below,



128 x 16 = 2k ; so what i understood is that only 2K is possible to be addressed, and innorder to address the next 2k part, the combination of 1,2,3 of the eeprom need to be changed, and the total combinations possible are 8.
Hence 2k x 8 = 16 k. That sounds ok. Am i correct ?

if so my question repeats, how can i address the first 2k where i need more than a byte address which i tried (the code posted above) and found to be not working ?
 

hgmjr

Joined Jan 28, 2005
9,027
The 24C16 is not a 16K by 8-bit device. The 16K refers to the total number of bits in the device. In other words, what you have is a device with a total of 16384/8 or 2048 bytes of memory. In a 2048 byte memory you have eight 256 byte banks. That means the 3 pins (B0, B1, & B2) on the device (in the case of the 24C16) permit you to address each of the eight 256 byte banks uniquely.

hgmjr
 

mehtadhaval

Joined Sep 21, 2007
9
1). AT24C16 contains a total of 2KByte memory
2). For AT24C16, A0, A1 and A2 pins are "No Connect"
3). To access addresses beyond 255, you will have to select Memory Page. For that, whn you are transmitting the 0101 sequence, after that, the 3 bits (known as P2, P1, P0) selects the Page. For example, if P0 = 0, P1 = 0, P2 = 0, then address 0x00 will access memory location 0x00. But, when P0 = 1, P1 = 0, P2 = 0, then address 0x00 will access memory location 0x100 (256).
 

Thread Starter

hadeedunhaad

Joined Apr 22, 2011
24
that was shocking , i never expected such a twist.
In my project i need atleast 18,000 bytes for data storage, ie roughly speaking 18KBytes. In that case which chip would you recommend me to go with ? I need I2C device and low cost. Waiting for your advice.

Thank you 'hgmjr' and 'mehtadhaval' for your very valuable and on time information.
 

AlexR

Joined Jan 16, 2008
732
Take a look at the 24LC256 from Microchip. It has an I2C interface and is a 32K x 8 device. If all you need is 16Kbyte then go for the 24LC128.
 
Top