Maximum I2C transfer rate

I’m wondering what is the maximum throughput rate I should expect to get for I2C transfers and best practices for capturing the data. I’d like to capture a high speed burst of data from an accelerometer/gyro. The device runs I2C at 400kHZ and I would expect to do burst transfers.

I can’t remember the exact rate you get when you ask for 400kHz, but it’s close.

I2C is 9 clocks per byte when the data is flowing, and the more you can get into one request the better as an address & read request is likely another 20 clocks before you see any data.

Thanks - What about the delay or overhead of the software call? I would assume some dead time in between back to back calls to the I2C API.

The API call overhead is minimal compared to the glacial speed of I2C!

You can use hardware.micros() to time how long it takes if you’re interested in the detail.

For a byte read at 400kHz, the I2C transaction is 100 usec. The dead time in between back to back read transactions, is usually around 250 usec.

That sounds about right; the raw bits for 4 bytes are 90us (address, subaddress, address, byte read). The more bytes you read, the less the setup overhead is.

Note that doing things like this:

myi2c <- hardware.i2c12; // make a reference to the device once at the start
myi2c.write(0x65, “\x00\x23”);

…is faster than:

hardware.i2c12.write(0x65, “\x00\x23”);

…because there’s less looking things up in squirrel tables. Plus, it’s more readable!