cancel
Showing results for 
Search instead for 
Did you mean: 

Why do I get overrun error when using DCMI?

YL.11
Associate II

BACKGROUND

project purpose: capture a picture every 2 seconds

board: nucleo stm32h743zi2 at 480MHz

ide: stm32cubeide

camera module: ov7670 at 24MHz

CONFIGURATION

The project was initialized using stm32cubeMX with I2C and DCMI initialized. The ov7670 is configured with QVGA resolutions and RGB565. I can confirm the ov7670 is properly configured because the debugger shows that each it_vsync contains 240 it_hsync (can be count using the interruption).

I have tried configuring the DMA with the following configurations:

  • DMA0/DMA1 Stream0-5
  • With and without FIFO
  • Normal Model and Circular model

Here is the main.c (only the part I added):

uint8_t framebuf[320 * 240 / 2];
void ov7670_Init() {
	ov7670_Stop();
	ov7670_Write_Reg(0x12, 0x80);  // RESET
    HAL_Delay(30);
    for(int i = 0; ov7670_reg[i][0] != REG_BATT; i++) {
    	ov7670_Write_Reg(ov7670_reg[i][0], ov7670_reg[i][1]);
    	HAL_Delay(1);
    }
}
 
...
 
int main(void)
{
  ...
  ov7670_Init();
  while (1)
  {
	  HAL_Delay(2000);
	  HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT, framebuf, 320*240/2);
  }
}

PROBLEM

Well, I can get the image bytes in the DR register of DCMI instance but the hdcmi->ErrorCode is 0 in the first 2 seconds and then becomes 65 (0x41), which I think means overrun error. The DMA2_Stream1_IRQHandler can trigger. The elements of framebuf are always random numbers. I did not do anything with the framebuf yet after capturing it.

So all together, I can the problem is related to the DMA settings.

Any idea how to solve the problem?

1 ACCEPTED SOLUTION

Accepted Solutions
YL.11
Associate II

Weeks have been spent before finally get things to work. I have to complian the code quality generated by cubeMX. After switching MX_DMA_Init() and MX_DCMI_Init() in the main.c file which is automatically generated, everything works fine.:dizzy_face:

View solution in original post

3 REPLIES 3
YL.11
Associate II

anybody can help?

YL.11
Associate II

Weeks have been spent before finally get things to work. I have to complian the code quality generated by cubeMX. After switching MX_DMA_Init() and MX_DCMI_Init() in the main.c file which is automatically generated, everything works fine.:dizzy_face:

Thanks for sharing your solution!

Had the exact same problem with my STM32H7A3IITxQ. Switching these functions also worked for me.

Seems like it hasn't been fixed in the last 2 years.