2 Replies Latest reply on Dec 6, 2018 4:17 PM by fawa_2830251

    I2C Master read specific byte from slave


      Hello everyone,


      Recently, I need to use I2C master component to read specific byte from slave with PSoC5LP development kit, but the mechanism in the I2C master sample code shows how to read whole buffer from slave.


      What I want is to when I key in 0x07 to PSoC, then the I2C master component will only read the value of 7th byte from slave without reading Byte0-6. Is there any hint/direction/sample code for me to implement the function?

        • 1. Re: I2C Master read specific byte from slave

          When your PSoC5 is the master then you need to act differently:

          When you want to read from a device you use (example for reading two bytes


              I2C_MasterSendStart(DeviceAddress,I2C_WRITE_XFER_MODE);    // Initialize a transaction for writing

              I2C_MasterWrite(Register);                // Indicate which register you want to write to


              I2C_MasterReadByte(I2C_ACK_DATA);            // Read first byte from register

              I2C_MasterReadByte(I2C_NAK_DATA);            // Read second byte from register, last byte is NAKed

              I2C_MasterSendStop();                    // End of transaction


          Not too difficult. Keep in mind that most of the APIs (except those for reading a byte) return a status byte which, when non-zero indicate an error condition.



          1 of 1 people found this helpful
          • 2. Re: I2C Master read specific byte from slave

            Hi Bob,


            Thanks for response, I've successfully implement the function in the demo board.