My first forum post, so Noob grace is humbly appreciated...
Thought I would attach to this exising post started by Gutzy
I'm trying to get an OV7670 camera (no FIFO) module working with my Due, and I just need to read the configuration and change a couple registers in the camera over the I2C interface. Everything else is working pretty well thanks to help from this forum.
I have the latest MAC OSX version 1.5.8 Arduino software, which should have issues with the Wire library fixed (or so I've read), but cannot after many hours even read a byte from the camera with my Due.
According to the camera datasheet, it's SIO-D (ie. SDA) line is compatible with the Due SDA1 - pin 70, meaning direct connection at 3.3V is perfect, and the SIO-D runs tri-state so setting pinMode(70, INPUT) disables the Due internal pull-up on that pin. I have SCL1-pin 71 set as OUTPUT, and I've tried a range of resistors between the SCL1 and SIO-C pins (from none to 1K). I have a scope on the SCL1 pin, but it shows the pin high and never cycling low when I run the code.
Of course without sending any clock pulses to the camera when I call the read routine (below), I get what I expect - only zeros (camera reset should restore defaults which are mostly NOT zero).
So it looks like the Wire library is failing to cause my poor Due to assert a clock signal, but still returning true on an available byte from SDA1.
Am I doing something wrong here, or are the most basic Wire functions just not available to work on the Due yet?
// CODE SAMPLE //
volatile byte regData = 0;
byte device = 0x43; // need to shift right 1 bit for a 7-bit address. 0x43 is READ for OV7670
byte regaddrx;
Wire1.begin;
// Configure camera by modifying registers via the SCCB, first read them...
for(regaddrx = 0x01; regaddrx < 0x7F; regaddrx++) { // max address for 7-bit is 0x7F
Serial.print(regaddrx, HEX);
Serial.print(":");
regData = ReadReg((device>>1), (regaddrx>>1));
Serial.print(regData, HEX);
Serial.print(", ");
}
...
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
}