Page 1
Introduction This application note mainly introduces: 1. How to configure and modify the clock source code based on the BSP_V2.x.x provided by Artery. 2. How to use the accessary clock configuration tools to set clock path and parameters to generate and use the corresponding clock code.
As the necessary condition for the correct and efficient running of chips, proper clock configuration is of great importance. The clock configuration of each AT32 series MCU may be slight different. This application note mainly introduces how to use BSP_V2.x.x provided by Artery to perform clock configuration of the corresponding AT32 MCU series.
AT32F403A/407 CRM Quick Start Guide Clock tree Before configuring the clock, it is necessary to have a comprehensive understanding of the clock tree, with focuses on the clock source, frequency multiplication and system clock. Figure 1. AT32F403A/407 clock tree SCLKSEL HEXT_IN HEXT HEXT OSC...
Page 8
AT32F403A/407 CRM Quick Start Guide Figure 1 contains the following key elements: SCLKSEL: The system clock can be selected from HEXT, PLLCLK and HICK. HEXT: It is a high-speed external oscillator that is connected externally to a 4~25 MHz crystal or clock source.
AT32F403A/407 CRM Quick Start Guide Code configuration This section introduces how to use library functions to configure the clock. Functions The interface functions for hardware clock configuration in BSP of the corresponding MCU series are encapsulated and can be called. Functions commonly used for clock configuration are listed below.
AT32F403A/407 CRM Quick Start Guide HICK The HICK oscillator is clocked by a high-speed RC in the microcontroller. Enable HICK clock source and wait until HICK clock becomes stable. The code is as follows: crm_clock_source_enable(CRM_CLOCK_SOURCE_HICK, TRUE); /* Enable HICK clock source */ while(crm_flag_get(CRM_HICK_STABLE_FLAG) != SET) /* Wait until HICK stable flag is set */ 3.2.3 PLL configuration...
AT32F403A/407 CRM Quick Start Guide 3.2.4 Set bus frequency division The bus frequency division configuration includes SCLK to AHBCLK, AHBCLK to APB1CLK and AHBCLK to APB2CLK. The code to implement AHB bus (SCLK/1) and APB1/APB2 bus (AHBCLK/2) is as follow: crm_ahb_div_set(CRM_AHB_DIV_1);...
AT32F403A/407 CRM Quick Start Guide is as follows: crm_sysclk_switch(CRM_SCLK_HEXT); /* Switch system clock source to HEXT */ while(crm_sysclk_switch_status_get() != CRM_SCLK_HEXT) /* Wait until the system clock is switched to HEXT */ PLLCLK When the PLLCLK is used as system clock source, the system clock frequency depends on the actual PLL frequency multiplication and the maximum frequency.
Page 14
AT32F403A/407 CRM Quick Start Guide while(crm_flag_get(CRM_PLL_STABLE_FLAG) != SET) /* Wait until PLL becomes stable */ crm_ahb_div_set(CRM_AHB_DIV_1); /* SCLK/1 is used as AHB bus clock */ crm_apb2_div_set(CRM_APB2_DIV_2); /* AHBCLK/2 is used as APB2 bus clock */ crm_apb1_div_set(CRM_APB1_DIV_2); /* AHBCLK/2 is used as APB1 bus clock */ crm_auto_step_mode_enable(TRUE);...
AT32F403A/407 CRM Quick Start Guide Clock configuration tools The New Clock Configuration is a graphical configuration tool developed by Artery for configuring the clock of AT32 series MCUs, to help users have a better understanding of the clock path, configure the required frequency and generate source files.
AT32F403A/407 CRM Quick Start Guide Figure 4. Configuration interface Menu bar The menu bar is shown below. Figure 5. Menu bar Project Create a new configuration project Open Open an existing configuration project Save Save the current configuration project ...
Clock configuration interface Users can configure the clock path and parameters in the clock configuration interface. Figure 7 shows the clock configuration for AT32F403A series MCU. The clock configuration interface mainly contains four blocks, as shown below. Figure 7. Clock configuration interface 1.
AT32F403A/407 CRM Quick Start Guide Figure 8 illustrates the clock configuration block. The configuration process corresponds to MCU clock tree, which may be slightly different for different MCU series. The clock path can be configured by clicking on each checkbox according to the configuration process, as shown below. Figure 8.
AT32F403A/407 CRM Quick Start Guide selected, CLKOUT HICK frequency is also 48 MHz). 13. usbdiv: drop-down box, which is used to configure PLL division factor when PLL clock is selected as the USB clock source. 14. hick to usb: checkbox, which is used to configure USB clocked by PLL clock or HICK 48 MHz. The USB clock configuration code is controlled by the “to usb”...
Notes on using the New Clock Configuration tool: The clock configuration source file generated by the New Clock Configuration tool should be used together with BSP_V2.x.x provided by Artery. The clock configuration source file generated for the specific MCU series should be used in the corresponding project only.
AT32F403A/407 CRM Quick Start Guide Application case 1: Switch system clock Introduction Switch the system clock when the system is running. Resources Hardware AT-START BOARD of the corresponding MCU series Software project\at_start_f403a\examples\crm\sysclk_switch Software design Configuration process Initialize buttons; Configure PLL/4 for CLKOUT;...
Page 22
AT32F403A/407 CRM Quick Start Guide crm_clock_source_enable(CRM_CLOCK_SOURCE_HICK, TRUE); /* Enable HICK clock source */ while(crm_flag_get(CRM_HICK_STABLE_FLAG) != SET) /* Wait until HICK stable flag is set */ crm_pll_config(CRM_PLL_SOURCE_HICK, CRM_PLL_MULT_16, CRM_PLL_OUTPUT_RANGE_LE72MHZ); /* Configure PLL: select HICK as the PLL clock source; set multiplication factor = 16, and PLL clock output range ≤ 72 MHz; formula: PLLCLK = 8 / 2 * 16 = 64 MHz */ crm_clock_source_enable(CRM_CLOCK_SOURCE_PLL, TRUE);...
AT32F403A/407 CRM Quick Start Guide Application case 2: Clock fail detector Introduction The clock fail detector is designed to respond to HEXT clock failure when the HEXT is used as the system clock, directly or indirectly. If a failure is detected on the HEXT clock, a NMI interrupt is generated so that the software can perform rescue operations.
AT32F403A/407 CRM Quick Start Guide Test result A clock failure occurs when the crystal is disconnected or the crystal pin is grounded during operation. Generally, HEXT is more stable than HICK, which is suitable to be used to observe CLKOUT (PA8) output.
AT32F403A/407 CRM Quick Start Guide Revision history Table 1. Document revision history Date Version Revision note 2021.8.18 2.0.0 Initial release. 2021.9.30 2.0.1 Updated sample code processing flow. 2021.10.21 2.0.2 Updated clock block diagram and partial function name. 2021.11.24 2.0.3 Updated the screenshot of New Clock Configuration tool. Updated the screenshot of New Clock Configuration tool and description of 2022.06.10 2.0.4...
Page 28
No license, express or implied, to any intellectual property rights is granted under this document. If any part of this docum ent deals with any third party products or services, it shal l not be deemed a license grant by ARTERY for the use of such third party products or services, or any intellectual property contained therein, or considered as a warranty regarding the use in any manner whatsoever of such third party products or services or any intellectual property contained therein.
Need help?
Do you have a question about the AT32F403A Series and is the answer not in the manual?
Questions and answers