Engineers developing embedded systems have several options when it comes to selecting a communication protocol for their hardware device. One such option, the I2C communication protocol, offers unique advantages that make it an attractive choice for engineers.
The inter-integrated circuit or I2C communication protocol is a two-wire, clock synchronized protocol with a two-way data line and a one-way clock line. I2C protocol is fairly simple in the sense that it relies on just two lines of communication, but its complexity arises from the fact that all devices on the bus must communicate with each other using only these two lines. An I2C bus may have several master and slave devices connected on the same lines, and bus arbitration must be used to handle bus contentions and ensure that the correct data is driven on the bus.
I2C is asynchronous communication protocol, meaning that, like the SPI protocol, the output of bits is synchronized to the sampling of bits by a clock signal that is shared between the master and slave devices on the bus. In an I2C device, the master device always retains control of the clock signal.
To successfully achieve communication on an I2C bus, a number of initial conditions have to be satisfied. The wiring on the device must be done correctly, the bus speed must be set to a speed that is usable by the master and slave devices, and the proper pull-up resistors must be present within the system. The master device must send the proper commands and the slave device should respond appropriately with an acknowledge (ACK) bit when the commands are received.
A useful starting point for debugging your I2C system is performing verification that each of the above requirements is being fulfilled. Here are the most important best practices to follow when debugging your I2C system.
Most guidance documents for I2C circuit design recommend that the user first develops the master device and tests it completely with a test slave before continuing development. Testing cannot be fully completed until the master and slave have been integrated, but delaying testing until this late stage can result in complicated errors that are difficult to resolve.
Instead, embedded engineers should test the master with a test slave that provides the necessary interfaces along with some additional test hooks. The implementing a test slave can be done with a microcontroller that could be used for slave development, or by using an independent host adapter capable of emulating an I2C slave.
Master and slave devices should be tested independently to ensure their stand-alone functionality before integration. Certain issues related to timing and signaling may only crop up once the final integration of the circuit has taken place, but the majority of functional testing can occur using an interface-driven test environment for separate validation of the master and slave devices.
Designing slave devices represents the majority of the effort throughout the design process, and the functioning of the slave should be the focus of the majority of testing efforts. Testing the slave device using an I2C master device, rather than the real master device that will be present in the system, is preferable. A purpose-built I2C master, such as the Total Phase Aardvark I2C/SPI Host Adapter or Promira Serial Platform makes it easy to send test transmissions to the slave device and verify that it is working properly prior to its final integration with the circuit.
You debugging efforts should ensure that the I2C circuit satisfies all of the requirements necessary for its normal functioning. You can start the testing process by verifying each of the following features on the I2C bus:
Like homes in a row, each slave device on the bus is assigned a unique address where it can be contacted by the master device to facilitate data transmission.
The 100kHz I2C communication protocol was first established by Philips Electronics in 1982, with a 400kHz fast-mode added a decade later in 1992. As such, there are many tools available for developers that can assist with programming and debugging or troubleshooting I2C systems.
The Total Phase Aardvark I2C/SPI Host Adapter can act as an I2C master or slave device with up to 800 kHz. It allows a developer or embedded systems engineer to interface a Windows, Linux, or Mac OS X computer via USB to an embedded system environment and to transfer serial messages using either the I2C or SPI protocol.
For developers working with I2C Fast Mode Plus at 1 MHz or higher, should consider the Promira Serial Platform by Total Phase. In addition to supporting speeds up to 3.4 MHz as a master or slave for I2C, it also supports low power devices down to 0.9V.
If you are developing your own I2C product, the Total Phase Beagle I2C/SPI Protocol Analyzer is an easy-to-use diagnostic and troubleshooting tool that can monitor activity on the I2C bus up to 4 MHz. With its accompanying Data Center Software, the Beagle I2C/SPI analyzer allows embedded engineers to monitor the serial bus and analyze data transfer across the bus using the I2C communication protocol in real time. Protocol analyzers allow engineers to directly examine the behavior of the I2C master and slave devices on the bus by capturing and analyzing data directly from the bus.
If you any questions about our Total Phase products, feel free to email us at sales@totalphase.com. You can also request a demo that is specific for your application.