1 /* ################################ System and Clock Configuration ########################### */
2 /**************************************************************************************************/
4 \defgroup system_init_gr System and Clock Configuration
5 \brief Functions for system and clock setup available in system_<i>device</i>.c.
7 Arm provides a template file <b>system_<i>device</i>.c</b> that must be adapted by
8 the silicon vendor to match their actual device. As a <b>minimum requirement</b>,
9 this file must provide:
10 - A device-specific system configuration function, \ref SystemInit().
11 - A global variable that contains the system frequency, \ref SystemCoreClock.
13 The file configures the device and, typically, initializes the oscillator (PLL) that is part
14 of the microcontroller device. This file might export other functions or variables that provide
15 a more flexible configuration of the microcontroller system.
17 \note Please pay special attention to the static variable \c SystemCoreClock. This variable might be
18 used throughout the whole system initialization and runtime to calculate frequency/time related values.
19 Thus one must assure that the variable always reflects the actual system clock speed. Be aware that
20 a value stored to \c SystemCoreClock during low level initializaton (i.e. \c SystemInit()) might get
21 overwritten by C libray startup code and/or .bss section initialization.
22 Thus its highly recommended to call \ref SystemCoreClockUpdate at the beginning of the user \c main() routine.
25 \section system_init_code_ex_sec Code Example
26 The code below shows the usage of the variable \ref SystemCoreClock and the functions
27 SystemInit() and SystemCoreClockUpdate() with an LPC1700.
32 uint32_t coreClock_1 = 0; /* Variables to store core clock values */
33 uint32_t coreClock_2 = 0;
38 coreClock_1 = SystemCoreClock; /* Store value of predefined SystemCoreClock */
40 SystemCoreClockUpdate(); /* Update SystemCoreClock according to register settings */
42 coreClock_2 = SystemCoreClock; /* Store value of calculated SystemCoreClock */
44 if (coreClock_2 != coreClock_1) { /* Without changing the clock setting both core clock values should be the same */
56 /**************************************************************************************************/
58 \brief Variable to hold the system core clock value
60 Holds the system core clock, which is the system clock frequency supplied to the SysTick
61 timer and the processor core clock. This variable can be used by debuggers to query the
62 frequency of the debug timer or to configure the trace clock speed.
64 \attention Compilers must be configured to avoid removing this variable in case the application
65 program is not using it. Debugging systems require the variable to be physically
66 present in memory so that it can be examined to configure the debugger.
68 uint32_t SystemCoreClock;
71 /**************************************************************************************************/
73 \brief Function to Initialize the system.
75 Initializes the microcontroller system. Typically, this function configures the
76 oscillator (PLL) that is part of the microcontroller device. For systems
77 with a variable clock speed, it updates the variable \ref SystemCoreClock.
78 SystemInit is called from the file <b>startup<i>_device</i></b>.
80 void SystemInit (void);
83 /**************************************************************************************************/
85 \brief Function to update the variable \ref SystemCoreClock
87 Updates the variable \ref SystemCoreClock and must be called whenever the core clock is changed
88 during program execution. The function evaluates the clock register settings and calculates
89 the current core clock.
91 void SystemCoreClockUpdate (void);
94 /** @} */ /* end group system_init_gr */