I am working with the STM32F4 microcontrollers. The I2C peripheral uses a clock setting.

I have been told that it does not matter when the peripheral is used as the slave device.

If that is true how is the proper hold time, alignment, and spacing before and after master clock edges maintained? i.e. If the clock falling edge of the master is received, and the slave device assumes a very slow clock rate, isn't it possible the slave device will change the data line too late, possibly after the next clock rising edge is received?

  • 1
    \$\begingroup\$ I believe it uses the other clock edge to synchronize. For example, the first transmission is the slave address. During this time, the data (for the slave) becomes valid on the rising edge. This means the device will detect the falling edge and the rising edge before reading the data - meaning it will know the clock rate. \$\endgroup\$ – Mewa Mar 6 '15 at 18:07

The bus master provides the clock. Therefore, the slave doesn't need to have clock generation parameters, as it's not generating the clock.

The slave doesn't need to know the speed of the clock coming in. It receives the falling edge of the clock, and then changes the data as soon as it can. In fact, it's required (by the spec) to change it within a certain time period of the falling edge of the clock (e.g. within 3.45 us in standard (100 kHz) mode).

The master will then latch the data on the rising edge of the clock. This cannot come "too soon" for the changed data to have arrived, because the spec again requires that the master's clock can't be too fast (min. low period of 4.7 us in standard mode).

There are other complications around hold times and limiting slew rates depending on which version of the I2C spec you're dealing with (and therefore which data rate you're using), but I won't go into that.

|improve this answer|||||
  • \$\begingroup\$ If a slave device does not use handshaking, it must perform updates to SDA within a short time of the falling edge on SCK. If a device does use handshaking, however, it may delay its transitions on SDA for much longer, provided that after a falling edge of SCK it quickly starts asserting that pin itself and continues to hold it until after it has changed SDA (or not) as required. \$\endgroup\$ – supercat Mar 6 '15 at 19:11
  • \$\begingroup\$ Yes, I forgot about that clock stretching hideousness :) \$\endgroup\$ – David Smith Mar 9 '15 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy