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 },
};