]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/Core/src/Ref_SystemAndClock.txt
CoreValidation: Fixed TC_CoreFunc_APSR and TC_CoreInstr_RRX.
[cmsis] / CMSIS / DoxyGen / Core / 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 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.
23
24
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.
28     
29 \code
30 #include "LPC17xx.h"
31
32 uint32_t coreClock_1 = 0;                       /* Variables to store core clock values */
33 uint32_t coreClock_2 = 0;
34
35
36 int main (void)  {
37
38   coreClock_1 = SystemCoreClock;                /* Store value of predefined SystemCoreClock */
39
40   SystemCoreClockUpdate();                      /* Update SystemCoreClock according to register settings */
41
42   coreClock_2 = SystemCoreClock;                /* Store value of calculated SystemCoreClock */
43
44   if (coreClock_2 != coreClock_1)  {            /* Without changing the clock setting both core clock values should be the same */ 
45     // Error Handling
46   }
47
48   while(1);
49 }
50 \endcode    
51     
52 @{
53 */
54
55
56 /**************************************************************************************************/
57 /** 
58     \brief      Variable to hold the system core clock value
59     \details
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.
63                      
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.
67 */
68 uint32_t SystemCoreClock;
69
70
71 /**************************************************************************************************/
72 /** 
73     \brief      Function to Initialize the system.
74     \details    
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>.
79 */
80 void SystemInit (void);
81
82
83 /**************************************************************************************************/
84 /** 
85     \brief      Function to update the variable \ref SystemCoreClock
86     \details    
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.
90 */
91 void SystemCoreClockUpdate (void);
92
93
94 /** @} */  /* end group system_init_gr */
95