OV7670 with both arduino uno and now mega

Make it simple: start by calculating the size of frame you need to send. Let's say you have a 320x240 bayer frame, which is 76,800 bytes long. And suppose you can run the OV7670 at 1 FPS. You will have to be able to send 614,400 bits per second to the other end via BlueTooth. Because you have to work at camera speed (Pixel clock). Unless the scene you are capturing is completely steady and you can read different parts of the frame from different frames in time. I'm not familiarized with the Bluetooth interface so I can't say whether you will be able to pass bytes from the cam to the Bluetooth device at the desired speed.
Having a SPI RAM for storing the frame will make your life easier, as long as your frame fits in 1 Mbit. No need for an SD card if you have to send from the camera to the bluetooth adapter.

Hi again,

I just come back to say thanks to drkblog and Mr_arduino :slight_smile: It's more clear now.

Hello, i watched the post but i need help for do the connections to the arduino mega

You have to be more specific in your question. Try providing some information too, as which is you OV7670 module version.

Here is the connection information: OV7670 with both arduino uno and now mega - #3 by Mr_arduino - Sensors - Arduino Forum

Actually those are the connections for the arduino uno. For the arduino mega where you connect stuff does not matter that much. The only thing I can suggest is that you make sure all the data pins D7-D0 are on the same port so you can read pixels faster. Also make sure that you buffer XCLK to 3.3v so you don't damage the module also the pin you use for XCLK must support the fast PWM output. Also it does matter where you put SIO_C and SIO_D make sure you use a pull-up resistor to 3.3v not 5v. SIO_C goes to pin 21. SIO_D goes to pin 20. Also make sure you set only the clock you feed the ov7670 (XCLK) as output never set any other pins that go to the ov7670 as output and never enable the internal pull-up resistors on those input pins that connect to the ov7670.

Hi, help me to understand c settings OV7670. I want to get a picture, and it gives you this fig1:
Settings:
WriteReg(CLKRC, 0x81);
WriteReg(DBLV , 0x4A);

WriteReg(COM7, 0x00); // YUV
WriteReg(COM3, 0x04);
WriteReg(COM14, 0x19);
WriteReg(SCALING_XSC, 0x3A);
WriteReg(SCALING_YSC, 0x35);
WriteReg(SCALING_DCWCTR, 0x11);
WriteReg(SCALING_PCLK_DIV, 0xF1);
WriteReg(SCALING_PCLK_DELAY, 0x02);

WriteReg(RGB444, 0x00); // Disable RGB444
WriteReg(COM17, 0x08); // color bar enable
//WriteReg(COM17, 0x00); // color bar disable
WriteReg(COM15, 0xC0); // Set normal rgb with Full range

// WINDOWING
WriteReg(HSTART, 0x16);
WriteReg(HSTOP, 0x04);
//HREF Control
//Bit[7:6]: HREF edge offset data output
//Bit[5:3]: HREF end 3 LSB(high 8 MSB at register HSTOP)
//Bit[2:0]: HREF start 3 LSB(high 8 MSB at register HSTART)
WriteReg(HREF, 0x24);
WriteReg(VSTRT, 0x02);
WriteReg(VSTOP, 0x7a);
WriteReg(VREF, 0x0a);
WriteReg(COM1, 0x00);

//21.11.2013
WriteReg(TSLB,0x0D); // 0D = UYVY 04 = YUYV
WriteReg(COM13,0x88); // connect to REG_TSLB

// COLOR SETTING

WriteReg(COM8,0x8F); // AGC AWB AEC Unlimited step size
WriteReg(0xAA,0x14); // Average-based AEC algorithm
WriteReg(BRIGHT,0x00); // 0x00(Brightness 0) - 0x18(Brightness +1) - 0x98(Brightness -1)
WriteReg(CONTRAS,0x40); // 0x40(Contrast 0) - 0x50(Contrast +1) - 0x38(Contrast -1)
WriteReg(0xB1,4); // really enable auto black level calibration
WriteReg(MTX1,0x80);
WriteReg(MTX2,0x80);
WriteReg(MTX3,0x00);
WriteReg(MTX4,0x22);
WriteReg(MTX5,0x5e);
WriteReg(MTX6,0x80);
WriteReg(MTXS,0x9e);
WriteReg(AWBC7,0x88);
WriteReg(AWBC8,0x88);
WriteReg(AWBC9,0x44);
WriteReg(AWBC10,0x67);
WriteReg(AWBC11,0x49);
WriteReg(AWBC12,0x0e);
WriteReg(GFIX,0x00);
WriteReg(AWBCTR3,0x0a);
WriteReg(AWBCTR2,0x55);
WriteReg(AWBCTR1,0x11);
WriteReg(AWBCTR0,0x9f);

fig1.bmp (90.2 KB)

Is it a OV7670 with or without FIFO?

I think you are not that far. You are loosing some pixels though. Did you try adjusting focus? At least to know if part of your image is ok.

OV7670 with FIFO

All the same, but the Color Bar

fig2.bmp (3.27 KB)

Try enabling color-bar pattern:
COM17 - bit3 ON
SCALING_XSC and SCALING_YSC default values

Then capture a frame and post it here.

Captured frame

Color_Bar2.bmp (3.27 KB)

Ok. There seems to be some synchronization issue. As the colorbar picture looks ordered. I guess it could be sensor configuration problem, instead of the reading of the FIFO.

There is some magic in the sensor configuration. Try ALL THESE VALUES. There are two structures here, you should set the registers in the order I pasted here, first ov7670_default_regs, then ov7670_fmt_yuv422 and you should be able to get a 640x480 frame in bayer codification. Some register/value pairs here use defines I invented. But they are descriptive enough for finding the correct values in the sensor documentation.

static struct regval_list ov7670_default_regs[] = {
	//{ REG_COM7, COM7_RESET },
//
// Clock scale: 3 = 15fps
//              2 = 20fps
//              1 = 30fps

	{ REG_CLKRC, 0x80 },	// OV: clock scale (30 fps) [26 funciona]
	{ REG_TSLB,  TSLB_YVYU },	// OV
	{ REG_COM7, COM7_RGB_YUV },	// YUV VGA
	{ REG_COM17, COM17_DSP_COLORBAR },
	//
	// Set the hardware window.  These values from OV don't entirely
	// make sense - hstop is less than hstart.  But they work...
	//
	{ REG_HSTART, 0x13 },	{ REG_HSTOP, 0x01 },
	{ REG_HREF, 0xb6 },	{ REG_VSTART, 0x02 },
	{ REG_VSTOP, 0x7a },	{ REG_VREF, 0x0a },

	{ REG_COM3, 0 },	{ REG_COM14, 0 },
	// Mystery scaling numbers
	{ 0x70, 0x3a },		{ 0x71, 0x35 },
	{ 0x72, 0x11 },		{ 0x73, 0xf0 },
	{ 0xa2, 0x02 },		
	{ REG_COM10, 0x00 }, // Usar COM10_PCLK_HB para frenar el clock en el blank 

	// Gamma curve values //

	{ 0x7a, 0x20 },		{ 0x7b, 0x10 },
	{ 0x7c, 0x1e },		{ 0x7d, 0x35 },
	{ 0x7e, 0x5a },		{ 0x7f, 0x69 },
	{ 0x80, 0x76 },		{ 0x81, 0x80 },
	{ 0x82, 0x88 },		{ 0x83, 0x8f },
	{ 0x84, 0x96 },		{ 0x85, 0xa3 },
	{ 0x86, 0xaf },		{ 0x87, 0xc4 },
	{ 0x88, 0xd7 },		{ 0x89, 0xe8 },

	
	// AGC and AEC parameters.  Note we start by disabling those features,
	// then turn them only after tweaking the values. 
	{ REG_COM8, COM8_FASTAEC | COM8_AECSTEP | COM8_BFILT },
	{ REG_GAIN, 0 },	{ REG_AECH, 0 },
	{ REG_COM4, 0x40 }, // magic reserved bit
	{ REG_COM9, 0x18 }, // 4x gain + magic rsvd bit
	{ REG_BD50MAX, 0x05 },	{ REG_BD60MAX, 0x07 },
	{ REG_AEW, 0x95 },	{ REG_AEB, 0x33 },
	{ REG_VPT, 0xe3 },	{ REG_HAECC1, 0x78 },
	{ REG_HAECC2, 0x68 },	{ 0xa1, 0x03 }, // magic
	{ REG_HAECC3, 0xd8 },	{ REG_HAECC4, 0xd8 },
	{ REG_HAECC5, 0xf0 },	{ REG_HAECC6, 0x90 },
	{ REG_HAECC7, 0x94 },
	{ REG_COM8, COM8_FASTAEC|COM8_AECSTEP|COM8_BFILT|COM8_AGC|COM8_AEC },

	// Almost all of these are magic "reserved" values.
	{ REG_COM5, 0x61 },	{ REG_COM6, 0x4b },
	{ 0x16, 0x02 },		{ REG_MVFP, 0x07 },
	{ 0x21, 0x02 },		{ 0x22, 0x91 },
	{ 0x29, 0x07 },		{ 0x33, 0x0b },
	{ 0x35, 0x0b },		{ 0x37, 0x1d },
	{ 0x38, 0x71 },		{ 0x39, 0x2a },
	{ REG_COM12, 0x78 },	{ 0x4d, 0x40 },
	{ 0x4e, 0x20 },		{ REG_GFIX, 0 },
	{ REG_DBLV, 0x4A },	 { 0x74, 0x10 },  // DVL 0x4A ?? 0x04
	{ 0x8d, 0x4f },		{ 0x8e, 0 },
	{ 0x8f, 0 },		{ 0x90, 0 },
	{ 0x91, 0 },		{ 0x96, 0 },
	{ 0x9a, 0 },		{ 0xb0, 0x84 },
	{ 0xb1, 0x0c },		{ 0xb2, 0x0e },
	{ 0xb3, 0x82 },		{ 0xb8, 0x0a },

	// More reserved magic, some of which tweaks white balance 
	{ 0x43, 0x0a },		{ 0x44, 0xf0 },
	{ 0x45, 0x34 },		{ 0x46, 0x58 },
	{ 0x47, 0x28 },		{ 0x48, 0x3a },
	{ 0x59, 0x88 },		{ 0x5a, 0x88 },
	{ 0x5b, 0x44 },		{ 0x5c, 0x67 },
	{ 0x5d, 0x49 },		{ 0x5e, 0x0e },
	{ 0x6c, 0x0a },		{ 0x6d, 0x55 },
	{ 0x6e, 0x11 },		{ 0x6f, 0x9f }, // "9e for advance AWB"
	{ 0x6a, 0x40 },		{ REG_BLUE, 0x40 }, // 0x40
	{ REG_RED, 0x60 },
	{ REG_COM8, COM8_FASTAEC|COM8_AECSTEP|COM8_BFILT|COM8_AGC|COM8_AEC|COM8_AWB },

	// Matrix coefficients
	{ 0x4f, 0x80 },		{ 0x50, 0x80 },
	{ 0x51, 0 },		{ 0x52, 0x22 },
	{ 0x53, 0x5e },		{ 0x54, 0x80 },
	{ 0x58, 0x9e },

	{ REG_COM16, COM16_AWBGAIN },	{ REG_EDGE, 0 },
	{ 0x75, 0x05 },		{ 0x76, 0xe1 },
	{ 0x4c, 0 },		{ 0x77, 0x01 },
	{ REG_COM13, 0xc3 },	{ 0x4b, 0x09 },
	{ 0xc9, 0x60 },		/*{ REG_COM16, 0x38 },*/
	{ 0x56, 0x40 },

	{ 0x34, 0x11 },		{ REG_COM11, COM11_EXP|COM11_HZAUTO|COM11_50HZ },
	{ 0xa4, 0x88 },		{ 0x96, 0 },
	{ 0x97, 0x30 },		{ 0x98, 0x20 },
	{ 0x99, 0x30 },		{ 0x9a, 0x84 },
	{ 0x9b, 0x29 },		{ 0x9c, 0x03 },
	{ 0x9d, 0x4c },		{ 0x9e, 0x3f },
	{ 0x78, 0x04 },

	// Extra-weird stuff.  Some sort of multiplexor register
	{ 0x79, 0x01 },		{ 0xc8, 0xf0 },
	{ 0x79, 0x0f },		{ 0xc8, 0x00 },
	{ 0x79, 0x10 },		{ 0xc8, 0x7e },
	{ 0x79, 0x0a },		{ 0xc8, 0x80 },
	{ 0x79, 0x0b },		{ 0xc8, 0x01 },
	{ 0x79, 0x0c },		{ 0xc8, 0x0f },
	{ 0x79, 0x0d },		{ 0xc8, 0x20 },
	{ 0x79, 0x09 },		{ 0xc8, 0x80 },
	{ 0x79, 0x02 },		{ 0xc8, 0xc0 },
	{ 0x79, 0x03 },		{ 0xc8, 0x40 },
	{ 0x79, 0x05 },		{ 0xc8, 0x30 },
	{ 0x79, 0x26 },
/*
	*/

	{ 0xff, 0xff },
};

/*
 * Here we'll try to encapsulate the changes for just the output
 * video format.
 *
 * RGB656 and YUV422 come from OV; RGB444 is homebrewed.
 *
 * IMPORTANT RULE: the first entry must be for COM7, see ov7670_s_fmt for why.
 */


static struct regval_list ov7670_fmt_yuv422[] = {
	{ REG_COM7, 0x0 },  /* Selects YUV mode */
	{ REG_RGB444, 0 },	/* No RGB444 please */
	{ REG_COM1, 0 },
	{ REG_COM15, COM15_RANGE_TOFF }, // OJO
	{ REG_COM9, 0x6A }, /* 128x gain ceiling; */
	{ 0x4f, 0x80 }, 	/* "matrix coefficient 1" */
	{ 0x50, 0x80 }, 	/* "matrix coefficient 2" */
	{ 0x51, 0    },		/* vb */
	{ 0x52, 0x22 }, 	/* "matrix coefficient 4" */
	{ 0x53, 0x5e }, 	/* "matrix coefficient 5" */
	{ 0x54, 0x80 }, 	/* "matrix coefficient 6" */
	{ REG_COM13, /*COM13_GAMMA|*/COM13_UVSAT },
	{ 0xff, 0xff },
};

Drkblog beat me to pretty much everything except one thing I was wondering about was the converter. The colors are all monochrome and washed out.could you post the raw data or try my converter? GitHub - ComputerNerd/RawCamera-data-converter: This program was made to convert raw data from the ov7670 to a png file. It may also work with other cameras. just today I did some work on the program and added a higher quality demosaicing algorithm. I recommend you use raw Bayer data.

Hello MR_Arduino, I have seen you job and it's awesome.
I amb working with OV7670 non-fifo version (I have ordered one with fifo I am still waiting for them)

I have (with long hours work...) managed to control I2C (I can read the full bank and modify any register) I also can store and entire frame (Due have enough memory). Once there I try with a VGA ouput based on other project I found over here. And I achieve getting images directly from ov7670 to a monitor through VGA. (Poor quality)

After that I have been almost a week working trying to getting images to PC and I think I'm about to kill myself because I haven't get it.
Them, now I would be happy getting one photo to a SDcard. I have this shield. http://www.ebay.es/itm/321234880652?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

Then I would like you to guide me on how to do it, I know that it's done in you code and library but without some help I can not understand it at all. I would be very gratefull for a little guidance on which will be the next steps.

Here is my main code, thus you could see what I am doing.

#include <Wire.h>      
#include <VGA.h>
#include <Ov7670.h>

Ov7670 ov7670;   
volatile unsigned int pixelCount, lineCount;
boolean startLine,startFrame;
byte lineData[COLS*2];

void setup() 
{
  Serial.begin(115200);                                  // Start serial comunication
  Wire.begin();                                          // Enable I2C
  ov7670.begin();                                        // Prepare Camera
  //ov7670.readAll();                                      // Read the camera's Bank Register
  
  attachInterrupt(HREF_PIN, hrefRising, RISING);         // Activate an interrupt when HREF goes up
  attachInterrupt(VSYNC_PIN, vsyncFalling, FALLING);     // Activate an interrupt when VSYNC goes down 
  
  //VGA.begin(320,240,VGA_COLOUR);                         // Enable VGA Output
}

void loop() 
{
  if (startLine)
  {
     startLine = false;
     while (pixelCount < COLS)
     {
        // First byte
        while(!PCLK);
        lineData[pixelCount*2] = DATA;
        while(PCLK);
        // Second byte
        while(!PCLK);
        lineData[pixelCount*2+1] = DATA;
        while(PCLK);
        pixelCount++;
     }
    //HERE SEND A LINE
  }
}

void hrefRising()
{
  noInterrupts();
  startLine = true;
  lineCount++;
  pixelCount = 0;
  interrupts();
}

void vsyncFalling()
{
  noInterrupts();
  //Serial.print(0x46,HEX);
  startFrame=true;
  lineCount = 0;
  interrupts();
}

where <Ov7670.h> is my own library I have been doing

Thanks in advance,

Aitor

Hello, I tried Your settings Bayer_Raw_VGA. And here is a picture.

Settings:

const struct sensor_reg ov7670_default_regs_DRK[] PROGMEM = {
//{ REG_COM7, COM7_RESET },
//
// Clock scale: 3 = 15fps
// 2 = 20fps
// 1 = 30fps

{ REG_CLKRC, 0x80 }, // OV: clock scale (30 fps) [26 funciona]
{ REG_TSLB, 0x0D/* TSLB_YVYU */ }, // OV
{ REG_COM7, 0x01 }, // YUV VGA
{ REG_COM17, 0x08 }, //color_bar
//
// Set the hardware window. These values from OV don't entirely
// make sense - hstop is less than hstart. But they work...
//
{ REG_HSTART, 0x13 }, { REG_HSTOP, 0x01 },
{ REG_HREF, 0xb6 }, { REG_VSTART, 0x02 },
{ REG_VSTOP, 0x7a }, { REG_VREF, 0x0a },

{ REG_COM3, 0 }, { REG_COM14, 0 },
// Mystery scaling numbers
{ 0x70, 0x3a }, { 0x71, 0x35 },
{ 0x72, 0x11 }, { 0x73, 0xf0 },
{ 0xa2, 0x02 },
{ REG_COM10, 0x00 }, // Usar COM10_PCLK_HB para frenar el clock en el blank

// Gamma curve values //

{ 0x7a, 0x20 }, { 0x7b, 0x10 },
{ 0x7c, 0x1e }, { 0x7d, 0x35 },
{ 0x7e, 0x5a }, { 0x7f, 0x69 },
{ 0x80, 0x76 }, { 0x81, 0x80 },
{ 0x82, 0x88 }, { 0x83, 0x8f },
{ 0x84, 0x96 }, { 0x85, 0xa3 },
{ 0x86, 0xaf }, { 0x87, 0xc4 },
{ 0x88, 0xd7 }, { 0x89, 0xe8 },

// AGC and AEC parameters. Note we start by disabling those features,
// then turn them only after tweaking the values.
{ REG_COM8, COM8_FASTAEC | COM8_AECSTEP | COM8_BFILT },
{ REG_GAIN, 0 }, { REG_AECH, 0 },
{ REG_COM4, 0x40 }, // magic reserved bit
{ REG_COM9, 0x18 }, // 4x gain + magic rsvd bit
{ REG_BD50MAX, 0x05 }, { REG_BD60MAX, 0x07 },
{ REG_AEW, 0x95 }, { REG_AEB, 0x33 },
{ REG_VPT, 0xe3 }, { REG_HAECC1, 0x78 },
{ REG_HAECC2, 0x68 }, { 0xa1, 0x03 }, // magic
{ REG_HAECC3, 0xd8 }, { REG_HAECC4, 0xd8 },
{ REG_HAECC5, 0xf0 }, { REG_HAECC6, 0x90 },
{ REG_HAECC7, 0x94 },
{ REG_COM8, COM8_FASTAEC|COM8_AECSTEP|COM8_BFILT|COM8_AGC|COM8_AEC },

// Almost all of these are magic "reserved" values.
{ REG_COM5, 0x61 }, { REG_COM6, 0x4b },
{ 0x16, 0x02 }, { REG_MVFP, 0x07 },
{ 0x21, 0x02 }, { 0x22, 0x91 },
{ 0x29, 0x07 }, { 0x33, 0x0b },
{ 0x35, 0x0b }, { 0x37, 0x1d },
{ 0x38, 0x71 }, { 0x39, 0x2a },
{ REG_COM12, 0x78 }, { 0x4d, 0x40 },
{ 0x4e, 0x20 }, { REG_GFIX, 0 },
{ REG_DBLV, 0x4A }, { 0x74, 0x10 }, // DVL 0x4A ?? 0x04
{ 0x8d, 0x4f }, { 0x8e, 0 },
{ 0x8f, 0 }, { 0x90, 0 },
{ 0x91, 0 }, { 0x96, 0 },
{ 0x9a, 0 }, { 0xb0, 0x84 },
{ 0xb1, 0x0c }, { 0xb2, 0x0e },
{ 0xb3, 0x82 }, { 0xb8, 0x0a },

// More reserved magic, some of which tweaks white balance
{ 0x43, 0x0a }, { 0x44, 0xf0 },
{ 0x45, 0x34 }, { 0x46, 0x58 },
{ 0x47, 0x28 }, { 0x48, 0x3a },
{ 0x59, 0x88 }, { 0x5a, 0x88 },
{ 0x5b, 0x44 }, { 0x5c, 0x67 },
{ 0x5d, 0x49 }, { 0x5e, 0x0e },
{ 0x6c, 0x0a }, { 0x6d, 0x55 },
{ 0x6e, 0x11 }, { 0x6f, 0x9f }, // "9e for advance AWB"
{ 0x6a, 0x40 }, { REG_BLUE, 0x40 }, // 0x40
{ REG_RED, 0x60 },
{ REG_COM8, COM8_FASTAEC|COM8_AECSTEP|COM8_BFILT|COM8_AGC|COM8_AEC|COM8_AWB },

// Matrix coefficients
{ 0x4f, 0x80 }, { 0x50, 0x80 },
{ 0x51, 0 }, { 0x52, 0x22 },
{ 0x53, 0x5e }, { 0x54, 0x80 },
{ 0x58, 0x9e },

{ REG_COM16, COM16_AWBGAIN }, { REG_EDGE, 0 },
{ 0x75, 0x05 }, { 0x76, 0xe1 },
{ 0x4c, 0 }, { 0x77, 0x01 },
{ REG_COM13, 0xc3 }, { 0x4b, 0x09 },
{ 0xc9, 0x60 }, /{ REG_COM16, 0x38 },/
{ 0x56, 0x40 },

{ 0x34, 0x11 }, { REG_COM11, COM11_EXP|COM11_HZAUTO|COM11_50HZ },
{ 0xa4, 0x88 }, { 0x96, 0 },
{ 0x97, 0x30 }, { 0x98, 0x20 },
{ 0x99, 0x30 }, { 0x9a, 0x84 },
{ 0x9b, 0x29 }, { 0x9c, 0x03 },
{ 0x9d, 0x4c }, { 0x9e, 0x3f },
{ 0x78, 0x04 },

// Extra-weird stuff. Some sort of multiplexor register
{ 0x79, 0x01 }, { 0xc8, 0xf0 },
{ 0x79, 0x0f }, { 0xc8, 0x00 },
{ 0x79, 0x10 }, { 0xc8, 0x7e },
{ 0x79, 0x0a }, { 0xc8, 0x80 },
{ 0x79, 0x0b }, { 0xc8, 0x01 },
{ 0x79, 0x0c }, { 0xc8, 0x0f },
{ 0x79, 0x0d }, { 0xc8, 0x20 },
{ 0x79, 0x09 }, { 0xc8, 0x80 },
{ 0x79, 0x02 }, { 0xc8, 0xc0 },
{ 0x79, 0x03 }, { 0xc8, 0x40 },
{ 0x79, 0x05 }, { 0xc8, 0x30 },
{ 0x79, 0x26 },
/*
*/

{ 0xff, 0xff },
};

Bayer_Raw_VGA.bmp (301 KB)

Can't understand what sequence set to get a good image.

Can you post the RAW data so I can test that with my decoder?

Settings:

const struct sensor_reg ov7670_default_regs_DRK[] PROGMEM = {
//{ REG_COM7, COM7_RESET },
//
// Clock scale: 3 = 15fps
// 2 = 20fps
// 1 = 30fps

{ REG_CLKRC, 0x80 }, // OV: clock scale (30 fps) [26 funciona]
{ REG_TSLB, 0x0D/* TSLB_YVYU */ }, // OV
{ REG_COM7, 0x01 }, // YUV VGA
{ REG_COM17, 0x08 }, //color_bar
//
// Set the hardware window. These values from OV don't entirely
// make sense - hstop is less than hstart. But they work...
//
{ REG_HSTART, 0x13 }, { REG_HSTOP, 0x01 },
{ REG_HREF, 0xb6 }, { REG_VSTART, 0x02 },
{ REG_VSTOP, 0x7a }, { REG_VREF, 0x0a },

{ REG_COM3, 0 }, { REG_COM14, 0 },
// Mystery scaling numbers
{ 0x70, 0x3a }, { 0x71, 0x35 },
{ 0x72, 0x11 }, { 0x73, 0xf0 },
{ 0xa2, 0x02 },
{ REG_COM10, 0x00 }, // Usar COM10_PCLK_HB para frenar el clock en el blank

// Gamma curve values //

{ 0x7a, 0x20 }, { 0x7b, 0x10 },
{ 0x7c, 0x1e }, { 0x7d, 0x35 },
{ 0x7e, 0x5a }, { 0x7f, 0x69 },
{ 0x80, 0x76 }, { 0x81, 0x80 },
{ 0x82, 0x88 }, { 0x83, 0x8f },
{ 0x84, 0x96 }, { 0x85, 0xa3 },
{ 0x86, 0xaf }, { 0x87, 0xc4 },
{ 0x88, 0xd7 }, { 0x89, 0xe8 },

// AGC and AEC parameters. Note we start by disabling those features,
// then turn them only after tweaking the values.
{ REG_COM8, COM8_FASTAEC | COM8_AECSTEP | COM8_BFILT },
{ REG_GAIN, 0 }, { REG_AECH, 0 },
{ REG_COM4, 0x40 }, // magic reserved bit
{ REG_COM9, 0x18 }, // 4x gain + magic rsvd bit
{ REG_BD50MAX, 0x05 }, { REG_BD60MAX, 0x07 },
{ REG_AEW, 0x95 }, { REG_AEB, 0x33 },
{ REG_VPT, 0xe3 }, { REG_HAECC1, 0x78 },
{ REG_HAECC2, 0x68 }, { 0xa1, 0x03 }, // magic
{ REG_HAECC3, 0xd8 }, { REG_HAECC4, 0xd8 },
{ REG_HAECC5, 0xf0 }, { REG_HAECC6, 0x90 },
{ REG_HAECC7, 0x94 },
{ REG_COM8, COM8_FASTAEC|COM8_AECSTEP|COM8_BFILT|COM8_AGC|COM8_AEC },

// Almost all of these are magic "reserved" values.
{ REG_COM5, 0x61 }, { REG_COM6, 0x4b },
{ 0x16, 0x02 }, { REG_MVFP, 0x07 },
{ 0x21, 0x02 }, { 0x22, 0x91 },
{ 0x29, 0x07 }, { 0x33, 0x0b },
{ 0x35, 0x0b }, { 0x37, 0x1d },
{ 0x38, 0x71 }, { 0x39, 0x2a },
{ REG_COM12, 0x78 }, { 0x4d, 0x40 },
{ 0x4e, 0x20 }, { REG_GFIX, 0 },
{ REG_DBLV, 0x4A }, { 0x74, 0x10 }, // DVL 0x4A ?? 0x04
{ 0x8d, 0x4f }, { 0x8e, 0 },
{ 0x8f, 0 }, { 0x90, 0 },
{ 0x91, 0 }, { 0x96, 0 },
{ 0x9a, 0 }, { 0xb0, 0x84 },
{ 0xb1, 0x0c }, { 0xb2, 0x0e },
{ 0xb3, 0x82 }, { 0xb8, 0x0a },

// More reserved magic, some of which tweaks white balance
{ 0x43, 0x0a }, { 0x44, 0xf0 },
{ 0x45, 0x34 }, { 0x46, 0x58 },
{ 0x47, 0x28 }, { 0x48, 0x3a },
{ 0x59, 0x88 }, { 0x5a, 0x88 },
{ 0x5b, 0x44 }, { 0x5c, 0x67 },
{ 0x5d, 0x49 }, { 0x5e, 0x0e },
{ 0x6c, 0x0a }, { 0x6d, 0x55 },
{ 0x6e, 0x11 }, { 0x6f, 0x9f }, // "9e for advance AWB"
{ 0x6a, 0x40 }, { REG_BLUE, 0x40 }, // 0x40
{ REG_RED, 0x60 },
{ REG_COM8, COM8_FASTAEC|COM8_AECSTEP|COM8_BFILT|COM8_AGC|COM8_AEC|COM8_AWB },

// Matrix coefficients
{ 0x4f, 0x80 }, { 0x50, 0x80 },
{ 0x51, 0 }, { 0x52, 0x22 },
{ 0x53, 0x5e }, { 0x54, 0x80 },
{ 0x58, 0x9e },

{ REG_COM16, COM16_AWBGAIN }, { REG_EDGE, 0 },
{ 0x75, 0x05 }, { 0x76, 0xe1 },
{ 0x4c, 0 }, { 0x77, 0x01 },
{ REG_COM13, 0xc3 }, { 0x4b, 0x09 },
{ 0xc9, 0x60 }, /{ REG_COM16, 0x38 },/
{ 0x56, 0x40 },

{ 0x34, 0x11 }, { REG_COM11, COM11_EXP|COM11_HZAUTO|COM11_50HZ },
{ 0xa4, 0x88 }, { 0x96, 0 },
{ 0x97, 0x30 }, { 0x98, 0x20 },
{ 0x99, 0x30 }, { 0x9a, 0x84 },
{ 0x9b, 0x29 }, { 0x9c, 0x03 },
{ 0x9d, 0x4c }, { 0x9e, 0x3f },
{ 0x78, 0x04 },

// Extra-weird stuff. Some sort of multiplexor register
{ 0x79, 0x01 }, { 0xc8, 0xf0 },
{ 0x79, 0x0f }, { 0xc8, 0x00 },
{ 0x79, 0x10 }, { 0xc8, 0x7e },
{ 0x79, 0x0a }, { 0xc8, 0x80 },
{ 0x79, 0x0b }, { 0xc8, 0x01 },
{ 0x79, 0x0c }, { 0xc8, 0x0f },
{ 0x79, 0x0d }, { 0xc8, 0x20 },
{ 0x79, 0x09 }, { 0xc8, 0x80 },
{ 0x79, 0x02 }, { 0xc8, 0xc0 },
{ 0x79, 0x03 }, { 0xc8, 0x40 },
{ 0x79, 0x05 }, { 0xc8, 0x30 },
{ 0x79, 0x26 },
/*
*/

{ 0xff, 0xff },
};

2013.11.26_16.21.15.raw (300 KB)

BAYER_RAW_VGA.bmp (301 KB)

With the other settings the picture

New_Bayer_RAW_VGA.bmp (301 KB)

2013.11.26_16.39.10.raw (300 KB)

We need some help from MR_arduino here. The RAW data has only bytes in AAh and 15h which doesn't look like a coloured image to me. But I'm not sure what could be wrong.