user21540: I am a new user of Aurdino and want to interface OV7670 camera with aurdino uno which uses i2c mode of communication.I want to check the configuration of the device control registers and set them as per requirement. In this case, OV7670 is my slave device.
     How can I access a particular register inside the slave device?(The parameters for commands like wire.begin() etc., include slave address but not the address of the registers inside a slave device.)

user11729: Take a look at the datasheet - that will show you the correct waveforms / transactions for this. However, something like this should work (assuming 8-bit addresses and registers)
// reading

Wire.beginTransmission(address); 
Wire.write(reg); // set address to read from our requested register
Wire.endTransmission(false); // repeated start
Wire.requestFrom(address,(unsigned char)1);  // just a single byte
if(Wire.endTransmission()!=0){
    // put error code here
}
readValue = Wire.read();

// writing

Wire.beginTransmission(address);
Wire.write(reg);
Wire.write(value);
if(Wire.endTransmission()!=0){ 
    // put error code here
}


user11763: To communicate with the OV7670:

SIOC => SCL
(pulled up to 3.3V)
SIOD => SDA
(pulled up to 3.3V)
RESET => 3.3V
PWDN => GND
XCLK => Clock signal is necessary (at least 10 Mhz)
Vcc => 3.3V
GND => GND

The XCLK needs at least 10 MHz according to the datasheet, but from other accounts, it seems that's not a hard limit. You can get a 4 MHz clock from the Uno using its timer0; check out this post on how to do it. After this, you can write a small sketch along the lines of:
Wire.begin();
Wire.beginTransmission(0x21);
Wire.write(0x12);  // software reset
Wire.write(0x80);
Wire.endTransmission();
delay(500); // wait for reset to complete

Wire.beginTransmission(0x21); 
Wire.write(0x01);  // u now read from reg 0x01
Wire.endTransmission();
Wire.requestFrom(0x21, 1);
while (Wire.available() == 0);  //block till u get something
while (Wire.available())
  Serial.println(Wire.read(), HEX);

You can place everything in setup() after including the Wire library and setting up the XCLK clock signal. If all goes well, 80 should be printed in the serial monitor and this will confirm that you're now communicating over the SCCB with the camera.
I should warn you that while others have used the Uno to grab images from the OV7670, the process is moderately complex, especially for a beginner, and it's not what the Uno is intended for; all you'll be able to do is grab frames and pass them on to some TFT screen or your PC and even then you'll get at most 5 fps, I think, with QVGA or QCIF output. You'd be better off with some ARM dev board, one running Linux perhaps. Good luck.

21540: <p>I am a new user of Aurdino and want to interface OV7670 camera with aurdino uno which uses i2c mode of communication.I want to check the configuration of the device control registers and set them as per requirement. In this case, OV7670 is my slave device.<br/><br/>
     How can I access a particular register inside the slave device?(The parameters for commands like wire.begin() etc., include slave address but not the address of the registers inside a slave device.)</p>
 11729: <p>Take a look at the datasheet - that will show you the correct waveforms / transactions for this. However, something like this should work (assuming 8-bit addresses and registers)</p>

<pre><code>// reading

Wire.beginTransmission(address); 
Wire.write(reg); // set address to read from our requested register
Wire.endTransmission(false); // repeated start
Wire.requestFrom(address,(unsigned char)1);  // just a single byte
if(Wire.endTransmission()!=0){
    // put error code here
}
readValue = Wire.read();

// writing

Wire.beginTransmission(address);
Wire.write(reg);
Wire.write(value);
if(Wire.endTransmission()!=0){ 
    // put error code here
}
</code></pre>
 11763: <p>To communicate with the OV7670:</p>

<ul>
<li>SIOC => SCL
(pulled up to 3.3V)</li>
<li>SIOD => SDA
(pulled up to 3.3V)</li>
<li>RESET => 3.3V</li>
<li>PWDN => GND</li>
<li>XCLK => Clock signal is necessary (at least 10 Mhz)</li>
<li>Vcc => 3.3V</li>
<li>GND => GND</li>
</ul>

<p>The XCLK needs at least 10 MHz according to the datasheet, but from other accounts, it seems that's not a hard limit. You can get a 4 MHz clock from the Uno using its <code>timer0</code>; check out this <a href="http://forum.arduino.cc/index.php?PHPSESSID=pt8le15alfme9abbohpu1grue2&amp;topic=128269.msg964725#msg964725" rel="nofollow">post</a> on how to do it. After this, you can write a small sketch along the lines of:</p>

<pre><code>Wire.begin();
Wire.beginTransmission(0x21);
Wire.write(0x12);  // software reset
Wire.write(0x80);
Wire.endTransmission();
delay(500); // wait for reset to complete

Wire.beginTransmission(0x21); 
Wire.write(0x01);  // u now read from reg 0x01
Wire.endTransmission();
Wire.requestFrom(0x21, 1);
while (Wire.available() == 0);  //block till u get something
while (Wire.available())
  Serial.println(Wire.read(), HEX);
</code></pre>

<p>You can place everything in <code>setup()</code> after including the <code>Wire</code> library and setting up the XCLK clock signal. If all goes well, <code>80</code> should be printed in the serial monitor and this will confirm that you're now communicating over the SCCB with the camera.</p>

<p>I should warn you that while others have used the Uno to grab images from the OV7670, the process is moderately complex, especially for a beginner, and it's not what the Uno is intended for; all you'll be able to do is grab frames and pass them on to some TFT screen or your PC and even then you'll get at most 5 fps, I think, with QVGA or QCIF output. You'd be better off with some ARM dev board, one running Linux perhaps. Good luck.</p>
