1
\$\begingroup\$

I am new to I2C and learning more about it from this TI document.

enter image description here

In the above image you can see that the slave address is provided twice. Why is that?

\$\endgroup\$

4 Answers 4

3
\$\begingroup\$

The I2C protocol is designed such that the slave address and R/#W bit are always sent (together) at a start (or repeated start).

When the master wants to read data from the slave, it first sends the slave address along with a write operation (R/#W = 0). Followed by the (start) address to read. This is done using the write operation.

Afterwards it has to switch to a read operation (R/#W = 1). This requires a repeated start along with slave address and the R/#W bit. Only then the slave takes control of the bus and can send the data.

A write-data operation is much simpler because the R/#W direction doesn't have to be changed. Therefore the master doesn't have to send a repeated start.

\$\endgroup\$
2
\$\begingroup\$

There are two transactions so the address needs to be written once per transaction.

The first transaction transfers a register address to the chip which you want to read.

The second transaction transfers the value of the register you wanted to read.

\$\endgroup\$
3
  • \$\begingroup\$ But for write operation device address is given only once \$\endgroup\$
    – Confused
    Commented Feb 1, 2023 at 9:04
  • 1
    \$\begingroup\$ @Hari That's because there's only one transaction; the master is already writing to the device so it just keeps writing data bytes. \$\endgroup\$
    – pipe
    Commented Feb 1, 2023 at 9:46
  • 1
    \$\begingroup\$ @Hari Yes, that is how the protocol of the chip works. Write and read are different. You must first write what kind of data you want to read. And you did only ask about the read. \$\endgroup\$
    – Justme
    Commented Feb 1, 2023 at 11:30
1
\$\begingroup\$

The first byte sent is the (7 bit) address appended with a R/W bit. The second byte sent is the inteded value for the slaves internal address pointer.

To read a specific register in the slave, the master must set the Slaves internal address pointer. This is done by writing the Slave address appended with R/W bit high. Next byte sent is the value the internal address pointer should have.

Now the the Master must send a Repested start because the Master will read this time. The Master sends the Slave address appended with R/W bit Low. Now the Master can read out the byte. The Slave will start with the register the internal address pointer is pointing to. After the first byte has been sent by the Slave, the address pointer increments. The Master can read additional bytes if it wants to. Uppon Finish, the Master Nacks. This will reset the internal state machine of the Slave.

\$\endgroup\$
-4
\$\begingroup\$

After every byte that is sent, the slave sends an acknowledge bit, to confirm, that the information has been received. It's the standard I2C protocol. The master resends the address, to ensure reliable data transfer from the two devices.

Regards Dario

\$\endgroup\$
1
  • 3
    \$\begingroup\$ That does not answer the question, and your reason why the address is transferred twice is not for reliability. \$\endgroup\$
    – Justme
    Commented Feb 1, 2023 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.