Change CPU frequency ? #12249
-
I notice that the machine_freq (set) function is not implemented for the m.iMX RT port. I'm not sure I'm capable of proposing an implementation. There are a lot of elements to control/check for a hot change? I tried a hard implementation by changing the BOARD_BOOTCLOCKRUN_CORE_CLOCK parameter and recompiling. This doesn't seem to be enough (cpu still at 600 Mhz). Am I way off the mark? |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 10 replies
-
Changing BOARD_BOOTCLOCKRUN_CORE_CLOCK does indeed not have any effect. The clock configuration is done in the respective boards/MIMXRTxxx_clock_config.c files and before that in the ROM code. Detailed information about the clock system can be found in the respective chapters of the Reference Manual. It looks complicated, and there a quite a few peripherals which require a fixed frequency. So just changing the ARM clock may not drop the power consumption substantially, if that is your interest. |
Beta Was this translation helpful? Give feedback.
-
By applying these modifications, I have good results (warning: do not apply my tests without checking) :
however, the processing of delays in my programs is not good (e.g. a time.sleep(5) will take 5 sec). I had understood the reference to be SystemCoreClock(=BOARD_BOOTCLOCKRUN_CORE_CLOCK) but that doesn't seem to be the case. I'm wrong in thinking that it's necessarily an oversight on my part in one of the 2 files MIMXRT1062_clock_config.[hc]? |
Beta Was this translation helpful? Give feedback.
-
sleep(5) takes now 5s? Coincidentally I tried to change ARM_PLL this afternoon as well, setting it to 300Mhz. That worked. Code execution got ~20% slower, and the current consumption of a Teensy4.1 dropped from 78mA to 56mA. Only reflashing the code after setting the change back was tricky. So that should better go into machine.freq() and the CPU should start at 600Mhz as usual. |
Beta Was this translation helpful? Give feedback.
-
Using fixed setting for just 150, 300 and 600 MHz the clocks can be balanced such that the IPG clock is still at 150Mhz. Code snippet below, using your changes as template. But the power consumption drops not dramatically. Just from 72mA to 54 mA at a Teensy 4.1.
|
Beta Was this translation helpful? Give feedback.
-
I finished a branch which includes the freq setting for all MCUs except MIMXRT1176. It is here: https://github.com/robert-hh/micropython/tree/mimxrt_freq. The power saving is usually pretty low. Teensy with ~30% is the largest. So I do not know whether I should make a PR for it. Maybe only for API consistency. |
Beta Was this translation helpful? Give feedback.
-
Yup, I was also having this same issue. But after getting here, I did fix it with the help of you guys. |
Beta Was this translation helpful? Give feedback.
-
Hi robert-hh, |
Beta Was this translation helpful? Give feedback.
-
I moved it to an archived copy of my repository. But I can put it back, if you need it. |
Beta Was this translation helpful? Give feedback.
I finished a branch which includes the freq setting for all MCUs except MIMXRT1176. It is here: https://github.com/robert-hh/micropython/tree/mimxrt_freq. The power saving is usually pretty low. Teensy with ~30% is the largest. So I do not know whether I should make a PR for it. Maybe only for API consistency.