1

I have a I2C connection between an RPI 3B+ and Arduino Nano. I want to send a key and a corresponding value byte, and the arduino does something with that inside a timed ISR. Which works. But I get IOerrors at the RPI side, probably because the ISR is busy. So I did a little test. Every 10000 messages send:

  • 245 IOerrors at 51,281 Hz ISR
  • 104 IOerrors at 25,600 Hz ISR
  • 28 IOerrors at 6,400 Hz ISR

Is there any way to have less or no IOerrors? I need about 25,600 kHz for my ISR.

RPI side:

bus.write_i2c_block_data(0x60, 0x00, [key, val])

Arduino side message handler called as Wire.onReceive(msg_handler);:

void msg_handler(int bitstream) {
     Wire.read();
     int pin = Wire.read();
     int val = Wire.read();
     Serial.println(pin);
     Wire.begin(0x60);

I do the wire begin every time because otherwise once it had a IOerror it stops printing on the serial. My wiring is 18 AWG and about 20cm. The error:

[Errno 121] Remote I/O error
1

What i2c clock speed are you using?

Even at the faster "fairly standard" speed of 400kHz, that's 2.5us per bit. For a two byte transfer, that's 4us for the data alone, which is 25000 transfers per second. Add on the start and stop bits, plus processing time and you can see that your target data rate isn't possible.

i2c just isn't that fast as standard, though there are much faster "non standard" modes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.