ov2640 library register settings question

mhmart
Posts: 2
Joined: Mon Sep 08, 2025 1:34 pm

ov2640 library register settings question

Postby mhmart » Mon Sep 08, 2025 1:41 pm

I am trying to make use of the registers provided by:
https://github.com/espressif/esp32-came ... s/ov2640.c

I am doing this to program the ov2640 in bare metal on 640x480 resolution. I came up with the registers as such:

Code: Select all

    {0xFF, 0x00}, // Select DSP bank
    {0x2C, 0xFF}, // Reserved (PLL control)
    {0x2E, 0xDF}, // Reserved (PLL control)
    {0x00, 0x00},

    //  Timing and output format
    {0xFF, 0x01}, // Select Sensor bank
    {0x3C, 0x32}, //
    {0x11, 0x10}, // Clock prescaler -> divide input clock (user request)
    {0x15, 0x32}, // Output format control -> HREF/VSYNC only (no PCLK on sync)
    {0x00, 0x00},

    // YUV422
    {0xFF, 0x00},   //  DSP bank
    {0xE0, 0x04},   //  reset DVP
    {0xC2, 0x08},   //  enable DVP
    {0xDA, 0x00},   //  mode YUV422
    {0xD7, 0x03},   //  from default github
    {0xE1, 0x67},   //  from default github
    {0xE0, 0x00},   //  release reset
    {0x00, 0x00},

        //  SET WINDOW SIZE
    {0xFF, 0x00},   //  DSP bank
    {0X51, 0xC8},   //  HSIZE
    {0X52, 0x96},   //  VSIZE
    {0x53, 0x00},   //  XOFFL -> 0
    {0x54, 0x00},   //  YOFFL -> 0
    {0x55, 0x00},   //  VHYX  -> 0x00
    {0x57, 0x00},   //  TEST


    /////////////////////////////////////////// ESP Source

    // REGS TO SVGA
    {0xFF, 0x01},   // Sensor bank
    {0x12, 0x40},   // com 7 set SVGA mode
    {0x03, 0x0A},   // SET COM1 to default SVGA Output
    {0x32, 0x09},   // set reg32 to 0x09 default SVGA parameter
    {0x17, 0x11},   //  HSTART
    {0x18, 0x43},   //  HSTOP
    {0x19, 0x00},   //  VSTART
    {0x1A, 0x4B},   //  VSTOP
    {0x00, 0x00},

    {0xFF, 0x00},   //  DSP bank
    {0xE0, 0x04},   //  Reset DVP
    {0xC0, 0x64},   //  Sensor resolution   Horizontal image size
    {0xC1, 0x4B},   //  Sensor resolution   Vertical image size
    {0x8C, 0x00},   //  Sensor resolution   SizeL - {HSIZE[11], HSIZE[2:0], VSIZE[2:0]}

    {0x86, 0x20 | 0x1D},    //  ctrl2 enable DCW, SDE, UV_ADJ, UV_AVG & CMX
    {0x50, 0x80},    //   CTRL I - LP_DP
    {0x00, 0x00},

    //  SET WINDOW SIZE
    {0xFF, 0x00},   //  DSP bank
    {0X51, 0xA0},   //  HSIZE -> max_x = 200
    {0X52, 0x78},   //  VSIZE -> max_y = 150
    {0x53, 0x00},   //  XOFFL -> 0
    {0x54, 0x00},   //  YOFFL -> 0
    {0x55, 0x00},   //  VHYX  -> 0x00
    {0x57, 0x00},   //  TEST

    //  This part is not working for some reason...
    {0x5A, 0xA0},    //  OUTW (real / 4)
    {0x5B, 0x78},    //  OUTH (real / 4)
    {0x5C, 0x00},   //  [7:4] => zoom speed, [2] => OUTH[8], [1:0] => OUTW[9:8]
    {0xD3, 0x82},
    {0x00, 0x00},

    {0xFF, 0xFF}, // End of table

The result is that I get 800x600 resolution, or at least, I'm reading 600 lines and per line 800 clock pulses so I assume still 800x600?
Why is that, what am I missing here?

Also, I want yuv422 which means y0 u y1 v -> 2 bytes per pixel. The 600 lines with 800 clock pulses suggest 1 byte per pixel?
What does it mean?

Datasheet: https://www.uctronics.com/download/cam_ ... 2640DS.pdf

Who is online

Users browsing this forum: No registered users and 5 guests