# F7 consumption optimization

**URL:** <https://forums.openmv.io/t/f7-consumption-optimization/1020>\
**Category:** OpenMV Boards\
**Created:** [November 28, 2018, 11:22am UTC](https://forums.openmv.io/t/f7-consumption-optimization/1020 "2018-11-28T11:22:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisPyres66](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/chrispyres66/32/39_2.png) [@chrisPyres66](https://forums.openmv.io/u/chrisPyres66)\
**Post date:** [November 28, 2018, 11:22am UTC](https://forums.openmv.io/t/f7-consumption-optimization/1020/1 "2018-11-28T11:22:11Z")

</div>

Hello,

I try to optimize the consumption, and i would like to start the camera at 120Mhz.

Before compiling, i changed in /openmv/src/cmsis/src/st/system\_stm32fxxx.c

```python
    #elif defined (STM32F765xx) // 120MHz/48Mhz in place of 216MHz/48MHz : 
    flash_latency = FLASH_LATENCY_3; // FLASH_LATENCY_7;
    RCC_OscInitStruct.PLL.PLLM = 12;
    RCC_OscInitStruct.PLL.PLLN = 240; // 432;
    RCC_OscInitStruct.PLL.PLLQ = 5; // 9;
    RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
    RCC_OscInitStruct.PLL.PLLR = 2;

```

but when i snapshot, the pixels are mixed in the images.  
Do i forget something ?

Thanks,

---

<div class="post-metadata">

**Author:** ![iabdalkader](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/iabdalkader/32/1169_2.png) [@iabdalkader](https://forums.openmv.io/u/iabdalkader)\
**Post date:** [November 28, 2018, 12:16pm UTC](https://forums.openmv.io/t/f7-consumption-optimization/1020/2 "2018-11-28T12:16:59Z")

</div>

> [@](#):
>
> Hello,
> 
> I try to optimize the consumption, and i would like to start the camera at 120Mhz.
> 
> Before compiling, i changed in /openmv/src/cmsis/src/st/system\_stm32fxxx.c
> 
> ```python
> #elif defined (STM32F765xx) // 120MHz/48Mhz in place of 216MHz/48MHz : 
> flash_latency = FLASH_LATENCY_3; // FLASH_LATENCY_7;
> RCC_OscInitStruct.PLL.PLLM = 12;
> RCC_OscInitStruct.PLL.PLLN = 240; // 432;
> RCC_OscInitStruct.PLL.PLLQ = 5; // 9;
> RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
> RCC_OscInitStruct.PLL.PLLR = 2;
> 
> ```
> 
> but when i snapshot, the pixels are mixed in the images.  
> Do i forget something ?
> 
> Thanks,

Hi, please use CubeMX to check your PLL settings (note the external clock is 12MHz). Also there’s a cpufreq module that can scale the frequency from Python, but it’s not tested thoroughly.

---

<div class="post-metadata">

**Author:** ![chrisPyres66](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/chrispyres66/32/39_2.png) [@chrisPyres66](https://forums.openmv.io/u/chrisPyres66)\
**Post date:** [November 28, 2018, 4:00pm UTC](https://forums.openmv.io/t/f7-consumption-optimization/1020/3 "2018-11-28T16:00:07Z")

</div>

Thanks for answer,

Yes i tried the cpufreq module like :

```python
import cpufreq
#cpufreq.set_frequency(cpufreq.CPUFREQ_120MHZ)

```

and i seemed to work.

I used the cubemx with the value from py\_cpufreq.c like in the previous post.  
I joined :

- the cubemx file where there is only a difference for I2C1 (30Mhz in place of 54Mhz) : is it important ?  
the image i get (the top third is ok)

Did i forget something in the plls (USB, DCMI, TIM1, SD) ?

Thanks,  
 ![Pb_Snapshot.PNG](https://canada1.discourse-cdn.com/flex029/uploads/openmv1/original/1X/d388b76953db6c8c4452fc918bb0de48bdf5d52a.png)  
[ClockV1.7z](https://forums.openmv.io/uploads/short-url/jOtRzJIlD0FCfao6bRXQhsInYwg.7z) (2.72 KB)

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [November 28, 2018, 4:33pm UTC](https://forums.openmv.io/t/f7-consumption-optimization/1020/4 "2018-11-28T16:33:48Z")

</div>

Hi, the cpufreq module should not be used. That only worked on the M4. I think I removed in from the docs but it’s still in the code base.

---

<div class="post-metadata">

**Author:** ![chrisPyres66](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/chrispyres66/32/39_2.png) [@chrisPyres66](https://forums.openmv.io/u/chrisPyres66)\
**Post date:** [December 4, 2018, 7:53am UTC](https://forums.openmv.io/t/f7-consumption-optimization/1020/5 "2018-12-04T07:53:58Z")

</div>

Hi,

Yes cpufreq module is in the source code, and it still seems worked…

As adviced, I used cubeMX for clock and i could define OMV\_XCLK\_FREQUENCY to define the good acquisition period for the sensor.  
Unfortunately, i am still a bit lost between all the clock and voltage parameters to optimize the consumption.

I dont know when the micropython parameters acts.  
I join a image with the different parameters i found and if someone can explain me how it works ?

Thanks,

 ![Parameter_CLOCK.PNG](https://canada1.discourse-cdn.com/flex029/uploads/openmv1/original/1X/ddb5d8a8f8dea9416c8f88095b470705c54c8d8a.png)

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [December 4, 2018, 5:45pm UTC](https://forums.openmv.io/t/f7-consumption-optimization/1020/6 "2018-12-04T17:45:03Z")

</div>

Ibrahim can answer this.

---

<div class="post-metadata">

**Author:** ![iabdalkader](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/iabdalkader/32/1169_2.png) [@iabdalkader](https://forums.openmv.io/u/iabdalkader)\
**Post date:** [December 4, 2018, 7:48pm UTC](https://forums.openmv.io/t/f7-consumption-optimization/1020/7 "2018-12-04T19:48:55Z")

</div>

MicroPython’s PLL settings are not used and system\_stm32.c is not used either. We use our own system file and PLL dividers, you can find out which files are used from the Makefile(s). Note you need to make sure the sensor frequency is 9MHz (or change the sensor’s PLL settings to match XCLK). I tried cpufreq.CPUFREQ\_168MHZ it seems to work. It’s really hard to find settings that works with everything (sensor, uart, USB etc…) I’d use CubeMX to verify all the frequencies.
