STM32U575I-EV DCMI OV5640, maximize frame rate for 720p/1080p JPEGs
I previously made another post regarding minimal adjustments to the DCMI example from the v1.4.0 MCU package. I've made several changes since and now, instead of determining the expected performance, would like to maximize the performance, namely the FPS, of the OV5640 (w/ both 720p and 1080p JPEGs).
I've gotten as far as 720p JPEGs coming in around 24fps, solely from increasing OV5640 PCLK (and I'm still working on correctly configuring for 1080p images). Whether it be adjustments to OV5640 configuration, code optimizations, STM clock frequencies, or more, I would like to ask about any and all suggestions for what I can look into.
--------
The general changes I've made so far:
- Use JPEG format for images (i.e., w/ DCMI 'JPEG mode' enabled)
- Use multiple buffers (4 of them, each 38,400 bytes) as described in AN5020 Rev 3 Ch6.4.9 (HAL seems to automatically handle this in HAL_DCMI_Start_DMA())
- Increase resolution of images (ex: for 720p, I set OV5640_TIMING_DVPHO_HIGH to 0x05, OV5640_TIMING_DVPHO_LOW to 0x00, OV5640_TIMING_DVPVO_HIGH to 0x02, and OV5640_TIMING_DVPVO_LOW to 0xD0)
- Increase OV5640 PCLK to 96MHz (I set OV5640_SC_PLL_CONTRL2 to 0x60, and OV5640_SC_PLL_CONTRL3 to 0x13)
- Measure frame rate using an LED (turns on when first enters GPDMA1_Channel12_IRQHandler(), turns off when exits handler)
- For example - If I see the LED toggle on/off 36 times in 1 second (via logic analyzer), that's 36 * 38,400 bytes = 1.4MB of data in 1 second. I had sandbox code for this same setup that could produce 720p JPEGs as large as 170KB. If each image is 170KB, that's 1.4MB/170KB = 7.8 JPEGs per second (almost 8fps).
--------
Helpful links:
- OV5640 datasheet - https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/OV5640_datasheet.pdf
- STM intro to DCMI document - https://www.st.com/content/ccc/resource/technical/document/application_note/group0/c0/ef/15/38/d1/d6/49/88/DM00373474/files/DM00373474.pdf/jcr:content/translations/en.DM00373474.pdf
- My old post about similar work - Solved: Re: STM32U575I-EV DCMI example, expected performan... - STMicroelectronics Community
--------
Development Environment:
- Windows 10
- STM32CubeIDE 1.14.1
