You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my testbed, the current CPU frequency is 160MHz.
TRM says, using PLL_CLK as clock source, it can have 3 different values: 80MHz, 160MHz and 240MHz (sect. 3.2.3).
The goal of this task is to enable somehow to change the CPU clock frequency.
TRM seems to be somewhat incompete about this, since merely modifying the value of DPORT_CPU_PER_CONF_REG.DPORT_CPU_CPUPERIOD_SEL does not result in the expected behavior.
Study the implementation of setting the CPU clock frequency in esp-idf.
I managed to switch from PLL to XTL as cpu clk src, but switching from XTL to PLL(240MHz) or from PLL(160MHz) to PLL(240MHz) is not resolved yet. The digital voltage regulator output level settings seem to have effect (there is a change in flowing current (and power consumption)), so the problem lies somewhere else.
Anyway, the lessons already learned:
With XTL_CLK (40MHz) the flowing current drops from ~ 0.040A to ~ 0.025A, which is a significant change. We should consider introducing a so-called rest_state or whatever, when the prog_cycle_xxx() tasks are already done and there is no interrupt expected to happen. And during this rest_state we can switch to XTL_CLK. Of course, there are many things to do, e.g., measure the time delay caused by switching, check clock accuracy, etc.
With XTL_CLK the APB_CLK frequency drops (from 80MHz) to 40MHz (or even lower if we shrink the CPU freq by increasing the SYSCON_PRE_DIV_CNT value). Currently the 80MHz is a hardwired value (#define-d) with all its derivatives (including the widely used MS2TICKS(X) macro). By introducing this clock swich, APB_FREQ_HZ becomes a variable (or at least can have any value of a predefined set, e.g., 80, 40, 20, 10, 5, 2, 1 MHz), so this change must be elaborated deeper.
Activity
SzigetiJ commentedon Jul 26, 2026
Setting 160MHz -> 80MHz works by default:
SzigetiJ commentedon Jul 29, 2026
Found the corresponding code in esp-idf:
To set CPU freq to 240MHz, we also have to adjust the CPU voltage:
The bit values come from consts and efuse parameter
The esp-idf procedure also does the followings:
SzigetiJ commentedon Jul 30, 2026
This is kind of WIP report.
I managed to switch from PLL to XTL as cpu clk src, but switching from XTL to PLL(240MHz) or from PLL(160MHz) to PLL(240MHz) is not resolved yet. The digital voltage regulator output level settings seem to have effect (there is a change in flowing current (and power consumption)), so the problem lies somewhere else.
Anyway, the lessons already learned:
rest_stateor whatever, when theprog_cycle_xxx()tasks are already done and there is no interrupt expected to happen. And during thisrest_statewe can switch toXTL_CLK. Of course, there are many things to do, e.g., measure the time delay caused by switching, check clock accuracy, etc.XTL_CLKtheAPB_CLKfrequency drops (from 80MHz) to 40MHz (or even lower if we shrink the CPU freq by increasing theSYSCON_PRE_DIV_CNTvalue). Currently the 80MHz is a hardwired value (#define-d) with all its derivatives (including the widely usedMS2TICKS(X)macro). By introducing this clock swich,APB_FREQ_HZbecomes a variable (or at least can have any value of a predefined set, e.g., 80, 40, 20, 10, 5, 2, 1 MHz), so this change must be elaborated deeper.SzigetiJ commentedon Aug 4, 2026
Done. See #60
Note, using
XTL_CLK, at CPU frequency of 4 MHz,UART0does not work as expected. With higher CPU frequencies,UART0is fine.