esp32c3 change cpu_clock_src

BugSimpson
Posts: 22
Joined: Fri Oct 11, 2024 2:14 pm

esp32c3 change cpu_clock_src

Postby BugSimpson » Sat Dec 28, 2024 10:06 am

hello @all,

i try to change the cpu clock source (by manipulating registers) and read the
( SYSTEM_SYSCLK_CONF_REG & SYSTEM_CLK_XTAL_FREQ_bm ) xtal frequency, i become everytime 40mhz.
it will be not change -.-*

i try to change like this ->

Code: Untitled.c Select all


void app_main(void)
{
sys_set_cpu_clock_frequency(CPU_CLK_SRC_PLL_CLK_3);

while (1)
{
spi_write_dword( sys_get_xtal_clk_freq() );
spi_write_dword( sys_get_soc_clk_sel() );
spi_write_dword( sys_get_pll_clock_frequency() );
spi_write_dword( sys_get_cpu_period_select() );
}
}

Code: Untitled.c Select all


void sys_set_cpu_clock_frequency( const cpu_clock_source_t _src )
{
sys_set_soc_clk_sel( cpu_clock_source[ _src ][0] );
sys_set_pll_clock_frequency( cpu_clock_source[ _src ][1] );
sys_set_cpu_period_select( cpu_clock_source[ _src ][2] );
}

Code: Untitled.c Select all


typedef enum cpu_clock_source_e
{
CPU_CLK_SRC_XTAL_CLK,
CPU_CLK_SRC_PLL_CLK_1,
CPU_CLK_SRC_PLL_CLK_2,
CPU_CLK_SRC_PLL_CLK_3,
CPU_CLK_SRC_PLL_CLK_4,
CPU_CLK_SRC_RC_FAST_CLK
}cpu_clock_source_t;

const uint8_t cpu_clock_source[][3] =
{
//SYSTEM_SOC_CLK_SEL | SYSTEM_PLL_FREQ_SEL | SYSTEM_PERIOD_SEL
{ 0 , 0 , 0 },
{ 1 , 1 , 0 },
{ 1 , 1 , 1 },
{ 1 , 0 , 0 },
{ 1 , 0 , 1 },
{ 2 , 0 , 0 },
};

MicroController
Posts: 2661
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: esp32c3 change cpu_clock_src

Postby MicroController » Sat Dec 28, 2024 6:03 pm

read the ( SYSTEM_SYSCLK_CONF_REG & SYSTEM_CLK_XTAL_FREQ_bm ) xtal frequency, i become everytime 40mhz.
it will be not change -.-*
->
SYSTEM_CLK_XTAL_FREQ This field is used to read XTAL frequency in MHz. (RO)
That field would make sense to not be changing - unless you could make the 40MHz external quartz crystal ("XTAL") change its frequency...

BugSimpson
Posts: 22
Joined: Fri Oct 11, 2024 2:14 pm

Re: esp32c3 change cpu_clock_src

Postby BugSimpson » Sat Dec 28, 2024 6:36 pm

i only read this register..

Who is online

Users browsing this forum: Google [Bot], YisouSpider and 3 guests