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