cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H747I-DISCO + OV5640 framerate

avburmel
Associate II

I have an STM32H747I-DISCO board and a B-CAMS-OMV camera module with the OV5640 sensor.

 

I'm trying to increase the frame rate using the BSP code from the example:
https://github.com/STMicroelectronics/stm32ai-modelzoo-services/tree/main

 

I managed to achieve a capture frame rate of 50 fps at 320x240 resolution by increasing the PCLK to 80 MHz.
Then, I tried switching the pixel format from OV5640_RGB565 to OV5640_Y8. This worked — I halved the buffer sizes and successfully displayed a grayscale image. However, the frame rate did not increase, even though the amount of data per frame was reduced by half. On the oscilloscope, I can see that the HSYNC pulse frequency remained unchanged.

After reading various forums and the OV5640 datasheet, I found that these registers affect the frame rate:

  • 0x380C TIMING HTS [11:8] (high byte)
  • 0x380D TIMING HTS [7:0] (low byte)
  • 0x380E TIMING VTS [15:8] (high byte)
  • 0x380F TIMING VTS [7:0] (low byte)

Assumed formula is:
Frame rate = Pixel clock / (HTS × VTS)

In my BSP driver, the default register values are:

 
{OV5640_TIMING_HTS_HIGH, 0x06},
{OV5640_TIMING_HTS_LOW, 0x40},
{OV5640_TIMING_VTS_HIGH, 0x03},
{OV5640_TIMING_VTS_LOW, 0xe8}
 

Which corresponds to HTS = 0x640 = 1600, VTS = 0x3E8 = 1000.
Using 80 MHz pixel clock: 80,000,000 / (1600 × 1000) = 50 fps — matches my measurement.

 

However, when looking at different OV5640 driver implementations, I see various values for HTS/VTS depending on the format, and I can't figure out the logic behind calculating these values.

 

Question 1: Why did changing the pixel format from 2-byte (RGB565) to 1-byte (Y8) not reduce the HSYNC interval or increase the frame rate?

 

Question 2: Is there a clear algorithm or method to correctly calculate HTS and VTS values based on the pixel format and resolution?

 

Question 3: Are there any other ways to further increase the frame rate with this hardware setup?

 

Any help or clarification would be greatly appreciated!

4 REPLIES 4
KDJEM.1
ST Employee

Hello @avburmel and welcome to the community;

 

To increase the frame rate you need increase the pixel clock frequency and adjust the camera PLL configuration. 

For more information, I advise you to refer to How to improve DCMI frame rate: An example using a... - STMicroelectronics Community.

 Also I advise you to reach higher framerates:

- Use only internal memory for DCMI frames.

- Use external memory without accessing by other masters for huge data(LTDC, DMA2D,..)

 

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello @KDJEM.1.
Thank you for the helpful link. However, I have already performed these actions. This reduces transmission time and memory usage, but the HSYNC duration is incomparably longer. Are there any proper ways to reduce HSYNC duration for the OV5640 camera?

avburmel
Associate II

The first question is resolved.
The HSYNC interval does change when switching formats—it's just difficult to notice against the background of the much longer HSYNC blanking period before outputting the next image line.

Questions 2 and 3 remain relevant: Are there any ways to configure the timing of the OV5640 camera for faster frame output, other than adjusting the PLL?

KDJEM.1
ST Employee

Hello @avburmel ;

 

Thank you for updating post.

On my end, the only solution I have tested to increase the frame rate is to increase the pixel clock frequency and adjust the camera's PLL configuration. 

 

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.