4 Replies Latest reply on Jun 28, 2018 1:10 AM by RajathB_01

    Not successful in communicating with I2C device using CYPD-3125 core

      HI,

       

      Need some guide line on why I2C device read/write is not success. Iam using PSOC creator to creat MUX_CTRL I2C master component. REad/Write routine looks like below. All  I2C driver calls return success but returned value is not matching with what expected.

       

      Thank you,

       

      uint8_t I2CDeviceReadReg(uint8_t reg)

      {

           uint8_t writebuf[1]={0x0};

          uint8_t readbuf[1]={0};

          writebuf[0]=reg;

      .......

       

              MUX_CTRL_I2CMasterWriteBuf(ADDR,(uint8_t*)writebuf,1,MUX_CTRL_I2C_MODE_NO_STOP);

              while((MUX_CTRL_I2CMasterStatus() & MUX_CTRL_I2C_MSTAT_WR_CMPLT)==0){};

              MUX_CTRL_I2CMasterReadBuf(ADDR,(uint8_t*)readbuf,1,MUX_CTRL_I2C_MODE_REPEAT_START);

              while((MUX_CTRL_I2CMasterStatus() & MUX_CTRL_I2C_MSTAT_RD_CMPLT)==0){};

      ................       

      return 0;

      }

       

      void I2CDeviceWriteReg(uint8_t reg,uint8_t value)

      {

          uint8_t writebuf[2]={0};

         

          writebuf[0]=reg;

          writebuf[1]=value;

         

          MUX_CTRL_I2CMasterWriteBuf(ADDR,writebuf,2,MUX_CTRL_I2C_MODE_COMPLETE_XFER);

          while((MUX_CTRL_I2CMasterStatus() & MUX_CTRL_I2C_MSTAT_WR_CMPLT)==0){};

         

          return;

         

      }