I2C communication

Hello,

I have to send some data to a device using I2C but I have a time constraint of 20ms to send everything

I am currently using two Arduinos to do my test (Arduino Yun as a master and Arduino Uno as a slave) and I managed to send everything within 76ms (see picture time)

I also noticed a gap between the end of a transaction and the beginning of a new one (see picture gap), any idea where this could come from ?

Do you know how I could make all of my transaction to be done faster ?

Here is my code:

#include <Wire.h>

long list[336] = {0x00000008, 0x0000431E, 0x00000008, 0x0000431E, 0x00000028, 0x02051801, 0x00004020, 0x38300000, 0x00004018, 0x00000021,0x00004410, 0x00003737,0x00004000, 0x11000a74,0x00004024, 0x0303249b,0x00000060, 0x00000000,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x00005000, 0x11000a74,0x00005024, 0x0303249b,0x00000060, 0x00000020,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x00006000, 0x11000a74,0x00006024, 0x0303249b,0x00000060, 0x00000040,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x00007000, 0x11000a74,0x00007024, 0x0303249b,0x00000060, 0x00000060,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x00004800, 0x11000a74,0x00004824, 0x0303249b,0x00000060, 0x00000010,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x00005800, 0x11000a74,0x00005824, 0x0303249b,0x00000060, 0x00000030,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x00006800, 0x11000a74,0x00006824, 0x0303249b,0x00000060, 0x00000050,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x00007800, 0x11000a74,0x00007824, 0x0303249b,0x00000060, 0x00000070,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x0000002c, 0x00000865,0x00000008, 0x00002318};

byte data[4];

void setup() {
  Wire.begin(); // Initiate the Wire library
  Wire.setClock(400000L);
}

void loop() {
  for(int i = 0; i < 335;)
  {
    Wire.beginTransmission(0x77);
    /*if(i==0)
    {
      Wire.write(0x42);
    }
    else if(i==334)
    {
      Wire.write(0x41);
    }
    else
    {
      Wire.write(0x40);
    }*/
    switch (i)
    {
      case 0:
        Wire.write(0x42);
        break;
      case 334:
        Wire.write(0x41);
        break;
      default:
        Wire.write(0x40);
        break;
    }
    data[0] = 0x07;
    data[1] = 0x0F; 
    data[2] = list[i] & 0xff;
    data[3] = (list[i] >> 8) & 0xff;    
    i++;
    Wire.write(data, 4);
    data[0] = list[i] & 0xff;
    data[1] = (list[i] >> 8) & 0xff;
    data[2] = (list[i] >> 16) & 0xff;
    data[3] = (list[i] >> 24) & 0xff;
    i++;
    Wire.write(data, 4);
    Wire.endTransmission();
  }
  delay(500);
}

Both Arduinos and my device work in 400kHz mode

Thank you for your help !!!

I have tested a setup using UNO and NANO where I can send your data in 55 mS. The improvement I have made by sending 27 bytes (we cannot exceed 32 is which Wire's FIFO max size) data in one pass instead of 9 bytes that you have done. Further improvement could be possible by changing the buffer size in the Wire.h Library?

I also noticed a gap between the end of a transaction and the beginning of a new one (see picture gap), any idea where this could come from ?

Yes, your code is run there. The preparation of the 9 bytes in each loop need about that time. The data is actually sent in the Wire.endTransmission() call. Everything else just fills a buffer and does some calculations which need time.
The gap at the beginning (just after the address is sent) is from the slave having to enter the reception interrupt, during that the slave stretches the clock, so the master has to wait.

Do you know how I could make all of my transaction to be done faster ?

Using SPI? If you need to transfer about 3kB of data you need a bit rate of more than 1.5MHz, not counting any acknowledgement losses. I guess with a 4MHz SPI connection you should be below 20ms.

Why do you think you have to transmit the data? What exactly is the UNO doing the Yun can’t do?

Hello,

I tried to change the buffer size from 32 to 64 and I managed to reach 64ms.
I also modified my code to send 54 bytes, here is the new one :

#include <Wire.h>

long list[336] = {0x00000008, 0x0000431E, 0x00000008, 0x0000431E, 0x00000028, 0x02051801, 0x00004020, 0x38300000, 0x00004018, 0x00000021,0x00004410, 0x00003737,0x00004000, 0x11000a74,0x00004024, 0x0303249b,0x00000060, 0x00000000,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x00005000, 0x11000a74,0x00005024, 0x0303249b,0x00000060, 0x00000020,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x00006000, 0x11000a74,0x00006024, 0x0303249b,0x00000060, 0x00000040,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x00007000, 0x11000a74,0x00007024, 0x0303249b,0x00000060, 0x00000060,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x00004800, 0x11000a74,0x00004824, 0x0303249b,0x00000060, 0x00000010,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x00005800, 0x11000a74,0x00005824, 0x0303249b,0x00000060, 0x00000030,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x00006800, 0x11000a74,0x00006824, 0x0303249b,0x00000060, 0x00000050,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x00007800, 0x11000a74,0x00007824, 0x0303249b,0x00000060, 0x00000070,0x00000064, 0x0039805e,0x00000064, 0x00388059,0x00000064, 0x002080fb,0x00000064, 0x00e380fc,0x00000064, 0x001380fd,0x00000064, 0x000480c1,0x00000064, 0x000080c2,0x00000064, 0x0000e03D,0x00000064, 0x001dE077,0x00000064, 0x0050E094,0x00000064, 0x00018056,0x00000064, 0x00048057,0x00000064, 0x0060805f,0x00000064, 0x00018062,0x00000064, 0x00008063,0x00000064, 0x00018065,0x00000064, 0x0040e043,0x0000002c, 0x00000865,0x00000008, 0x00002318};

byte data[4];

void setup() {
  Wire.begin(); // Initiate the Wire library
  Wire.setClock(400000L);
}

void loop() {
  for(int i = 0; i < 335;)
  {
    Wire.beginTransmission(0x77);
    for (int j = 0; j < 6; j++)
    {
      switch (i)
      {
        case 0:
          Wire.write(0x42);
          break;
        case 334:
          Wire.write(0x41);
          break;
        default:
          Wire.write(0x40);
          break;
      }
      data[0] = 0x07;
      data[1] = 0x0F; 
      data[2] = list[i] & 0xff;
      data[3] = (list[i] >> 8) & 0xff;    
      i++;
      Wire.write(data, 4);
      data[0] = list[i] & 0xff;
      data[1] = (list[i] >> 8) & 0xff;
      data[2] = (list[i] >> 16) & 0xff;
      data[3] = (list[i] >> 24) & 0xff;
      i++;
      Wire.write(data, 4);
    }
    Wire.endTransmission();
  }
  delay(500);
}

I am not doing it for the Uno, it is just that I have a component to configure via an external I2C master
I am planning on using the Arduino Yun as my I2C master and I am now using the Uno as a slave just to test my code

Thanks for your replies !

Tell me the trick of changing of BUFFER_LENGTH in the Wire.h Library from 32 to 64. I have been trying to change for sometimes; but, I am being denied to save the change.

I opened Wire.h and twi.h with notepad++, run it as administrator, otherwise you won't be able to modify it and changed BUFFER_LENGTH to 64

jeancoco:
I opened Wire.h and twi.h with notepad++, run it as administrator, otherwise you won’t be able to modify it and changed BUFFER_LENGTH to 64

Thanks for the trick, and it works. I could change the BUFFER_LENGTH from 32 to 64. Now, the transfer time is only 8 ms. I have a doubt on it; probably, there is something wrong!. These are my codes for UNO and NANO. How many data bytes are transferred from Master to Slave? Is it 1512 bytes? My setup shows 1512 bytes.

UNO Codes

#include <Wire.h>

long list[336] =
{
  0x00000008, 0x0000431E, 0x00000008, 0x0000431E, 0x00000028, 0x02051801, 0x00004020, 0x38300000,
  0x00004018, 0x00000021, 0x00004410, 0x00003737, 0x00004000, 0x11000a74, 0x00004024, 0x0303249b,
  0x00000060, 0x00000000, 0x00000064, 0x0039805e, 0x00000064, 0x00388059, 0x00000064, 0x002080fb,
  0x00000064, 0x00e380fc, 0x00000064, 0x001380fd, 0x00000064, 0x000480c1, 0x00000064, 0x000080c2,
  0x00000064, 0x0000e03D, 0x00000064, 0x001dE077, 0x00000064, 0x0050E094, 0x00000064, 0x00018056,
  0x00000064, 0x00048057, 0x00000064, 0x0060805f, 0x00000064, 0x00018062, 0x00000064, 0x00008063,
  0x00000064, 0x00018065, 0x00000064, 0x0040e043, 0x00005000, 0x11000a74, 0x00005024, 0x0303249b,
  0x00000060, 0x00000020, 0x00000064, 0x0039805e, 0x00000064, 0x00388059, 0x00000064, 0x002080fb,
  0x00000064, 0x00e380fc, 0x00000064, 0x001380fd, 0x00000064, 0x000480c1, 0x00000064, 0x000080c2,
  0x00000064, 0x0000e03D, 0x00000064, 0x001dE077, 0x00000064, 0x0050E094, 0x00000064, 0x00018056,
  0x00000064, 0x00048057, 0x00000064, 0x0060805f, 0x00000064, 0x00018062, 0x00000064, 0x00008063,
  0x00000064, 0x00018065, 0x00000064, 0x0040e043, 0x00006000, 0x11000a74, 0x00006024, 0x0303249b,
  0x00000060, 0x00000040, 0x00000064, 0x0039805e, 0x00000064, 0x00388059, 0x00000064, 0x002080fb,
  0x00000064, 0x00e380fc, 0x00000064, 0x001380fd, 0x00000064, 0x000480c1, 0x00000064, 0x000080c2,
  0x00000064, 0x0000e03D, 0x00000064, 0x001dE077, 0x00000064, 0x0050E094, 0x00000064, 0x00018056,
  0x00000064, 0x00048057, 0x00000064, 0x0060805f, 0x00000064, 0x00018062, 0x00000064, 0x00008063,
  0x00000064, 0x00018065, 0x00000064, 0x0040e043, 0x00007000, 0x11000a74, 0x00007024, 0x0303249b,
  0x00000060, 0x00000060, 0x00000064, 0x0039805e, 0x00000064, 0x00388059, 0x00000064, 0x002080fb,
  0x00000064, 0x00e380fc, 0x00000064, 0x001380fd, 0x00000064, 0x000480c1, 0x00000064, 0x000080c2,
  0x00000064, 0x0000e03D, 0x00000064, 0x001dE077, 0x00000064, 0x0050E094, 0x00000064, 0x00018056,
  0x00000064, 0x00048057, 0x00000064, 0x0060805f, 0x00000064, 0x00018062, 0x00000064, 0x00008063,
  0x00000064, 0x00018065, 0x00000064, 0x0040e043, 0x00004800, 0x11000a74, 0x00004824, 0x0303249b,
  0x00000060, 0x00000010, 0x00000064, 0x0039805e, 0x00000064, 0x00388059, 0x00000064, 0x002080fb,
  0x00000064, 0x00e380fc, 0x00000064, 0x001380fd, 0x00000064, 0x000480c1, 0x00000064, 0x000080c2,
  0x00000064, 0x0000e03D, 0x00000064, 0x001dE077, 0x00000064, 0x0050E094, 0x00000064, 0x00018056,
  0x00000064, 0x00048057, 0x00000064, 0x0060805f, 0x00000064, 0x00018062, 0x00000064, 0x00008063,
  0x00000064, 0x00018065, 0x00000064, 0x0040e043, 0x00005800, 0x11000a74, 0x00005824, 0x0303249b,
  0x00000060, 0x00000030, 0x00000064, 0x0039805e, 0x00000064, 0x00388059, 0x00000064, 0x002080fb,
  0x00000064, 0x00e380fc, 0x00000064, 0x001380fd, 0x00000064, 0x000480c1, 0x00000064, 0x000080c2,
  0x00000064, 0x0000e03D, 0x00000064, 0x001dE077, 0x00000064, 0x0050E094, 0x00000064, 0x00018056,
  0x00000064, 0x00048057, 0x00000064, 0x0060805f, 0x00000064, 0x00018062, 0x00000064, 0x00008063,
  0x00000064, 0x00018065, 0x00000064, 0x0040e043, 0x00006800, 0x11000a74, 0x00006824, 0x0303249b,
  0x00000060, 0x00000050, 0x00000064, 0x0039805e, 0x00000064, 0x00388059, 0x00000064, 0x002080fb,
  0x00000064, 0x00e380fc, 0x00000064, 0x001380fd, 0x00000064, 0x000480c1, 0x00000064, 0x000080c2,
  0x00000064, 0x0000e03D, 0x00000064, 0x001dE077, 0x00000064, 0x0050E094, 0x00000064, 0x00018056,
  0x00000064, 0x00048057, 0x00000064, 0x0060805f, 0x00000064, 0x00018062, 0x00000064, 0x00008063,
  0x00000064, 0x00018065, 0x00000064, 0x0040e043, 0x00007800, 0x11000a74, 0x00007824, 0x0303249b,
  0x00000060, 0x00000070, 0x00000064, 0x0039805e, 0x00000064, 0x00388059, 0x00000064, 0x002080fb,
  0x00000064, 0x00e380fc, 0x00000064, 0x001380fd, 0x00000064, 0x000480c1, 0x00000064, 0x000080c2,
  0x00000064, 0x0000e03D, 0x00000064, 0x001dE077, 0x00000064, 0x0050E094, 0x00000064, 0x00018056,
  0x00000064, 0x00048057, 0x00000064, 0x0060805f, 0x00000064, 0x00018062, 0x00000064, 0x00008063,
  0x00000064, 0x00018065, 0x00000064, 0x0040e043, 0x0000002c, 0x00000865, 0x00000008, 0x00002318
};

byte data[4];
unsigned long presentMillis = 0;

void setup()
{
  Wire.begin(); // Initiate the Wire library
  Wire.setClock(400000L);
  Serial.begin(9600);
}

void loop()
{
  // Wire.beginTransmission(0x77);
  for (int i = 0; i < 335;)
  {

    Wire.beginTransmission(0x77);
    for (int j = 0; j < 6; j++)
    {
      switch (i)
      {
        case 0:
          Wire.write(0x42);
          break;
        case 334:
          Wire.write(0x41);
          break;
        default:
          Wire.write(0x40);
          break;
      }
      data[0] = 0x07;
      data[1] = 0x0F;
      data[2] = list[i] & 0xff;
      data[3] = (list[i] >> 8) & 0xff;
      i++;
      Wire.write(data, 4);
      data[0] = list[i] & 0xff;
      data[1] = (list[i] >> 8) & 0xff;
      data[2] = (list[i] >> 16) & 0xff;
      data[3] = (list[i] >> 24) & 0xff;
      i++;
      Wire.write(data, 4);
    }

    Wire.endTransmission();
  }
  // Wire.endTransmission();
  Serial.println(millis(), DEC); //ms
  while (1);// delay(500);
}

NANO Codes

#include<Wire.h>
byte myData[50];
unsigned long counter=0;
void setup()
{
  Serial.begin(9600);
  Wire. begin(0x77);
  Wire.setClock(400000L);
  Wire.onReceive(receiveEvent);
  byte x = 0b10000000;
  bitWrite(x, 0, HIGH);
 Serial.print(x, BIN);
}

void loop()
{
  
}

void receiveEvent(int howMany)
{
 // for(int i=0; i<howMany; i++)
 // {
 //   myData[i] = Wire.read();
  //  Serial.print(myData[i], HEX);
  //  counter++;
 // }
  //Serial.println();
 // Serial.println(counter, DEC);
}

I am not doing it for the Uno, it is just that I have a component to configure via an external I2C master I am planning on using the Arduino Yun as my I2C master and I am now using the Uno as a slave just to test my code

It might help to tell us what kind of component that is. Using standard I2C you probably won't get below 20ms for that much data.

pylon: It might help to tell us what kind of component that is. Using standard I2C you probably won't get below 20ms for that much data.

That's why the result (8 ms) of my Post#6 seems to be dubious!

That's why the result (8 ms) of my Post#6 seems to be dubious!

How did you measure the 8ms? Using a logic analyzer?

pylon: How did you measure the 8ms? Using a logic analyzer?

I just executed the millis() function to get the elapsed time at the Sender Side (Post#6).

I just executed the millis() function to get the elapsed time at the Sender Side (Post#6).

That just prints the milliseconds since power on, that's not a time measurement. I cannot see why the printed value should be at 8ms though but might be that it was 98ms but the first character wasn't transferred correctly.

pylon: That just prints the milliseconds since power on, [...]

That just prints the milliseconds since the UNO has started the execution of the uploaded program(power on, [...]).

pylon: I cannot see why the printed value should be at 8ms though but might be that it was 98ms but the first character wasn't transferred correctly.

How could it be? When the block transfer was 27-byte, the 'total transfer time' was 55 ms; now, the block transfer is 54-byte due to I2C FIFO size increased from 32 to 64; why would there be an increase in 'total transfer time'? It should decrease; but, not down to 8 ms!

That just prints the milliseconds since the UNO has started the execution of the uploaded program(power on, [...]).

Correct. But that still does not measure the time correctly. And, more importantly, it doesn't ensure you get the complete number. Have you tried printing some string in front of the number to see if you get the complete number?

pylon: But that still does not measure the time correctly. And, more importantly, it doesn't ensure you get the complete number. Have you tried printing some string in front of the number to see if you get the complete number?

When the block size was 27-byte (3x9), I could nicely print at the receiver side the number of total byte transferred/received (1512 byte); but, when block size was increased to 54 (6x9) by increasing the I2C FIFO size (from 32 to 64), there was no way that I could print a number as to how many bytes was transferred/received. There was something that went wrong in the whole approach when the I2C FIFO size was increased to decrease the 'total transfer time'.

When the block size was 27-byte (3x9), I could nicely print at the receiver side the number of total byte transferred/received (1512 byte); but, when block size was increased to 54 (6x9) by increasing the I2C FIFO size (from 32 to 64), there was no way that I could print a number as to how many bytes was transferred/received. There was something that went wrong in the whole approach when the I2C FIFO size was increased to decrease the 'total transfer time'.

You probably used the code that is commented out in post #6. You're doing the same error again and again. Don't use the Serial object inside interrupt context! I know you don't believe me but that's the reason it doesn't work.

pylon: You probably used the code that is commented out in post #6. You're doing the same error again and again. Don't use the Serial object inside interrupt context! I know you don't believe me but that's the reason it doesn't work.

I remember that the 'void receiveEvent(int howMany){}' handler at the receiver side was totally empty when the block size was increased to 54; I was measuring the transfer time at the Sender side.

I was measuring the transfer time at the Sender side.

See answer #13.