EZUSB FX2 I2C EZUSB_WaitForEEPROMWrite() problem

Hi,

I'm trying to access an EEPROM with an EZUSB FX2 dev board. I have written the following code to write to the EEPROM

   eeprom_buf[0]  = LSB(0);
   eeprom_buf[1]  = value;
   eeprom_buf[2] = EZUSB_WriteI2C(0x53, 2, eeprom_buf);
   EZUSB_WaitForEEPROMWrite(0x53);


This writes the device I2C address(0x53), the internal EEPROM address(0) followed by the actual data value. It used to work, but suddenly it doesn't seem to work anymore.

I've checked the actual SDA/SCL lines to see what's going through, and it seems that the problem lies with EZUSB_WaitForEEPROMWrite(). Right before this function is called, the SDA waveform looks fine. It shows 101001100(address 0x53, a WR, and finally an ACK), followed by 000000000(address 0, ACK), followed by 000011100(value 0xE, ACK), then a 1(STOP).

Once I include the EZUSB_WaitForEEPROMWrite() function, the device address(1010011) keeps getting written to the bus over and over again, and the controller keeps receiving a NACK instead. EZUSB_WriteI2C() returns 1, so apparently it is successful.

Does anyone know why? Do I even need to run EZUSB_WaitForEEPROMWrite()?

Parents
  • After you send the write operation to the EEPROM, it is busy for a while. In this period, the EEPROM will not respond until the write is complete. This period is called as Write Cycle Time and it takes 5ms or so. See the datasheet of your EEPROM.

    EZUSB_WaitForEEPROMWrite() is designed to detect the response of the EEPROM. When you continue EEPROM operation further after the write operation, you need to call it to know the end of the write operation.

    Of course, you can insert another short task between the EEPROM operation.

    Tsuneo

Reply
  • After you send the write operation to the EEPROM, it is busy for a while. In this period, the EEPROM will not respond until the write is complete. This period is called as Write Cycle Time and it takes 5ms or so. See the datasheet of your EEPROM.

    EZUSB_WaitForEEPROMWrite() is designed to detect the response of the EEPROM. When you continue EEPROM operation further after the write operation, you need to call it to know the end of the write operation.

    Of course, you can insert another short task between the EEPROM operation.

    Tsuneo

Children
More questions in this forum