Wiki

The most recent version of this page is a draft.DiffThis version is outdated by a newer approved version.DiffThis version (02 Apr 2019 16:35) is a draft.
Approvals: 0/1

This is an old revision of the document!


Debugging I2C with the ADALM2000

Objective

The objective of this tutorial is to use the Logic Analyzer instrument provided by the ADALM2000 (M2K) board and the Scopy software toolset to visualize I2C (Inter-Integrated Circuit) transactions between two devices.

The ADT7420 PMOD Temperature Demo project will be used as an example. The project uses the EVAL-ADT7420-PMDZ connected to the EVAL-ADICUP360 microcontroller board. The PMOD includes the ADT7420 high accuracy digital temperature sensor.

The Demo application includes a function that reads and displays the temperature data from the ADT7420 and one that reads and displays the ID register data for ADT7420.

Background

I2C is a serial protocol for two-wire interface to connect low-speed peripheral integrated circuits like EEPROMs, A/D and D/A converters and other similar peripherals in embedded systems to processors and microcontrollers in short-distance (intra-board communication).

With I2C, you can connect multiple slaves to a single master and you can have multiple masters controlling single, or multiple slaves. This is really useful, for example, when you want to have more than one microcontroller writing data to a single memory card.

Figure 1. I2C master-slave configuration

Transmission lines:

  • SDA (Serial Data) – line for the master and slave to send and receive data
  • SCL (Serial Clock) – line that carries the clock signal

Being a serial communication protocol, the data is transferred bit by bit along a single wire (the SDA line).

I2C is synchronous, therefore the output of bits is synchronized to the sampling of bits by a clock signal shared between the master and the slave. The clock signal is always controlled by the master.

The data is transferred in messages composed of multiple frames. Each message has an address frame that contains the binary address of the slave, and one or more data frames. The message also includes start and stop conditions, read/write bits, and ACK/NACK bits between each data frame as presented in Figure 2.

Figure 2. I2C message content

Message components:

  • Start - SDA line switches from a high voltage level to a low voltage level before the SCL line switches from high to low.
  • Address Frame - master indicates the slave to which the message is being sent
  • Read/Write Bit - bit that indicates if the master is sending (low voltage level) or receiving (high voltage level) data from slave.
  • Data Frame - 8-bit data passed from master to slave or vice versa, starting with the most significant bit first (MSB)
  • ACK/NACK Bit - the ACK bit is returned from the receiving device if an address frame or data frame is received.

Hardware Configuration

Figure 3. shows the hardware connection between M2K board and EVAL-ADICUP360 + EVAL-ADT7420-PMDZ.

Figure 3. I2C Debug Hardware Setup

The I2C pins are available for monitoring at port PWMH of the EVAL-ADICUP360.

EVAL-ADICUP360 I2C pin configuration: Port PWMH:

  • Pin9 - SDA
  • Pin10 - SCL

Port POWER:

  • Pin6 - DGND

M2K I2C pin configuration:

  • DIO0 - SCL
  • DIO1 - SDA

Connect the M2K pins to the EVAL-ADICUP360 as follows:

  • Pin9 - DIO1
  • Pin10 - DIO0
  • GND - DGND

Scopy Logic Analyzer Configuration

Open the Logic Analyzer instrument, select DIO0-DIO1 lines and press the “Group with selected” button.

Figure 3. I2C Group Channels

Select the channel group formed and apply the I2C decoder. While the group is selected, open settings menu by pressing the button on the top right side of the user interface. A settings panel will appear for the I2C decoder, allowing the signal-channel configuration and parameters setup.

Figure 4. Group Settings

The Logic Analyzer must be set up to “catch” the I2C transfer on the Logic Analyzer plot. Therefore we need to configure a trigger. Since the I2C transfer starts when the Start signal is asserted low, the falling edge of the SDA channel can be used as the trigger.

Figure 5. Trigger Settings

I2C Transfer Example

This example verifies that for a given software command, the correct messages are transferred over I2C between master (EVAL-ADICUP360) and slave (EVAL-ADT7420-PMDZ).

The default I2C device address for EVAL-ADT7420-PMDZ is 0x48.

Read ID Register

Set the Time Base of the Logic Analyzer instrument to 50us and the Trigger Position at 200us and run a Single sweep.

Figure 6. General Settings

The Logic Analyzer will wait for the falling edge of the SDA signal to be triggered.

Run the “ADT7420_Read_One_Reg (ID_REG)” function. This will initiate the I2C transfer.

The result is presented in Figure 7.

Figure 7. I2C Read ID Register

Analyzing the plot, the fist message contains a write sequence composed of the device address (0x48) followed by the address of the ID register. The master then waits for the second message that is a read sequence containing the device address and one byte of data representing content of the ID register (0xCB).

Read Temperature

Set the Time Base of the Logic Analyzer instrument to 75us and the Trigger Position at 250us and run a Single sweep.

The Logic Analyzer will wait for the falling edge of the SDA signal to be triggered.

Run the “ADT7420_Read_Temp()” function. This will initiate the I2C transfer.

The result is presented in Figure 8.

Figure 8. I2C Read Temperature

Analyzing the plot, the fist message contains a write sequence composed of the device address (0x48) followed by the address of the temperature value MSB register. The master then waits for the second message that is a read sequence containing the device address and two bytes of data representing content of the temperature value most significant byte (0x0E) and temperature value least significant byte (0xE8).

Conclusion

In addition to I2C, the application includes a set of decoders covering a large number of communication protocols such as SPI, I2S, UART, JTAG, and others, making ADALM2000 a powerful tool for analyzing and debugging digital signals.

Further Reading:

university/courses/electronics/m2k-i2c-debug.1554215724.txt.gz · Last modified: 02 Apr 2019 16:35 by Antoniu Miclaus