Search code examples
i2cnxp-microcontroller

Acknowledgement in I2C slave


I read the I2C specification provided by nxp.but I am still not clear on some points. can you explain to me?

  1. normally slave is controlled by I2C master. Acknowledgment is enabled by I2C master then how slave generates I2C acknowledgment?
  2. I2C slave address and I2C data byte both are 1-byte data then how I2C slave differentiate between them?

Solution

  • Assuming i2c specification for nxp is identical to industry standard.

    1) I don't think that "acknowledgement is enabled by Master" is the correct term here. After each (full) byte sent by the Master it waits for the Slave to send back the acknowledgement bit (or the not acknowledgement ). The slave does this by changing the level of the SDA line.

    2) For transferring data from Master to Slave (and back) it is very important to keep the order of the sent bytes. A typical example would be like this:

    • Master sends: Start Signal
    • Master sends: Slave Address + Write-Bit
    • Slave sends: ACK
    • Master sends: Register Address the master wants to read
    • Slave sends: ACK
    • Master sends: repeated Start Signal
    • Master sends: Slave Address + Read-Bit
    • Slave sends: ACK
    • Slave sends: content of register Register Address the master wants to read
    • Master sends: NACK
    • Master sends: Stop Signal

    If you are looking for some more details on the I2C, there is plenty of it throughout the internet. For me, section 21 of this data sheet helped me a lot to understand.