Wire does not work on my Due

I'm asking for quick help troubleshooting. Something as simple as reading/writing to a device register over I2C should work first try out of the box, right?

On my Uno R3+ board when I execute Wire commands I see a distinct set of 9 clock pulses on the SCL output for each byte phase being transmitted or received...BUT not on my Due board. The SCL lines just sit high and do nothing. I've tried both sets (SCL/SDA with Wire. and SCL1/SDA1 with Wire1.). I have a current limiting resistor on the SCL pin to my camera and have tried a range of values but there is no activity on the Due pin seen at all, so I think I've eliminated any wiring issues. My OV7670 cam runs on 3.3 V which is why I bought a Due for ease of connection (and speed).

Anyway, either I have fried SCL pins on my Due board (both sets?, but they have never touched anything > 3.3V), or the Wire library simply does not work -- yet.

PLEASE, PLEASE help.
Can someone on the development team confirm that Wire in 1.5.8 has been tested to work on the Due?

OR, could a user who has successfully run Wire on a Due chime in to let me know what I might be missing?

OR, I am thinking maybe my install is somehow not loading the right libraries or variants for my specific Due board. Anyone have any insight into this, or how to check it?

From reading many many posts (and I do mean many), I'm sure this would help a few users like me gain confidence in the Due board. There seems to remain much mystery about the Due, which is strange for such a popular model.

Here is the code I would expect to work, but doesn't (maybe someone could run it on their Due to see if it is correct):
(NOTE: even if this code is incorrect, the Wire1 Transmission commands should pulse the SCL1 line on the DUE as I have confirmed the equivalent Wire commands do on the UNO)

byte regData = 0;
byte device = 0x42; // or the WRITE address of your device
byte devicerx = 0x43; // 0x43 is READ for OV7670
byte regaddrx;

Wire1.begin();

void loop(); {
for(regaddrx = 0x01; regaddrx < 0x0A; regaddrx++) { // max address for 7-bit is 0x7F, just get first few registers
regData = ReadReg((devicerx>>1), (regaddrx>>1));
Serial.print(regaddrx, HEX);
Serial.print(":");
Serial.print(regData, HEX);
Serial.print(", ");
}
Serial.println();
}
// read from camera on SCCB
byte ReadReg (byte addr, byte regAddr) {
Wire1.beginTransmission(addr);
Wire1.write(regAddr); // Register address to read
Wire1.endTransmission(); // Terminate request
Wire1.requestFrom(int(addr), 1); // Read a byte
while(!Wire1.available()) { }; // Wait for receipt
return(Wire1.read()); // Get result
}

// how I would write to camera on SCCB, if I could first read from it
void WriteReg (byte addr, byte regAddr, byte val) {
Wire1.beginTransmission(addr);
Wire1.write(regAddr);
Wire1.write(val);
Wire1.endTransmission();
}

This mite sound silly - but I could not see the include for wire.h?

Yes I have it, just didn't put it in the post when I copy/pasted the code snippet out of my larger program. The compiler would spit at me on the Wire1. were it not there.

sorry for leaving it out.

I am having similar problems with a Due and Wire. The target board has multiple I2C devices which I didn't get to run yet.
I am testing out the code at
Arduino Playground - I2cScanner.
It reports it finds one address during the first execution of loop() only. After that,I see on my scope that the SDA(pin 20) and SCL(pin21) just stay high.

On the other hand, I ran successfully the GitHub - adafruit/Adafruit-MCP23017-Arduino-Library: Arduino Library for Adafruit MCP23017 Adafruit_MCP23017 library on a different board. It is based on Wire.
Frank

I am using the Arduino 1.5.7 IDE.

1 Like