LPC1769 with OV7670

Managed to get working a stripped down version of my code on LPC1769 Xpresso board with OV7670 FIFO module. Since I’m handling the IO and interrupts using macros, was not that hard. With serial port running @ 921.6 kbps I am able to reach around 4 fps (@ 160 x 120) using Processing to display the serial stream. I should be able to go even higher, however, I did use a serial communication protocol that is requesting a new frame only after previous one was displayed which adds some delays too.

There is no processing or colour handling done, but that should not be an issue I guess.


14 thoughts on “LPC1769 with OV7670

  1. Hi i’m trying to make OV7670 + FIFO camer run on STM32F103 microcontroller and can’t get a proper image. SCCB works fine and i can read all registers but with my lens covered i get some random fsdfdfsadfdfasfsdfsdfsafanumbers

  2. Sorry didn’t see that i was still typing :) …. i get some random numbers, where the image should be all black. Could you help me with this ? Or will you be able to send me your code for LPC ? Thanks

    • Hi Manias, if your SCCB works fine, you should see “black” as in 0x08 0x08 … if in YUV mode (default mode). Also, be sure you did not enable “color bar” options (registry COM7 and/or COM17). I will suggest also to check that you did set COM10 for negative VSYNC which is a must for OV7670 V2 module.
      Do check AL422B datasheet and the diagram with the signals for the mode you use, do pay attention at the timings as your problem seems to be related either to incorrect setting of COM10 or incorrect handling of FIFO chip signals. if you check on one of my older posts, this was already, I will suggest to take a look here. Hope that helps!

  3. Thanks for fast reply :) I saw that post eariler but i thought that i have version 1, just looked and it version 2 so that was a good clue. But i still have no luck, i checked all connections and everything looks fine for me. I also checked the datasheet for AL422B and i think that the code i’m using for receiving a frame is wrong, but in every sample i found it looks the same, so i’m not sure. I’m basing on this code:
    Can you check It ? the part i think is wrong is in this file :

    • Hi Manias, no worry. Took a look on the code and seems is the one provided on ebay with some small changes and seems the logic in main.c is correct. I will put OE (guess is CS in your code) to GND as should always be 0 logic (see AL422 manual), i will check for VSYNC to be 1 instead, as 2 will means to divide by 2 the number of frames but the rest looks ok. I guess your problem should be either on how you manipulate the pins, try using a multichannel scope to see you control signals relative to VSYNC/WRST and WEN. If RRST is after WEN (see AL422 datasheet) and your OE is in “0”, you should be able to read the data out from the camera. Also, can you try setting COM17 to enable color bars as a test signal?
      As a side note, RGB565 is pretty “noisy”, try first using YUV (default) which is much cleaner, until u can see the image properly.

  4. Hello Manias, i had the same issues, the same corrupted data, saw your post and i took some courage… Finally i made the OV7670+FIFO module work with STM32F103, it took me months and a lot of tests (trying different versions of OV7670 without FIFO i got just random data…), by now i can say that the registers are a real pain, and there are LOT of things that can get messed up just by modifying one bit of any register, and that there even are reserved registers that must be set to an adequate value, i don’t know why but even the output sequence (first and second byte ) gets swapped by a register that is unknown. Here I publish the register values that worked to RGB565, QVGA (XCLK signal is given by a 25MHZ osc).
    {0x3a, 0x04},
    {0x40, 0x10},
    {0x12, 0x14},
    {0x32, 0x80},
    {0x17, 0x17},
    {0x18, 0x05},
    {0x19, 0x02},
    {0x1a, 0x7b}, /* 0x7a */
    {0x03, 0x0a}, /* 0x0a */
    {0x0c, 0x0c},
    {0x3e, 0x00},
    {0x70, 0x00},
    {0x71, 0x01},
    {0x72, 0x11},
    {0x73, 0x09},
    {0xa2, 0x02},
    {0x11, 0x00},
    {0x7a, 0x20},
    {0x7b, 0x1c},
    {0x7c, 0x28},
    {0x7d, 0x3c},
    {0x7e, 0x55},
    {0x7f, 0x68},
    {0x80, 0x76},
    {0x81, 0x80},
    {0x82, 0x88},
    {0x83, 0x8f},
    {0x84, 0x96},
    {0x85, 0xa3},
    {0x86, 0xaf},
    {0x87, 0xc4},
    {0x88, 0xd7},
    {0x89, 0xe8},
    {0x13, 0xe0},
    {0x00, 0x00}, /* AGC */
    {0x10, 0x00},
    {0x0d, 0x00},
    {0x14, 0x10}, /* 0x38 limit the max gain */
    {0xa5, 0x05},
    {0xab, 0x07},
    {0x24, 0x75},
    {0x25, 0x63},
    {0x26, 0xA5},
    {0x9f, 0x78},
    {0xa0, 0x68},
    {0xa1, 0x03}, /* 0x0b */
    {0xa6, 0xdf}, /* 0xd8 */
    {0xa7, 0xdf}, /* 0xd8 */
    {0xa8, 0xf0},
    {0xa9, 0x90},
    {0xaa, 0x94},
    {0x13, 0xe5},
    {0x0e, 0x61},
    {0x0f, 0x4b},
    {0x16, 0x02},
    {0x1e, 0x37}, /* 0x07 */
    {0x21, 0x02},
    {0x22, 0x91},
    {0x29, 0x07},
    {0x33, 0x0b},
    {0x35, 0x0b},
    {0x37, 0x1d},
    {0x38, 0x71},
    {0x39, 0x2a},
    {0x3c, 0x78},
    {0x4d, 0x40},
    {0x4e, 0x20},
    {0x69, 0x5d},
    {0x6b, 0x40}, /* PLL */
    {0x74, 0x19},
    {0x8d, 0x4f},
    {0x8e, 0x00},
    {0x8f, 0x00},
    {0x90, 0x00},
    {0x91, 0x00},
    {0x92, 0x00}, /* 0x19 0x66 */
    {0x96, 0x00},
    {0x9a, 0x80},
    {0xb0, 0x84},
    {0xb1, 0x0c},
    {0xb2, 0x0e},
    {0xb3, 0x82},
    {0xb8, 0x0a},
    {0x43, 0x14},//importante
    {0x44, 0xf0},
    {0x45, 0x34},
    {0x46, 0x58},
    {0x47, 0x28},
    {0x48, 0x3a},

  5. hi

    I’m new for this. I’m trying to make OV 2640 to work on LPC 1769 microcontroller using SPI or I2C. I couldn’t find code anywhere. Please provide me links where i can accesss the code.

  6. My apologies, i didn’t check your comment. i2c is to transfer data, SPI is used to configure the camera. I’m ready to go with i2c for the configuration if SPI is not possible. Thanks for the reply.

    • Hi lokesh, actually i2c is only for configuration. For data transfer you will have to use the 8 bit bus…
      For details on how to configure the camera you just need to read the datasheet for the camera you are using. All the datasheets are available online.

      • Hi Bob, this is a very old post. The test was done using a LPCxpresso test board and a ov7670 FIFO board.

        I do have some boards running but with LPC1343 and the boards are custom made. May i know what you need it for?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s