]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/Core_A/src/Using.txt
Rework documentation for using Core_A, added missing diagram and adopted the basic...
[cmsis] / CMSIS / DoxyGen / Core_A / src / Using.txt
1 /** 
2 \page using_pg Using CMSIS in Embedded Applications
3
4
5 \details 
6
7 To use the CMSIS-Core-A the following files are added to the embedded application:
8  - \ref startup_c_pg with reset handler and exception vectors.
9  - \ref system_c_pg with general device configuration (i.e. for clock and bus setup).
10  - \ref device_h_pg gives access to processor core and all peripherals.
11  - \ref mem_h_pg contains basic memory configurations.
12  - \ref mmu_c_pg contains the memory management unit setup.
13  
14 \note The files \ref startup_c_pg, \ref system_c_pg, \ref mem_h_pg, and \ref mmu_h_pg may require application specific adaptations and therefore should be copied 
15       into the application project folder prior configuration. The \ref device_h_pg is included in all source files that need device access 
16           and can be stored on a central include folder that is generic for all projects.
17
18 The \ref ResetHandler defined in \ref startup_c_pg is executed after reset. 
19 The default initialization sequence is
20  - set the vector base address register (\ref __set_VBAR),
21  - set stacks for each exception mode (\ref __set_mode, \ref __set_SP),
22  - call \ref MMU_CreateTranslationTable, and
23  - call \ref SystemInit.
24
25 After the system initialization control is transferred to the C/C++ run-time
26 library which performs initialization and calls the \b main function in the user code. In addition the \ref startup_c_pg contains a weak default handler
27 implementation for every exception. It may also contain stack and heap configurations for the user application.
28
29 The \ref system_c_pg performs the setup for the processor clock. The variable \ref SystemCoreClock indicates the CPU clock speed.
30 \ref system_init_gr describes the minimum feature set. In addition the file may contain functions for the memory bus setup and clock re-configuration. 
31
32 The \ref device_h_pg is the central include file that the application programmer is using in the C/C++ source code. It provides the following features:
33  - \ref peripheral_gr provides a standardized register layout for all peripherals. Optionally functions for device-specific peripherals may be available.
34  - \ref GIC_gr can be accessed with standardized symbols and functions for the General Interrupt Controller (GIC) are provided.
35  - \ref intrinsic_CPU_gr allow to access special instructions, for example for activating sleep mode or the NOP instruction.
36  - \ref intrinsic_SIMD_gr provide access to the DSP-oriented instructions.
37  - \ref SysTick_gr function to configure and start a periodic timer interrupt.
38  - \ref ITM_Debug_gr are functions that allow printf-style I/O via the CoreSight Debug Unit and ITM communication.
39
40 \image html "CMSIS_CORE_A_Files_user.png" "CMSIS-Core-A User Files"
41
42 The CMSIS-Core-A user files are device specific. In addition, the \ref startup_c_pg is also compiler vendor specific. 
43 The various compiler vendor tool chains may provide folders that contain the CMSIS files for each supported device.
44   
45 \note The silicon vendors create these device-specific CMSIS-Core-A files based on \ref templates_pg provide by ARM.
46
47 Thereafter, the functions described under <a href="Modules.html">\b Reference </a> can be used in the application.
48
49 \b Examples
50  - \subpage using_CMSIS is a simple example that shows the usage of the CMSIS layer.
51  - \subpage using_ARM_pg explains how to use CMSIS-Core-M for ARM processors.
52
53
54 \page using_CMSIS Basic CMSIS Example
55
56 A typical example for using the CMSIS layer is provided below. The example is based on an unspecific Cortex-A9 Device. 
57     
58 \code
59 #include <ARMCA9.h>                              // File name depends on device used
60  
61 static const uint32_t TICK_RATE_HZ = 1000U;
62  
63 uint32_t volatile msTicks;                       // Counter for millisecond Interval
64  
65 static void SysTick_Handler( void )
66 {
67         msTicks++;                                   // Increment Counter
68 }
69  
70 // We use the Private Tiemer (PTIM) of the Cortex-A9 FVP Model here.
71 // In general the available Timers are highly vendor specific for Cortex-A processors.
72 void private_timer_init(void) {
73  
74   PTIM_SetLoadValue ((SystemCoreClock/TICK_RATE_HZ) - 1U);
75   PTIM_SetControl (PTIM_GetControl() | 7U);
76
77   /* Install SysTick_Handler as the interrupt function for PTIM */
78   InterruptHandlerRegister (PrivTimer_IRQn, SysTick_Handler);
79  
80   /* Determine number of implemented priority bits */
81   GIC_SetPriority (PrivTimer_IRQn, 0xFFU);
82  
83   /* Set lowest priority -1 */
84   GIC_SetPriority (PrivTimer_IRQn, GIC_GetPriority(PrivTimer_IRQn)-1);
85  
86   /* Enable IRQ */
87   GIC_EnableIRQ (PrivTimer_IRQn);
88 }
89
90 /* Delay execution for given amount of ticks */
91 void Delay(uint32_t ticks)  {
92   uint32_t tgtTicks = msTicks + ticks;           // target tick count to delay execution to
93   while (msTicks == tgtTicks)  {
94     __WFE ();                                    // Power-Down until next Event/Interrupt
95   }
96 }
97  
98 /* main function */
99 int main(void)
100 {
101   /* Initialize device HAL here */
102   private_timer_init();
103  
104   static uint8_t ledState = 0;
105  
106   /* Infinite loop */
107   while (1)
108   {
109           /* Add application code here */
110           ledState = !ledState;
111           Delay(500);
112   }
113 }
114 \endcode
115     
116 \page using_ARM_pg Using CMSIS with generic ARM Processors
117
118 ARM provides CMSIS-Core-A files for the supported ARM Processors and for various compiler vendors. 
119 These files can be used when standard ARM processors should be used in a project.
120 The table below lists the folder and device names of the ARM processors.
121   
122 <table class="cmtable">
123     <tr>
124       <th>Folder</th>
125       <th>Processor</th>
126       <th>Description</th>
127     </tr>
128     <tr>
129       <td>".\Device\ARM\ARMCA7"</td>
130       <td>Cortex-A7</td>
131       <td>Contains \b Include and \b Source template files configured for the Cortex-A7 processor.
132               The device name is ARMCA7 and the name of the \ref device_h_pg is <ARMCA7.h>.
133           </td>
134     </tr>
135     <tr>
136       <td>".\Device\ARM\ARMCA9"</td>
137       <td>Cortex-A9</td>
138       <td>Contains \b Include and \b Source template files configured for the Cortex-A9 processor.
139               The device name is ARMCA9 and the name of the \ref device_h_pg is <ARMCA9.h>.
140           </td>
141     </tr>
142 </table>
143
144 */