I2C SPI USB CAN eSPI Cable Testing View All Videos Quick Start Guides Software Downloads App Notes White Papers User Manuals Knowledge Base Sales Support About Us
Products Blog Sales Support Contact Search
What Causes I2C Clock Stretching? When Is It Needed?
Rena Ayeras

Question from the Customer:

We are using the Aardvark I2C/SPI Host Adapter as an I2C slave to test a master I2C port on another device. It appears the Aardvark adapter uses clock stretching while it is configured as a slave. Can you tell us what causes clock stretching?  When should we expect to see that feature occur?

Response from Technical Support:

Thanks for your question! The Aardvark I2C/SPI Host Adapter functionalities are based on I2C protocols. The I2C bus consists of only two lines, SDA (serial data) and SCL (serial clock). An I2C master device provides the SCL and controls the clock speed. After the master device initiates a data transfer, either an I2C master or an I2C slave device can send data. It is possible for a slave device to hold the SCL signal low, which “stretches” the clock and can halt the master device from transmitting data or commands. The purpose of clock stretching is to place the master device on hold.

Note: Although clock stretching is part of the I2C protocol, a master device, as well as a slave device, may or may not be designed to support clock stretching.

I2C Clock Stretching Support

The Aardvark adapter is designed to support clock stretching as either a master device or a slave device. However, only a slave device can initiate­ the clock stretch. The clock stretching feature cannot be disabled in the Aardvark adapter.

How Clock Stretching Is Used

Clock stretching allows an I2C slave device to force the master device into a wait state. A slave device may perform clock stretching when it needs more time to manage data, such as store received data, or prepare to transmit another byte of data. This typically occurs after the slave device has received and acknowledged a byte of data.

Which I2C Slave Devices Need Clock Stretching

Whether or not clock stretching is needed depends on the functions of the slave device. Here are two examples:

  • A processing device, such as a microprocessor or a microcontroller may need additional time to process an interrupt, receive and manage data, and perform the appropriate function(s).
  • A simpler device, such as an EEPROM, does not process data internally, so it does not need clock stretching to perform any of its functions.

Per the I2C protocol, there is no limit for the duration of a clock stretching period. However, if a timeout has been configured, a “bus lock” or other error may occur. For information about configuring timeouts, please refer to the API command “Set Bus Lock Timeout” in the Aardvark I2C/SPI Host Adapter User Manual.

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

If you have other questions about our host adapters or other Total Phase products, feel free to email us at sales@totalphase.com. You can also request a demo that is specific for your application.