This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Accessing external I2C EEPROM with Cypress EZ-USB dev kit

Hi

I'm trying to add an external EEPROM to my Cypress EZ-USB NX2LP-Flex dev kit, and accessing it using the library functions EZUSB_ReadI2C(), EZUSB_WriteI2C() and EZUSB_WaitForEEPROMWrite().

I plugged in a new 2Kbit EEPROM in the DIP socket and thought it was the only EEPROM there, and I tried reading it at address 0xA0, and was able to get all 0xFFs. I tried to write a single byte to the EEPROM with the following code:

   BYTE xdata temp1;
   BYTE xdata temp2[8];
   BOOL wrOK = FALSE;
   temp1 = 0x01;
   while (!wrOK)
      wrOK = EZUSB_WriteI2C(0xA0,0x01, &temp1);


I then read to read 8 bytes back with the following code

   EZUSB_ReadI2C(0xA0,0x08, &temp2);


Instead of getting all 0xFF except for the 1st byte, I got all 0x01.

I then realized that there are more than 1 I2C EEPROM connected to the SDA/SCL lines, so I'm wondering how do I address the correct one? And once I do that, how do I specify the memory address within the chip? I know the device address for all EEPROM starts with 1010(0xA), but I'm confused as to the later 4bits.

Thanks.

  • The specific EEPROM Datasheet will tell you how to assign the low-order address bits.

  • I've looked at the datasheets. The one I'm using is a Microchip 24AA08. According to the datasheet,

    3.6 Device Addressing
    A control byte is the first byte received following the
    Start condition from the master device (Figure 3-2).
    The control byte consists of a four-bit control code. For
    the 24XX08,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). B2 is a 'don't
    care' for the 24XX08. They are used by the master
    device to select which of the four 256 word-blocks of
    memory are to be accessed. These bits are in effect the
    three Most Significant bits of the word address.
    The last bit of the control byte defines the operation to
    be performed. When set to '1', a read operation is
    selected. When set to '0' a write operation is selected.
    Following the Start condition, the 24XX08 monitors the
    SDA bus checking the device type identifier being
    transmitted and, upon receiving a '1010' code, the
    slave device outputs an Acknowledge signal on the
    SDA line. Depending on the state of the R/W bit, the
    24XX08 will select a read or write operation.
    


    It seems to suggest that the lower order address bits are used to select among 4 banks within the chip, rather than to select the actual chip itself, out of many chips. This is why I'm confused. Isn't the 7bit I2C address meant to address devices, and not addresses within a device?

    This brings me to my next question, supposing I have the actual device address. How then would I address within the device using the EZUSB_WriteI2C() and EZUSB_ReadI2C() functions? These functions only allow me to specify device address, length and data structure to write from/read to. It doesn't let me specify the word address.

  • "How then would I address within the device using the EZUSB_WriteI2C() and EZUSB_ReadI2C() functions?"

    I think you said those functions were provided by Cypress - so you'll have to ask Cypress that one!

  • I was hoping people have used these functions before and could give me a faster response. The local Cypress reps aren't exactly very responsive or knowledgeable.

    Anyone else?

  • It seems to suggest that the lower order address bits are used to select among 4 banks within the chip, rather than to select the actual chip itself, out of many chips. This is why I'm confused. Isn't the 7bit I2C address meant to address devices, and not addresses within a device?
    1) you are right
    2) in this speial case, it makes sense. In the olden days, when the king of diamonds were still a jack, the IIC EEPROMS were small and had some pins you tied high or low to select the address so you could have 8 of the same chip with different addresses on the bus. So, visualize you chip as a replacement for 4 chips of 1/4 tha capacity. If this does not make it clear, find the datasheet for such a chip and you will see.

    Erik

  • "visualize you chip as a replacement for 4 chips of 1/4 tha capacity."

    In other words, this chip cannot share the bus with any other EEPROM?
    (unless the other EEPROM has a high-order address nibble other than 1010)

  • yes.

    I had a look at the datasheet and the PIG guys have confoooosed the defecation out of this.

    the 8 pin packages have A0. A1, A2 pins. A0, A1 are meaningless and A2 is not used (It should be to allow 2 such devices on the bus).

    Oh, well, the joy of using Microchip devices.

    I did not even know that a chip "addressed like 4 chips" existed. The EEPROMs I use (Ramtron) have a 2 byte memory address and A0-A2 are live allowing 8 devices on the IIC bus.

    Erik

  • Let me see if I understand you correctly.

    1) So in the olden days, the 3bits are used to select up to 8 IIC EEPROM devices on the same bus. However, once these devices started getting bigger than 256bytes, these 3 bits are actually used to select up to 8 256byte blocks?

    2) Since my device is a 1KB chip that's made up of 4 blocks, I am able to use the device address to actually address individual blocks within the chip?

    3) Since my device only has 4 blocks, I can actually use A2 to allow for 4 more blocks(can be another 1KB device, or 2 512byte chips, or 4 256byte chips, etc.)?

    4) I set the actual device address of the chip by pulling A2 up/down, hence setting it's address 10101XX or 10101XX.

    5) Actual word addressing would have to be done by some function other than EZUSB_WriteI2C() & EZUSB_ReadI2C() since these functions only allow device address as input parameters and not word address?

    Thanks!

  • 3) Since my device only has 4 blocks, I can actually use A2 to allow for 4 more blocks(can be another 1KB device, or 2 512byte chips, or 4 256byte chips, etc.)?

    4) I set the actual device address of the chip by pulling A2 up/down, hence setting it's address 10101XX or 10101XX.

    ... my quick read of the datasheet seems to indicat that A2 is ignored.

    You can use whatever you want, but for certainity of supply I would use an EEPROM with standard format (I use Ramtron - yes single supplier but, since the access format is standard, I can use any similar EEPROM in a pinch, just do not get the resiliance (which I can live without, but prefer and like)).

    Erik