0
\$\begingroup\$

I have studied the I2C and SPI communication protocols, but one thing has been confusing for me. In the case of the SPI we have shift registers at both ends and with the help of the SPI rising clock edge the data shifts from the master to the slave. In the case of I2C, I have seen that the values are only transferred if the clock is high. The first question is that if the first value is shifted and we still have a high voltage, then the second bit can also be shifted in the same clock cycle. Secondly, in i2C, it means we do not have a clock on the edges and hence shift registers are not activated on the edges therefore the same problem can occur on the receiver end. The receiver buffer continues to take the two or many values if the clock is high?? Kindly help me clarify this confusion.

\$\endgroup\$

3 Answers 3

1
\$\begingroup\$

When receiving, data is typically clocked in on a clock edge. This is because its convenient and the specs say the data is stable at that point. In controllers with SPI peripheral you can usually adjust when data is clocked in using some control register bit called CPOL and CPHA.

Bellow an excerpt from the datasheet of a nordic semiconductor IC:

nordicsemi NRF52811 SPI timings

You can see that the data is stable for some short time after a clock change.

In I2C it is the same. Here a snippet of the I2C spec from NXP:

I2C Data validity

You can see that the data USDA must be stable when the clock line USCL changes. You can pick any clock edge to trigger the data shift. Or (in this case) even randomly choose some point between the clock flanks to sample the data. Typically you will want to sample on the rising edge of the clock because some implementations will not honor the falling timings. Have a look at the timing diagram bellow:

NXP I2C Timing Diagram

The key parameters are Data set up time (tSU;DAT) and Data valid time (tVD;DAT)

Sources:

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Maximilian - Hi, Please remember the site rule which requires that when a post includes content (e.g. text, image, photo etc.) copied or adapted from elsewhere, that content must be correctly referenced by the post's author. As a minimum, the source webpage or PDF etc. should be linked (see that rule regarding references for books / articles etc.). I saw that you mentioned the sources in the (usually invisible) HTML alt text, however actual links to the sources are required. Please can you edit your post and add those required links? Thanks. \$\endgroup\$
    – SamGibson
    Jul 12, 2023 at 12:50
1
\$\begingroup\$

In I2C, the "high" states are reached through a pull-up resistor, these aren't actively driven. As such, the rising edges are fairly round, and the exact timing of the edge detector is not entirely well-defined.

So, each bit is transferred at a rising edge of the clock, and the clock needs to be pulled low between bits.

If the data line changes while the clock is high, that is either a start or a stop condition.

\$\endgroup\$
0
\$\begingroup\$

With I2C, each clock pulse sends one bit just like with SPI. No difference there.

The data wire is updated by transmitter while clock is low and kept stable while clock is high.

An I2C device loads the data bit in from bus on the rising edge and on falling edge an I2C device sets the data bit to bus.

\$\endgroup\$

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.