Few questions about my I2C data

Hello folks, hope you are having a great day if the sun is still up in your part of the world; else, hope all is still ok.

I just built an I2C experiment to get myself more familiar with it. The point of the experiment is to make myself familiar with all the I2C data that is generated on my OScope.

The process is very simple as you can see. The User turns on the button on the Master and the signal goes through the I2C lines and turns on the LED on the slave. ( Both Master and Slave are NANOs in this case. )

Here comes the main point:
I hooked up the I2C bus to my OScope. You can see the OScope screenshots below.

  1. In Pic 1 below, In the top left corner, what does the -14.9340us mean?

  2. In Pic 1 below, In the top left corner, what does the address 0x10 ( in green ) mean?

  3. In Pic 1 below, In the top center, what does the 0x64 mean? ( This 0x64 is shown under the data column)

  4. As you can see in the Master sketch, we are writing either 100 or 101 to the slave. Are the '100' and '101' some how being represented by the pink square waves?

  5. If you look closely at the "DATA" column in Pic 1 and Pic 2, the value changes from 0x64 to 0x65. Why does it change and what does it mean? Does it mean it is transitioning from 'case 100' to 'case 101'? ( The cases are in the slave sketch)

  6. The slave address is 0X08 in the slave code. Is it supposed to show up, somewhere at all?

Other refernce pics are also included below.

Thank you for your replies!

Above is PIC # 1

Above is PIC #2.

Measure-SDS00001

Above is PIC # 3

Above is PIC#4

// MASTER CODE BEGINS BELOW.

#include <Wire.h>
const int signalSwitch = 4;
int switch1State = 0;
void setup()
{
  Wire.begin();
  pinMode(4, INPUT);  // Sets pin 4 as input.
}

void loop()
{
  switch1State = digitalRead(4);
  // send command to start blinking

  if (switch1State == HIGH) {

    Wire.beginTransmission( 0x08);
    Wire.write( 100);
    Wire.endTransmission();
    delay(2000);
  }

  else (switch1State == LOW); {
    // send command to stop blinking
    Wire.beginTransmission( 0x08);
    Wire.write( 101);
    Wire.endTransmission();
    delay(2000);
  }
}
// MASTER CODE ENDS HERE. 
// SLAVE CODE BEGINS BELOW 
#include <Wire.h>
volatile bool enableBlinking = false;

void setup()
{
  Wire.begin(0x08);   // join I2C bus as Slave with address 0x08
  Wire.onReceive( receiveEvent);

  pinMode( 13, OUTPUT);
}

void loop()
{
  if ( enableBlinking)
  {
    digitalWrite( 13, HIGH);
    delay( 100);
    digitalWrite( 13, LOW);
    delay( 100);
    
  }
}

void receiveEvent( int howMany)
{
  if ( howMany == 1)  // extra safety check, expecting just one byte
  {
    int x = Wire.read();
    switch ( x)
    {
      case 100:
        enableBlinking = true;
        break;
      case 101:
        enableBlinking = false;
        break;
    }
  }
}
// SLAVE CODE ENDS HERE.

I'd expect that's a time stamp. Check your scope's user manual to find out exactly what that is.

All of these are related and I'd suggest you read up on I2C operation. The slave address is always sent first, but it is 7 bits left justified with the least significant bit being an indicator of it being a read or write command. So the slave address of 0x8 looks like 0x10 when sent. The data you are sending, 100 or 101 (in decimal) are 0x64 and 0x65 in hexadecimal.
The pink trace, SDA, is the data, but each bit is only captured on the rising edge of the yellow trace, SCL. Your scope conveniently decodes all of this for you so you don't have to examine the traces.

2 Likes

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.