Look at this scope capture of I2C

Greetings all,

So I am a rookie and just got my first oscilloscope. So I decided to see if the scope can pull in the SDA of my MCP23017 circuit so I see what it looks like. But it doesn’t look as expected. Can it be the 4.7k resistors? Take a look at the image capture below.

Here’s some code for GeeWiz Sakes:

byte address = 0x20;
int ledWhich = 1;
int led = 0;

void setup(){
    Wire.setSpeed(CLOCK_SPEED_400KHZ);
    Wire.begin();
    
    Wire.beginTransmission(address);
    Wire.write(0x00);
    Wire.write(0x01);
    Wire.endTransmission();
    
    Wire.beginTransmission(address);
    Wire.write(0x01);
    Wire.write(0x00);
    Wire.endTransmission();
    
    
}

void loop(){
    
    Wire.beginTransmission(address);
    Wire.write(0x12);
    Wire.endTransmission();
    
    Wire.requestFrom(address, 1);
    led = Wire.read();
    Wire.beginTransmission(address);
    Wire.write(0x13);
    Wire.write(led);
    Wire.endTransmission();
    
    delay(200);
    
    // if (led < 0x80){
    //     led = led << 1;
    // }else if(led == 0x80){
    //     led = led >> 7;
    // }

}

I don’t know if that’s unusual, but I2C works such that SDA is changed on the falling edge of SCL and tested on the rising edge of SCL. Because of this, the edges on SDA signal don’t need to be clean for it to operate correctly.

you’ve calibrated the probes and have a nice, pretty square wave (perfectly square, no noisy bits)?

Yes. I used the self testing hooks on the front of the scope and it’s nice and clean there.

I’ve played with an RC circuit get pretty cool results there as well

scope display looks like it is undersampled. Needs sampling rate 10x bit rate to get clean display. Also, the undershoot looks like scope probe grounding is not correct.

1 Like

It’s also a lot easier to debug I2C if you can see both clock and data. Hook up both channels at the same time and take a sweep?