cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U575I-EV DCMI example, expected performance

afok-esmart
Associate III

I am currently using the STM32U575I-EV; I was able to flash the DCMI example project's code from STM32CubeU5 (Projects\STM32U575I-EV\Examples\DCMI\DCMI_ContinousCap_EmbeddedSynchMode) and I see the onboard camera's feed displaying on the LCD as expected.

I wanted to measure the frame rate. To do this, I modified the behavior of LED5 (labelled LD5 on the eval kit; corresponding GPIO pin at PB7 in the CN14 header) such that each toggle represents a frame that got captured; with a logic analyzer, I count the number of edges within 1 sec and get the approx. frame rate. In the code, I comment out the main.c, BSP_LED_Off() function call, like so:

 

int main(void)
{
  /* init code ... */
  while (1)
  {
    /* LCD and suspend/resume code ...*/
    if(frame_captured != 0)
    {
      frame_captured = 0;
      BSP_LED_Toggle(LED5);
    }
//    else
//    {
//      BSP_LED_Off(LED5);
//    }
  }
}

 

 After doing this, the logic analyzer output showed about 7.5fps. This seems somewhat low, since the OV5640 camera's datasheet claims its maximum can be 120fps at the 320x240 resolution. So I wanted to ask if there are any suggestions for improving the frame rate. My company is working on a project that would like to achieve at least 720p 15fps with a similar setup.

1 ACCEPTED SOLUTION

Accepted Solutions
KDJEM.1
ST Employee

Hello @afok-esmart ,

 

Could you please try to increase the OV5640 input frequency to 24MHz.

For that please add this line of code in main.c in the OV5640 initialization.

  OV5640_SetPCLK(&OV5640Obj, OV5640_PCLK_24M);

Please let me know if you are able to achieve the 15fps.

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.

View solution in original post

5 REPLIES 5
KDJEM.1
ST Employee

Hello @afok-esmart ,

 

Could you please try to increase the OV5640 input frequency to 24MHz.

For that please add this line of code in main.c in the OV5640 initialization.

  OV5640_SetPCLK(&OV5640Obj, OV5640_PCLK_24M);

Please let me know if you are able to achieve the 15fps.

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.

KDJEM.1
ST Employee

Hello @afok-esmart ,

Also don't forget that the OV5640 imposes the clock frequency on the DCMI (the OV module is a master and the DCMI is a slave) to increase the fps rate we need to set up correctly the ov5640 to reach the15 fps.

What I want to say is that the DCMI support the 15 fps, but the OV5640 need to be configured to reach the 15 fps.

For that, please also modify this line of code in OV5640.c file

  {OV5640_SC_PLL_CONTRL2, 0x30},   /* 7.5 fps*/

 by

  {OV5640_SC_PLL_CONTRL2, 0x60},   /* 15 fps*/

 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.

When I only added OV5640_SetPCLK(&OV5640Obj, OV5640_PCLK_24M), this did bump it up to 15fps (thanks @KDJEM.1). The logic analyzer shows the frames coming in at an inconsistent rate but that's acceptable for my project at least for now. Here's the modification I made:

 

static uint32_t OV5640_Config(void)
{
    /* config/init code... */
    /* Disable Flip and mirror effect */
    if(OV5640_MirrorFlipConfig(&OV5640Obj, OV5640_MIRROR_FLIP_NONE)!= OV5640_OK)
    {
      status = OV5640_ERROR;
    }

    HAL_Delay(100);
    /* own - set clock to 24MHz */
    OV5640_SetPCLK(&OV5640Obj, OV5640_PCLK_24M);

    HAL_Delay(100);
    /* remaining code... */
}

 

I also tried adjusting OV5640_SC_PLL_CONTRL2 on top of the PCLK change but did not see any major improvement. Not sure if I did it correctly (or if I should even see any more improvement), since I didn't want to modify the OV5640 library directly; I did the following right after the OV5640_SetPCLK() call:

 

uint8_t tmp = 0x60;
OV5640Obj.IO.WriteReg(OV5640Obj.IO.Address, OV5640_SC_PLL_CONTRL2, &tmp, 1);

---------

EDIT1: Never mind about my OV5640_SC_PLL_CONTRL2 issue. Turns out the OV5640_SetPCLK() function already changes that register, so calling OV5640_SetPCLK() was enough.

 

If I wanted to try increasing the framerate even more i.e., I was trying to maximize it on this STM chip (recall my goal is 15fps but on 720p resolution), do you know if that's just simply increasing the value in OV5640_SC_PLL_CONTRL2 even more? From a quick glance at the datasheet, that's what I've guessed the PLL multiplier is somewhat, if not directly, used for.

KDJEM.1
ST Employee

Hello @afok-esmart ,

Glad to know the initial issue is resolved. For that, Could you please click on "Accept solution" on the reply which solved your issue or answered your question?

To modify the resolution, I advise you to refer to this table in the OV5640 datasheet and to 6.4 DMA configuration in AN5020.

KDJEM1_0-1707405038994.png

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.