RSS Feed Email Facebook Twitter Stumbleupon Google Bookmark

I2C Analyzer - Monitor and Control I2C Bus

By I. Funa

There is almost no embedded system that has no peripheral devices. Even if the system needs only I/O lines there are many cases where the microcontroller has not enough pins. Port expanders are very popular because you can place them anywhere and you don't have to make long connections from the microcontroller to remote board areas for each I/O signal. Most port expanders and other peripheral devices use I2C bus to connect to the microcontroller.

I2C bus is a simple serial communication bus and protocol. It needs only two control signals, SCL and SDA. Writing software to support I2C devices is easy. Many microcontrollers have built-in hardware support. But even if the I2C is not directly supported you can write few short routines to send and receive data. I2C devices are simple to control so they are widely used even for projects intended for absolute beginners.

If you are developing embedded systems either professionally or just for fun you will sooner or later come into position where some devices will not respond to I2C commands or they won't behave as expected. In such cases there are only two basic approaches. The first one is to add debug routines to monitor I2C communication in order to find the cause of the problem. This approach works very well if the problem is in the software but it is time consuming and you need some skills to investigate data at right places and it doesn't find hardware related problems. The second approach means using external device to monitor I2C communication.

This way you can easily check if the software is sending right commands and if the device is responding properly. One popular method for I2C analysis is a module or extension for some digital storage oscilloscopes. This module enables decoding of I2C messages and displaying a complete communication over I2C bus. This is very convenient but costly debugging method because the price of the DSO including I2C module is beyond reach for many hobby programmers.

Another very popular but still professional way of debugging I2C bus is by using a simple USB to I2C interface. This device listens to the I2C communication and the software running on a PC decodes packets and displays all the data related to the I2C communication. It is also possible to save captured data for later analysis or to set triggers for specific events to capture only communication related to one I2C address.

Another great function of advanced I2C analyzers is the capability to act as I2C master. This way you can send I2C packets and receive responses from slave devices. This is the quickest way to discover what is not working as it should.

Such I2C devices are cheap and offer many advanced features also for decoding other popular protocols like SPI, JTAG and UART. They are very practical, be connected to any PC including laptop and some advanced models offer also basic functions of oscilloscope or logic analyzer. Once you see what packets are sent and how individual devices respond to commands from the software it is very easy to find the cause of the problem. In some cases it will be wrong I2C address that is being used or wrong packet format but it may also happen that the problem is in the faulty device or device connections.

About The Author
I. Funa: Interested in electronics, computers, web technologies, and internet marketing. Article Source: EzineArticles.com.


blog comments powered by Disqus