Communication via I2C port doesn’t work

Summary:
This seems to be a WIO bug. When WIO is an I2C slave and receives its first transmission from a master it hangs itself and hangs the I2C bus (holds the SCL and SDA low). Tried it with and without 10K pull up resistors but results were the same.

Description:
Ok here is what I did. I ran an Arduino Zero (because it is 3.3v) as a slave and the WIO as a master. I connected it off the backport instead of through the Grove connector (the pins marked I2C1_SDA and I2C_SCL). I also made sure to share the grounds between both boards. Everything worked fine as expected.

I then ran the exact same code with the Zero as a master and the WIO as a slave. The WIO seems to hang and it holds the SDA and SCL lines low. I determined this by using a logic analyzer.

It seems to do this this right in the middle of receiving its first message. I also tried an I2C scan from the Zero to the WIO and it would hang everything as soon as it got to it’s address (0x10);

Master

#include <Wire.h>
int x = 0;

void setup() {    
  Serial.begin(9600);    
  while(!Serial);
  Serial.println("Starting");
  delay(200);
  // Start the I2C Bus as Master
  Wire.begin(); 
}

void loop() {
  Wire.beginTransmission(0x0A); 
  Wire.write(x+'0');              // sends x as char 
  int err = Wire.endTransmission();    // stop transmitting
  Serial.println(err);

  x=(x+1)%6;    
  delay(25);
 }

Slave

#include <Wire.h>

volatile int x = 0;
volatile bool hit = false;

void setup() {
  // I took out Serial prints just to make sure there was no conflict.
  //Serial.begin(9600);
  //while(!Serial);
  
  Wire.begin(0x0A); 
  // Attach a function to trigger when something is received.
  Wire.onReceive(receiveEvent);
}

void receiveEvent(int bytes) {
  hit = true;
  x = Wire.read();    // read one character from the I2C
}

void loop() {
  //Serial.print(hit);
  //Serial.print('\t');
  //Serial.println((char)x);
  delay(100);
}

Below is the logic analyzer results. I narrowed it down to the part where the WIO is turned on. It literally holds the lines low as you can see.

2 Likes