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

EZUSB I2C library issues

Hi,
I'm trying to use the EZUSB I2C library to access an external I2C EEPROM. The library provides the following functions to access the I2C bus

EZUSB_ReadI2C()
EZUSB_WriteI2C()

I've tried to use both functions to read from the FX2LP dev board's buttons as well as write to the 7-segment LED with success. However I'm having trouble accessing an I2C EEPROM.

As I understand, in order to read a byte from an I2C EEPROM, I have to first write the word address, then then read it back. So I wrote the following function

void EEPROMRead(WORD addr, BYTE length, BYTE xdata *buf)
{
   BYTE i = 1;
   BOOL rdOK = FALSE;

   rdOK = EZUSB_WriteI2C(EEPROM_ADDR, i, &addr);

   rdOK = EZUSB_ReadI2C(EEPROM_ADDR, length, buf);
}

However, this didn't work, and buf isn't touched at all, retaining its previous value.

I tried hooking up a logic analyzer to see what the exact signals look like, and strangely the signals don't correspond to what I'm telling the I2C functions! For example when I put a device address of 0xA0 for the EEPROM, what I see on the logic analyzer isn't 0xA0 but something else. Same deal when I try to access the on-board buttons and LED, even though they work!

This got me confused, so I tried manually setting the I2CS and I2DAT to send a write command to the address 0xA0, and this time, I see 0xA0 on the logic analyzer.

So, is there something wrong with the EZUSB I2C library functions, or am I missing something?

0