How Can I Monitor Clock Stretching on an I2C Bus?

Question from the Customer:

I would like to monitor the clock stretching that I am experiencing on the I2C bus. How can I do that?

Response from Technical Support:

Thanks for your question! Clock stretching is part of the functionality of I2C protocol; this feature is entirely transparent to the software. Clock stretching is when the I2C slave pulls the SCL (serial clock) line low, slowing down communication by “stretching” the clock. The clock is pulled low when the Slave is processing the data received from Master. After the data is processed, the device releases the clock line allowing the pull-up resistor to finally pull it high.  The master will issue a clock pulse only when the SCL is high. If the slave is holding it low the master waits until it goes high before continuing. Luckily,most microprocessors will handle this automatically.

The Total Phase Beagle I2C/SPI Protocol Analyzer together with the Data Center Software is the perfect tool for monitoring the I2C bus activity, in this case, specifically clock stretching.

 Beagle I2C/SPI Protocol Analyzer  Data Center Software

Figure 1: Beagle I2C/SPI Protocol Analyzer

Figure 2: Data Center Protocol Analyzer Software

In the Details pane of the Data Center Software output display, you can select the Timing tab to view the timing of each bit. Based on the I2C bus speed, you can calculate the expected duration rate of a bit and compare that value to the actual duration of the bit. This way, you can determine if clock stretching is occurring.

   Data Center Software and I2C Clock Stretching
  Figure 3: Data Center Software – Timing Pane

Note: The Data Center Software implements a timeout value of 250ms.  If a slave device clock stretches for longer than 250ms, the Data Center Software will report a TIMEOUT for the transaction.

If you are interested in how to implement clock stretching you may be interested in reading our blog When does the Aardvark I2C/SPI Host Adapter Enable Clock Stretching?

We hope this answers your question. Additional resources that you may find helpful include the following:

If you have questions about our Total Phase products, feel free to email us at sales@totalphase.com, or if you already own one of our devices and have a technical question, please submit a request for technical support.

Leave a Reply