]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/Core_A/src/Ref_SystemAndClock.txt
Update README.md (#73)
[cmsis] / CMSIS / DoxyGen / Core_A / src / Ref_SystemAndClock.txt
1 /* ################################  System and Clock Configuration   ########################### */
2 /**************************************************************************************************/
3 /**
4 \defgroup   system_init_gr   System and Clock Configuration
5 \brief Functions for system and clock setup available in system_<i>device</i>.c.
6 \details
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. 
12
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.
16
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 initialization (i.e. \c SystemInit()) might get
21 overwritten by C library startup code. Thus its highly recommended to call \ref SystemCoreClockUpdate
22 at the beginning of the user \c main() routine.
23
24 \section system_init_code_ex_sec Code Example
25 The code below shows the usage of the variable \ref SystemCoreClock and the functions 
26 SystemInit() and SystemCoreClockUpdate() with an arbitrary Arm Cortex-A9.
27     
28 \code
29 #include "ARMCA9.h"
30
31 uint32_t coreClock_1 = 0;                       /* Variables to store core clock values */
32 uint32_t coreClock_2 = 0;
33
34
35 int main (void)  {
36
37   coreClock_1 = SystemCoreClock;                /* Store value of predefined SystemCoreClock */
38
39   SystemCoreClockUpdate();                      /* Update SystemCoreClock according to register settings */
40
41   coreClock_2 = SystemCoreClock;                /* Store value of calculated SystemCoreClock */
42
43   if (coreClock_2 != coreClock_1)  {            /* Without changing the clock setting both core clock values should be the same */ 
44     // Error Handling
45   }
46
47   while(1);
48 }
49 \endcode    
50     
51 @{
52 */
53
54
55 /**************************************************************************************************/
56 /** 
57     \brief      Variable to hold the system core clock value
58     \details
59     Holds the system core clock, which is the system clock      frequency supplied to the SysTick 
60     timer and the processor core clock. This variable can be used by debuggers to query the 
61     frequency of the debug timer or to configure the trace clock speed.
62                      
63     \attention  Compilers must be configured to avoid removing this variable in case the application 
64                 program is not using it. Debugging systems require the variable to be physically 
65                 present in memory so that it can be examined to configure the debugger.
66 */
67 uint32_t SystemCoreClock;
68
69
70 /**************************************************************************************************/
71 /** 
72     \brief      Function to Initialize the system.
73     \details    
74     Initializes the microcontroller system. Typically, this function configures the 
75                      oscillator (PLL) that is part of the microcontroller device. For systems 
76                      with a variable clock speed, it updates the variable \ref SystemCoreClock.
77                      SystemInit is called from the file <b>startup<i>_device</i></b>.
78 */
79 void SystemInit (void);
80
81
82 /**************************************************************************************************/
83 /** 
84     \brief      Function to update the variable \ref SystemCoreClock
85     \details    
86     Updates the variable \ref SystemCoreClock and must be called whenever the core clock is changed 
87     during program execution. The function evaluates the clock register settings and calculates 
88     the current core clock.
89 */
90 void SystemCoreClockUpdate (void);
91
92
93 /** @} */  /* end group system_init_gr */
94