0 Replies Latest reply on Apr 1, 2010 2:12 AM by vincent.zhang

    When the I2C_SSTAT_RD_CMPT will be setting[I2C Slave Mode] ?

    vincent.zhang

      When I read the datasheet of I2C(I2CHW in PSoC Creator), I found when we use Slave mode, the function "uint8 I2C_SlaveStatus(void)" will be used to check the status for I2C Slave, and also, we can see the example code in the datasheet as below:

      uint8 wrBuf[10];
      uint8 userArray[10];
      uint8 byteCnt;
      I2C_SlaveInitWriteBuf((uint8 *) wrBuf, 10);
      /* Wait for I2C master to complete a write */
      for(;1 /* loop forever */
      {
      /* Wait for I2C master to complete a write */
      if(I2C_SlaveStatus( ) & I2C_SSTAT_RD_CMPT )
      {
      byteCnt = I2C_SlaveGetWriteBufSize( );
      I2C_SlaveClearReadStatus( );
      For(i=0; I < byteCnt; i++)
      {
      userArray = wrBuf; /* Transfer data */
      }
      I2C_SlaveClearWriteBuf( );
      }
      }



      Why we can use the I2C_SSTAT_RD_CMPT to indicate the I2C Master has complete a write?
      And I don't know when the I2C_SSTAT_RD_CMPT will be set?(if the I2C_SSTAT_RD_CMPT is set when we finished read the buffer, and when the last byte is transmitted, we will also read the wrBuf[], but then, the content in the buffer is not written by the Master?)