cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 Discovery DCMI OV7670 problem

Dawid Brzakala
Associate II
Posted on November 01, 2017 at 22:23

Hello,

I am trying to capture data from ov7670 camera using DCMI and display it on LCD(later I want add some image processing). I'm storing image in QCIF format on internal RAM and then I'm sending it to LCD.

So far only LCD is working, but I cannot make camera working. When I'm trying to display captured image I'm always getting something similar to this:

0690X00000604BXQAY.jpg

Stripes on image changes colors and sometimes there are some noises.

Maybe there is problem with DCMI or camera registers configuration?

Here is DCMI configuration:

/**DCMI GPIO Configuration   

    PE4     ------> DCMI_D4

    PE5     ------> DCMI_D6

    PE6     ------> DCMI_D7

    PA4     ------> DCMI_HSYNC

    PA6     ------> DCMI_PIXCK

    PC6     ------> DCMI_D0

    PC7     ------> DCMI_D1

    PC8     ------> DCMI_D2

    PC9     ------> DCMI_D3

    PB6     ------> DCMI_D5

    PB7     ------> DCMI_VSYNC

    */

    GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

    GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;

    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

    GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_6;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

    GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;

    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

    GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

    GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;

    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

    GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

    GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;

    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

    /* DCMI DMA Init */

    /* DCMI Init */

    hdma_dcmi.Instance = DMA2_Stream1;

    hdma_dcmi.Init.Channel = DMA_CHANNEL_1;

    hdma_dcmi.Init.Direction = DMA_PERIPH_TO_MEMORY;

    hdma_dcmi.Init.PeriphInc = DMA_PINC_DISABLE;

    hdma_dcmi.Init.MemInc = DMA_MINC_ENABLE;

    hdma_dcmi.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;

    hdma_dcmi.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;

    hdma_dcmi.Init.Mode = DMA_CIRCULAR;

    hdma_dcmi.Init.Priority = DMA_PRIORITY_HIGH;

    hdma_dcmi.Init.FIFOMode = DMA_FIFOMODE_ENABLE;

    hdma_dcmi.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_1QUARTERFULL;

    hdma_dcmi.Init.PeriphBurst = DMA_PBURST_SINGLE;

Rest of a code in attachment.

Thank you for help

#ov7670 #stm32f4 #dcmi #stm32f4-ov7670 #stm32f4-dcmi
4 REPLIES 4
Posted on November 02, 2017 at 01:42

Not a whole lot of camera talent on the forum.

Looks like the raster length is wrong. You could try playing with that so the display straightens out. If this were my issue I'd inspect the rasters and bit maps, looking to see if any of the data in them was consistent or provided any insight.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
Posted on November 02, 2017 at 07:13

Not being a camera specialist, after reading the specs, I would break the problem in small pieces.

1. Are you able to draw a white border rectangle on black background at the edge of the LCD Display? Check carefully the corners for small defect, missing pixel or wrong color.

==> To make sure the frame buffer in RAM is well mapped

==> Note the color depth used.

2. Inject to the camera a full black and progressively white full picture and check if your incoming camera data looks fine and compatible with the LCD pixel mapping. 

3. Use horizontal, vertical lines to see if the frame contains vertical line pattern. If the vertical line look diagonal going down left, the total horizontal pixel per line is too small (h total too big = h pixels + h blanking) 

Dawid Brzakala
Associate II
Posted on November 02, 2017 at 09:53

Thank you,

LCD is working good, I can draw borders and i tested it drawing image similar to this 

http://forums.odforce.net/uploads/monthly_2017_05/render_pass_colourmap.jpg.18d10b8d9d63c8a67d4f3f56fb58189e.jpg

Problem was with blanking, but (what is strange) QCIF resolution is 144x176 and in my case its 144x172 so there is no h pixels + h blanking, but h pixels - h blanking.

I still have problem with colors, image is purplish and when I configured camera to display color bar colors are wrong, but I will try to find something on arduino forums.

I will check tonight if bits are not swapped.

Posted on November 29, 2017 at 15:43

have you found the reason for the colors problem? I'm getting strange colors and I don't know what is the reason