# I2C protocol debugging using oscilloscope

We are testing an I2C accelerometer connected to the ATMega32A micro-controller. The accelerometer was working fine. We can write and read the registers using I2C protocol. When connected to the oscilloscope, we find it very hard to decode the signals to normal value.

We are just writing a value 0x08 (00001000) into the register 0x10 (00010000).

As per the I2C protocol, after the start condition we have to write SLA+W (slave address + write command). The 8-bit slave address with write command for the accelerometer is 0x30 (00110000).

I2C data must be like this

0 0 1 1 0 0 0 0       0(ack)      0 0 0 1 0 0 0 0     0(ack)     0 0 0 0 1 0 0 0     0(ack)


0(ack) is the acknowledgement of the I2C slave (accelerometer). Yet the signal we got from the oscilloscope gives no clue

The clock and I2C settings are as follows

• Controller clock: 4 MHz internal clock
• I2C frequency: 100 kHz
• Pull-up resistors: 4.7 kOhms

Here is the image of the I2C-clock (Yellow signal) and I2C-data (Blue signal) lines.

I really need someone's hand in it to help in decoding

• 4MHz is a very fast I2C clock frequency. Your scope readings look like they're undersampled. Try slowing down your clock, at least as a debugging step – Scott Seidman Oct 15 '14 at 14:52
• It's still true that the scope is not sampling fast enough for this task. Especially worrisome is the time relationship between channels - is that one ADC dividing its already insufficient sample rate (and thus introducing a sample worth of skew), or two ADCs at least taking their insufficient samples at about the same time? – Chris Stratton Oct 15 '14 at 15:08
• The pull up resistors are obviously not good enough. Replace them with 2.2K resistors and retry and re-scope the data/lines. – KyranF Oct 15 '14 at 15:18
• You really need to do another measurement but with good oscilloscope and probes. For instance I've made some measurement on a 100kHz I2C recently with a high-end oscilloscope, 500 MHz passives probes and a limiting bandwidth of 20 MHz and here is the result : toopix.eu/userfiles/5a718f0b27c2bfd2ffa02f54edc22cba.png (I was accessing a device at address 0x50) – zeqL Oct 15 '14 at 15:45
• The overall consensus is - scope is bad/not set up correctly? – KyranF Oct 15 '14 at 15:51