You need to test, we're here to help.

You need to test, we're here to help.

22 July 2015

Debugging I2C Buses in Embedded Systems

Debugging of I2C on a Teledyne LeCroy WaveSurfer 3000 oscilloscope
Figure 1: Debugging of I2C on a Teledyne LeCroy
WaveSurfer 3000 oscilloscope
Embedded systems became ubiquitous decades ago and are now found in everything from mobile devices to vehicles to the traffic lights that control their movements. These days, they're typically based on microcontrollers and perform some specific task(s) within a larger system, such as controlling your car's ABS system. They may or may not have any sort of user interface, and can range widely in terms of complexity and functionality.

Anything beyond the absolutely simplest embedded systems will need to communicate with the outside world, and that is most typically done using synchronous serial-communication protocols. Three common examples of such protocols are I2C, SPI, and UART. Today's digital oscilloscopes are well up to the task of debugging serial links. Let's take a look at each of these protocols in turn and how an oscilloscope can ease the task. In this case, we'll be looking at screen captures of an I2C waveform from a Teledyne LeCroy WaveSurfer 3000 oscilloscope (Figure 1).

The Inter-Integrated Circuit (I2C) Protocol

The breakdown of a basic I2C packet
Figure 2: The breakdown of a basic I2C packet
I2C is a master/slave synchronous communication protocol that delivers data rates up to 3.4 Mb/s. It uses two bidirectional lines for signaling (clock and data). Slaves are addressed using unique addresses which can be in either a 7- or 10-bit format (Figure 2). An I2C system can have multiple masters, each with a unique address. Data transfers are initiated by the master with a start bit followed by the address of the intended slave and a read or write bit to indicate the nature of the transfer. Slaves respond with an ACK (acknowledge) bit.

Now is as good a time as any to mention the utility of color-coded overlays in an oscilloscope's trigger/decode software. Color coding of the data stream makes for a much more informative and intuitive display. Depending on the timebase and the amount of zoom that's applied, the decoded stream is expanded or condensed for improved understanding of events during long or short acquisitions.

The I2C trigger decode software provides a wide range of triggering capabilities that enable quick location and isolation of events on the bus. There are simple triggers such as Start, Stop, No Ack, or Restart as well as more advanced triggering. Conditional data triggering allows selection of a range of data values to trigger on and not just a single value. Examples include less than, greater than, in range, and out of range. 

Just below the graticule in Figure 1 is a table display that summarizes protocol information. The table allows you to use the oscilloscope like a protocol analyzer; the table can be custom configured to display the desired data and export it to an Excel file if you like. Touching an entry in the table automatically opens a zoom view of that portion of the acquisition. The table never obscures the view of the waveform.

In the Address Setup section of the I2C trigger/decode dialog box (Figure 1 again), you can configure an address trigger in binary or hex and in either 7- or 10-bit formats. You can also decide to include or exclude the read/write bit in the address depending on how your I2C bus operates.

The Data Pattern Setup section of the dialog box exemplifies the power of modern decode/trigger software. Here, you can set up the oscilloscope to trigger on Address + Data, or only on Data; data patterns may be entered in binary or hex. Binary triggering offers triggering on individual bits while hex triggering simplifies the setup of long data pattern triggers (up to 12-byte patterns are supported).

In the next post, we'll look more closely at the Serial Peripheral Interface (SPI) protocol.

No comments:

Post a Comment