‎2020-01-02 07:19 PM
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:
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?
Solved! Go to Solution.
‎2020-01-17 12:04 AM
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:
‎2020-01-07 02:54 AM
anybody can help?
‎2020-01-17 12:04 AM
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:
‎2022-03-28 11:15 PM
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.