How to find the size of i2c eeprom?

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using 24lc512 and 24lc16 eeprom. Is there is any way to find the memory capacity of EEPROM by sending command on i2c?. Actually, I use these is according to requirement. so I want microcontroller automatically find which is connected on i2c. Presently I am thinking to write a byte on 2500 location of eeprom. If it is 64kb memory then the byte is written correctly otherwise if respond with 0XFF and then try to write using the function for 24lc16 (it require page and address, this is a separate function). If the value is written then I use the function for 16kb read/write. I try this on every power up.   

 

edit: Moved because it was not a tutorial and fixed the title for a clearer meaning. Moderator.

This topic has a solution.
Last Edited: Sat. May 4, 2019 - 11:24 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You only need to try this once - once you've determined what size the device is, you then write this in the first few bytes along with a CRC. From then on all you need to do is read the first few bytes, check the CRC then you now know what size the device is.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

check the datasheet of the components.

If there is a register you can read that will give you the info just read it. else you will need to read the device ID and in your code check what size belongs to the given device ID.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Device id for both is the same (0X50). And writing dummy byte (i already mention) may cause writing parameter on the wrong position(if performed on the wrong eerom). And there is no register which gives such information.

Last Edited: Fri. May 3, 2019 - 11:27 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Go on.   It is simple.   You write "Open Sesame" at location 0x0000.

 

Then read back from locations 0x0080,  0x0100, 0x0200, 0x0400, ... ,0x8000.

 

24C01 will repeat at 128 bytes, 24C02 will repeat at 256 bytes,  ... 24C256 will repeat at 0x8000.

 

24C01, 24C02 have 8-byte page buffers.  So you will see "amen Ses"

 

You only have to do this once.   But you can equally well just compare the existing contents of a page.   Obviously a magic sequence is a better test.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry,

 

I think I not explain my problem properly.

 

I want to find out which eeprom is connected on i2c. Both eeprom having different addressing methods. 24LC16 send page no with address and 24LC512 send 16 bit address for reading and writing.

 

As I told, In my algo, First I send write frame for 24lc16. Which contain page no ,address and data. Then I read same address. If it contain data which I write, then I assume it is 24LC16.

 

If I get not get same data then I send write frame for 24LC512. Which contain 16 bit address (2 byte address, high and low byte) and data. Then I send a read frame for same address. If data is same as I write then I assume it is 24LC512.

 

(Please see the datasheet of both eeprom (24lc16,24lc512) for addressing and frame format of read and write cycle.)

 

In this algo there is chance that, if write frame for 24lc16 is send,  but micrcontroller is connected with 24lc512,  then there is chance that data may written on any location where some other important data is present.

 

So I want to avoid this method. Can any one suggest some better way. 

 

     

Last Edited: Fri. May 3, 2019 - 02:55 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Same principle.   Write "Open Sesame" at location 8.  

The 24C16 has Page boundary at 0x0010.  This will write "Open Ses" in location 0x0008-0x000F and "ame" in location 0x0000-0x0002

 

24C16: 

<8><O><p><e><n< ><S><e><s><a><m><e>

24C512:  This will write "Open Sesame" at 0x0008-0x0012

<0><8><O><p><e><n< ><S><e><s><a><m><e>

If you write the 24C512 sequence to a 24C16,   it will store "\8Open Sesame" at location 0x0000.

If you write the 24C16 sequence to a 24C512,  it will store "pen Sesame" at location 0x084F

 

In other words,  it is easy to distinguish the two chips.   e.g. by intentionally writing over a Page boundary.

Or you can write a sequence and look for "repeats"

 

David.

Last Edited: Fri. May 3, 2019 - 04:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for replay,

 

Sorry, but what is  "pen Sesame" ,"ame" and "Open Sesame"

Last Edited: Fri. May 3, 2019 - 05:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you find a locked box full of treasure,  you just have to say "Open Sesame".

 

This gives you access to all the gold, silver and jewels in the box.

 

This works for English treasure.   You may need to use different "magic words" for foreign treasure.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
you just have to say "Open Sesame".
david.prentice wrote:
This works for English treasure.  

???  I did not know that Ali Baba was English.

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Everything important was always down to the Brits.

 

I looked up "Open Sesame" on Wikipedia.    It seems to be fairly universally known in the Western world.

 

I suspect that Arabic countries have never heard of Ali Baba.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
This works for English treasure.

I know we English love assimilating other peoples treasure and incorporating it as our own; but when I was told the story as a youngster; it was actually Persian treasure. smiley

(Strictly though; it was a Persian cave and I'm assuming the treasure hidden within was also Persian) 

 

@OP How on earth did you get into this situation with different chips at the same I2C device address ?

 

Last Edited: Fri. May 3, 2019 - 08:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

N.Winterbottom wrote:

@OP How on earth did you get into this situation with different chips at the same I2C device address ?

I guess it is a production variant. one variant has small eeprom and one variant has large eeprom. He just wants his code to be version independent so looks for a way to get that done.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would guess that it is a production variant too. Virgin chips are all 0xFF. You do not need to argue over "Open Sesame" or "Abracadabra". You can determine with a single byte ( except 0xFF)
.
Personally, I would diagnose the exact chip. Who knows what your assembly house will put on a future pcb?
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1



How to find the size of i2c eeprom?



 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

you just have to say "Open Sesame".

 

I always say this when I go to the supermarket, and the door always opens.

Getting away cleanly with the loot is another chapter.

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

Last Edited: Mon. May 6, 2019 - 09:14 PM