| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /*
- * Copyright (c) 2006-2021, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- * 2024-08-30 shelton first version
- */
- #include "board.h"
- void system_clock_config(void)
- {
- /* reset crm */
- crm_reset();
- /* config flash psr register */
- flash_psr_set(FLASH_WAIT_CYCLE_5);
- /* enable pwc periph clock */
- crm_periph_clock_enable(CRM_PWC_PERIPH_CLOCK, TRUE);
- /* set power ldo output voltage to 1.3v */
- pwc_ldo_output_voltage_set(PWC_LDO_OUTPUT_1V3);
- crm_clock_source_enable(CRM_CLOCK_SOURCE_HEXT, TRUE);
- /* wait till hext is ready */
- while(crm_hext_stable_wait() == ERROR)
- {
- }
- /* if pll parameter has changed, please use the AT32_New_Clock_Configuration tool for new configuration. */
- crm_pll_config(CRM_PLL_SOURCE_HEXT, 90, 1, CRM_PLL_FR_4);
- /* enable pll */
- crm_clock_source_enable(CRM_CLOCK_SOURCE_PLL, TRUE);
- /* wait till pll is ready */
- while(crm_flag_get(CRM_PLL_STABLE_FLAG) != SET)
- {
- }
- /* config ahbclk */
- crm_ahb_div_set(CRM_AHB_DIV_1);
- /* config apb3clk, the maximum frequency of APB3 clock is 90 MHz */
- crm_apb3_div_set(CRM_APB3_DIV_4);
- /* config apb2clk, the maximum frequency of APB2 clock is 180 MHz */
- crm_apb2_div_set(CRM_APB2_DIV_1);
- /* config apb1clk, the maximum frequency of APB1 clock is 180 MHz */
- crm_apb1_div_set(CRM_APB1_DIV_1);
- /* enable auto step mode */
- crm_auto_step_mode_enable(TRUE);
- /* select pll as system clock source */
- crm_sysclk_switch(CRM_SCLK_PLL);
- /* wait till pll is used as system clock source */
- while(crm_sysclk_switch_status_get() != CRM_SCLK_PLL)
- {
- }
- /* disable auto step mode */
- crm_auto_step_mode_enable(FALSE);
- /* update system_core_clock global variable */
- system_core_clock_update();
- }
|