4 Replies Latest reply on Jun 17, 2019 2:37 AM by user_2903406

    FX2LP I2C does not work properly, EZUSB_WriteI2C does not return

    docs_3756686

      Hello,

       

      I am writing an FX2LP firmware, and I would like to read the battery voltage through I2C.

      I implement my version based on I2C Read/Write in FX2LP - KBA224159  and https://www.cypress.com/documentation/application-notes/an45471-create-your-own-usb-vendor-commands-using-fx2lp

      However it does not work, when I want to read via I2C.


      I init the the I2C with the following code in the TD_init function:

       

      EZUSB_InitI2C(); // Initialize I2C Bus

      I2CTL |= 0x01; //400kHz

       

      I2C communication code is in the getBatteryInfo() funciton:

      BYTE xdata BUFFER[1];

      BYTE xdata ee_str[1];

      BYTE I2C_ADD = 0x6C;

      ee_str[0] = 0x09;

      EZUSB_WriteI2C(I2C_ADD, 1, ee_str);

      EZUSB_ReadI2C(0x09, 0x01, BUFFER);

      return BUFFER[0];

       

      I tried to debug the code. I figured out that the EZUSB_WriteI2C function does not return, it stuck in the while loop. It seems that the I2CPckt.status hasnot got the good value.

       

      I attached my code, please help, i have tried everthing.

       

      Thanks,

      Domi