Not all I2C Serial EEPROMs are created equal. In fact there is a lot of variety out there as the memory size increases the addressing schemes change, the number and use of the device select pins change as well. The size increase reflects more or less closely the passing of time (years) and with it the evolution of the market of serial EEPROMs within and beyond the confines of the original specifications of the bus.
To be able to adapt the code developed in the previous postings, you will need to pay close attention to the details. To simplify the task, I have tried to collect in one big table the key elements that differentiate each device.
|24xx00||16||NC||NC||NC||No||1||NA||Available in SOT23-5 package|
|24xx01B||128||NC||NC||NC||Yes||1||8||Available in SOT23-5 package|
|24C01C||128||A0||A1||A2||No||1||16||Just like the -01B but with active device select lines|
|24xx014||128||A0||A1||A2||Yes||1||16||Just like the -01C but adds functional WP pin|
|24xx04B||512||B0||NC||NC||Yes||1||16||B0 is the address 9th bit|
|24xx08B||1k||B0||B1||NC||Yes||1||16||B0 and B1 are the address 9th and 10th bit|
|24xx16B||2k||B0||B1||B2||Yes||1||16||B0/B1/B2 are the address 9-10-11th bit|
|24xx515||64k||A0||A1||B0||Yes||2||128||B0 replaces the 15th bit (msb) of the address|
(Notice that I refer exclusively to the devices as implemented by Microchip as those are the ones I am more familiar with. Subtle implementation differences could be lurking here and there although you shouldn’t expect many…)
I used a bold font to highlight the main irregularities in the table. I also used the “xx” notation where you will find available “AA”, “LC” and sometimes “FC” options indicating respectively: low voltage (1.8V) devices, standard devices (2.5-5V) and fast devices (1MHz max. bus speed rated).
To try and make sense of the data I can offer a simplified summary in a few bullets:
- To reduce the die area (and therefore the price) small devices (below 256 byte capacity) do not support the device address pins (only one device can be connected to the bus at all times). Although if proper addressing is required, a -C model offering such functionality is available
- To keep the bus overhead low (using only one byte of address after the command byte) devices with capacity between 512 and 2k bytes (-04 to -16) use three bits of the command byte (in violation of the standard) to carry from 1 to three bits of the address (marked as B0/B1 and B2). As a consequence the device addressing is incomplete and only one device can be connected to the bus.
- Memory sizes at or above 4k bytes require a second address byte following the command byte
- The write buffer (page) size grows somewhat linearly with the size of the array, but there are notable exceptions, watch out!
The SEE24.c module presented recently was designed for the 24xx16B type of Serial EEPROM, a device that you will find right in the middle of the table and, as you can see, perhaps not representing the most generic case. Depending on the memory size required by your application you will need to:
- apply minor changes to the addressSEE() function (adding a second address byte and moving the msb address bits there)
or in case you are planning to use the smallest devices available (24xx00) that do not offer a write (page) buffer:
- modify the writeSEE() function to separate the two data byte write commands in two independent complete write sequences
As a final note, it is possible to write code for a microcontroller to detect automatically the type and size of the Serial EEPROM connected to the bus, but this is far from being a universal algorithm. It is possible, but only within the confines of a single manufacturer and possibly a subset of the entire product range, see AN690 for one of my early attempts…