startup_XMC1200.S
17.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
/******************************************************************************
* @file startup_XMC1200.s
* @brief CMSIS Core Device Startup File for
* Infineon XMC1200 Device Series
* @version V1.13
* @date Dec 2014
*
* Copyright (C) 2014 Infineon Technologies AG. All rights reserved.
*
*
* @par
* Infineon Technologies AG (Infineon) is supplying this software for use with
* Infineon's microcontrollers. This file can be freely distributed
* within development tools that are supporting such microcontrollers.
*
* @par
* THIS SOFTWARE IS PROVIDED AS IS. NO WARRANTIES, WHETHER EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
* ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
/********************** Version History ***************************************
* V1.0, Oct, 02, 2012 PKB:Startup file for XMC1
* V1.1, Oct, 19, 2012 PKB:ERU and MATH interrupt handlers
* V1.2, Nov, 02, 2012 PKB:Renamed AllowPLLInitByStartup to AllowClkInitByStartup
* V1.3, Dec, 11, 2012 PKB:Attributes of .XmcVeneerCode section changed
* V1.4, Dec, 13, 2012 PKB:Removed unwanted interrupts/veneers
* V1.5, Jan, 26, 2013 PKB:Corrected the SSW related entries
* V1.6, Feb, 13, 2013 PKB:Relative path to Device_Data.h
* V1.7, Feb, 19, 2013 PKB:Included XMC1100_SCU.inc
* V1.8, Jan, 24, 2014 PKB:Removed AllowClkInitStartup and DAVE Extended init
* V1.9, Feb, 05, 2014 PKB:Removed redundant alignment code from copy+clear funcs
* V1.10, Feb, 14, 2014 PKB:Added software_init_hook and hardware_init_hook
* V1.11, May, 06, 2014 JFT:__COPY_FLASH2RAM to initialize ram
* Added ram_code section initialization
* V1.12, Sep, 29, 2014 JFT:One single default handler
* Device_Data.h not included, user may use CLKVAL1_SSW
* and CLKVAL2_SSW.
* software_init_hook and hardware_init_hook removed
* Misc optimizations
* V1.13, Dec, 11,2014 JFT:Default clocking changed, MCLK=32MHz and PCLK=64MHz
******************************************************************************/
/*****************************************************************************
* <h> Clock system handling by SSW
* <h> CLK_VAL1 Configuration
* <o0.0..7> FDIV Fractional Divider Selection
* <o0.8..15> IDIV Divider Selection (limited to 1-16)
* <0=> Divider is bypassed
* <1=> MCLK = 32 MHz
* <2=> MCLK = 16 MHz
* <3=> MCLK = 10.67 MHz
* <4=> MCLK = 8 MHz
* <254=> MCLK = 126 kHz
* <255=> MCLK = 125.5 kHz
* <o0.16> PCLKSEL PCLK Clock Select
* <0=> PCLK = MCLK
* <1=> PCLK = 2 x MCLK
* <o0.17..19> RTCCLKSEL RTC Clock Select
* <0=> 32.768kHz standby clock
* <1=> 32.768kHz external clock from ERU0.IOUT0
* <2=> 32.768kHz external clock from ACMP0.OUT
* <3=> 32.768kHz external clock from ACMP1.OUT
* <4=> 32.768kHz external clock from ACMP2.OUT
* <5=> Reserved
* <6=> Reserved
* <7=> Reserved
* <o0.31> do not move CLK_VAL1 to SCU_CLKCR[0..19]
* </h>
*****************************************************************************/
#define CLKVAL1_SSW 0x00010100
/*****************************************************************************
* <h> CLK_VAL2 Configuration
* <o0.0> disable VADC and SHS Gating
* <o0.1> disable CCU80 Gating
* <o0.2> disable CCU40 Gating
* <o0.3> disable USIC0 Gating
* <o0.4> disable BCCU0 Gating
* <o0.5> disable LEDTS0 Gating
* <o0.6> disable LEDTS1 Gating
* <o0.7> disable POSIF0 Gating
* <o0.8> disable MATH Gating
* <o0.9> disable WDT Gating
* <o0.10> disable RTC Gating
* <o0.31> do not move CLK_VAL2 to SCU_CGATCLR0[0..10]
* </h>
*****************************************************************************/
#define CLKVAL2_SSW 0x80000000
/* A macro to define vector table entries */
.macro Entry Handler
.long \Handler
.endm
/* A couple of macros to ease definition of the various handlers */
.macro Insert_ExceptionHandler Handler_Func
.weak \Handler_Func
.thumb_set \Handler_Func, Default_handler
.endm
/* ================== START OF VECTOR TABLE DEFINITION ====================== */
/* Vector Table - This is indirectly branched to through the veneers */
.syntax unified
.cpu cortex-m0
.section ".reset"
.align 2
.globl __Vectors
.type __Vectors, %object
__Vectors:
.long __initial_sp /* Top of Stack */
.long Reset_Handler /* Reset Handler */
/*
* All entries below are redundant for M0, but are retained because they can
* in the future be directly ported to M0 Plus devices.
*/
.long 0 /* Reserved */
Entry HardFault_Handler /* Hard Fault Handler */
.long CLKVAL1_SSW /* Reserved */
.long CLKVAL2_SSW /* Reserved */
#ifdef RETAIN_VECTOR_TABLE
.long 0 /* Reserved */
.long 0 /* Reserved */
.long 0 /* Reserved */
.long 0 /* Reserved */
.long 0 /* Reserved */
Entry SVC_Handler /* SVCall Handler */
.long 0 /* Reserved */
.long 0 /* Reserved */
Entry PendSV_Handler /* PendSV Handler */
Entry SysTick_Handler /* SysTick Handler */
/* Interrupt Handlers for Service Requests (SR) from XMC1200 Peripherals */
Entry SCU_0_IRQHandler /* Handler name for SR SCU_0 */
Entry SCU_1_IRQHandler /* Handler name for SR SCU_1 */
Entry SCU_2_IRQHandler /* Handler name for SR SCU_2 */
Entry ERU0_0_IRQHandler /* Handler name for SR ERU0_0 */
Entry ERU0_1_IRQHandler /* Handler name for SR ERU0_1 */
Entry ERU0_2_IRQHandler /* Handler name for SR ERU0_2 */
Entry ERU0_3_IRQHandler /* Handler name for SR ERU0_3 */
.long 0 /* Not Available */
.long 0 /* Not Available */
Entry USIC0_0_IRQHandler /* Handler name for SR USIC0_0 */
Entry USIC0_1_IRQHandler /* Handler name for SR USIC0_1 */
Entry USIC0_2_IRQHandler /* Handler name for SR USIC0_2 */
Entry USIC0_3_IRQHandler /* Handler name for SR USIC0_3 */
Entry USIC0_4_IRQHandler /* Handler name for SR USIC0_4 */
Entry USIC0_5_IRQHandler /* Handler name for SR USIC0_5 */
Entry VADC0_C0_0_IRQHandler /* Handler name for SR VADC0_C0_0 */
Entry VADC0_C0_1_IRQHandler /* Handler name for SR VADC0_C0_1 */
Entry VADC0_G0_0_IRQHandler /* Handler name for SR VADC0_G0_0 */
Entry VADC0_G0_1_IRQHandler /* Handler name for SR VADC0_G0_1 */
Entry VADC0_G1_0_IRQHandler /* Handler name for SR VADC0_G1_0 */
Entry VADC0_G1_1_IRQHandler /* Handler name for SR VADC0_G1_1 */
Entry CCU40_0_IRQHandler /* Handler name for SR CCU40_0 */
Entry CCU40_1_IRQHandler /* Handler name for SR CCU40_1 */
Entry CCU40_2_IRQHandler /* Handler name for SR CCU40_2 */
Entry CCU40_3_IRQHandler /* Handler name for SR CCU40_3 */
.long 0 /* Not Available */
.long 0 /* Not Available */
.long 0 /* Not Available */
.long 0 /* Not Available */
Entry LEDTS0_0_IRQHandler /* Handler name for SR LEDTS0_0 */
Entry LEDTS1_0_IRQHandler /* Handler name for SR LEDTS1_0 */
Entry BCCU0_0_IRQHandler /* Handler name for SR BCCU0_0 */
#endif
.size __Vectors, . - __Vectors
/* ================== END OF VECTOR TABLE DEFINITION ======================= */
/* ================== START OF VECTOR ROUTINES ============================= */
.thumb
.align 1
/* Reset Handler */
.thumb_func
.globl Reset_Handler
.type Reset_Handler, %function
Reset_Handler:
/* Initialize interrupt veneer */
ldr r1, =eROData
ldr r2, =VeneerStart
ldr r3, =VeneerEnd
bl __copy_data
ldr r0, =SystemInit
blx r0
/* Initialize data */
ldr r1, =DataLoadAddr
ldr r2, =__data_start
ldr r3, =__data_end
bl __copy_data
/* RAM code */
ldr r1, =__ram_code_load
ldr r2, =__ram_code_start
ldr r3, =__ram_code_end
bl __copy_data
/* Define __SKIP_BSS_CLEAR to disable zeroing uninitialzed data in startup.
* The BSS section is specified by following symbols
* __bss_start__: start of the BSS section.
* __bss_end__: end of the BSS section.
*
* Both addresses must be aligned to 4 bytes boundary.
*/
#ifndef __SKIP_BSS_CLEAR
ldr r1, =__bss_start
ldr r2, =__bss_end
movs r0, 0
subs r2, r1
ble .L_loop3_done
.L_loop3:
subs r2, #4
str r0, [r1, r2]
bgt .L_loop3
.L_loop3_done:
#endif /* __SKIP_BSS_CLEAR */
#ifndef __SKIP_LIBC_INIT_ARRAY
ldr r0, =__libc_init_array
blx r0
#endif
ldr r0, =main
blx r0
.thumb_func
.type __copy_data, %function
__copy_data:
/* The ranges of copy from/to are specified by following symbols
* r1: start of the section to copy from.
* r2: start of the section to copy to
* r3: end of the section to copy to
*
* All addresses must be aligned to 4 bytes boundary.
* Uses r0
*/
subs r3, r2
ble .L_loop_done
.L_loop:
subs r3, #4
ldr r0, [r1,r3]
str r0, [r2,r3]
bgt .L_loop
.L_loop_done:
bx lr
.pool
.size Reset_Handler,.-Reset_Handler
/* ======================================================================== */
/* ========== START OF EXCEPTION HANDLER DEFINITION ======================== */
.align 1
.thumb_func
.weak Default_handler
.type Default_handler, %function
Default_handler:
b .
.size Default_handler, . - Default_handler
Insert_ExceptionHandler HardFault_Handler
Insert_ExceptionHandler SVC_Handler
Insert_ExceptionHandler PendSV_Handler
Insert_ExceptionHandler SysTick_Handler
Insert_ExceptionHandler SCU_0_IRQHandler
Insert_ExceptionHandler SCU_1_IRQHandler
Insert_ExceptionHandler SCU_2_IRQHandler
Insert_ExceptionHandler ERU0_0_IRQHandler
Insert_ExceptionHandler ERU0_1_IRQHandler
Insert_ExceptionHandler ERU0_2_IRQHandler
Insert_ExceptionHandler ERU0_3_IRQHandler
Insert_ExceptionHandler VADC0_C0_0_IRQHandler
Insert_ExceptionHandler VADC0_C0_1_IRQHandler
Insert_ExceptionHandler VADC0_G0_0_IRQHandler
Insert_ExceptionHandler VADC0_G0_1_IRQHandler
Insert_ExceptionHandler VADC0_G1_0_IRQHandler
Insert_ExceptionHandler VADC0_G1_1_IRQHandler
Insert_ExceptionHandler CCU40_0_IRQHandler
Insert_ExceptionHandler CCU40_1_IRQHandler
Insert_ExceptionHandler CCU40_2_IRQHandler
Insert_ExceptionHandler CCU40_3_IRQHandler
Insert_ExceptionHandler USIC0_0_IRQHandler
Insert_ExceptionHandler USIC0_1_IRQHandler
Insert_ExceptionHandler USIC0_2_IRQHandler
Insert_ExceptionHandler USIC0_3_IRQHandler
Insert_ExceptionHandler USIC0_4_IRQHandler
Insert_ExceptionHandler USIC0_5_IRQHandler
Insert_ExceptionHandler LEDTS0_0_IRQHandler
Insert_ExceptionHandler LEDTS1_0_IRQHandler
Insert_ExceptionHandler BCCU0_0_IRQHandler
/* ======================================================================== */
/* ==================VENEERS VENEERS VENEERS VENEERS VENEERS=============== */
.section ".XmcVeneerCode","ax",%progbits
.align 1
.globl HardFault_Veneer
HardFault_Veneer:
LDR R0, =HardFault_Handler
MOV PC,R0
.long 0
.long 0
.long 0
.long 0
.long 0
.long 0
.long 0
/* ======================================================================== */
.globl SVC_Veneer
SVC_Veneer:
LDR R0, =SVC_Handler
MOV PC,R0
.long 0
.long 0
/* ======================================================================== */
.globl PendSV_Veneer
PendSV_Veneer:
LDR R0, =PendSV_Handler
MOV PC,R0
/* ======================================================================== */
.globl SysTick_Veneer
SysTick_Veneer:
LDR R0, =SysTick_Handler
MOV PC,R0
/* ======================================================================== */
.globl SCU_0_Veneer
SCU_0_Veneer:
LDR R0, =SCU_0_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl SCU_1_Veneer
SCU_1_Veneer:
LDR R0, =SCU_1_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl SCU_2_Veneer
SCU_2_Veneer:
LDR R0, =SCU_2_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl SCU_3_Veneer
SCU_3_Veneer:
LDR R0, =ERU0_0_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl SCU_4_Veneer
SCU_4_Veneer:
LDR R0, =ERU0_1_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl SCU_5_Veneer
SCU_5_Veneer:
LDR R0, =ERU0_2_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl SCU_6_Veneer
SCU_6_Veneer:
LDR R0, =ERU0_3_IRQHandler
MOV PC,R0
.long 0
.long 0
/* ======================================================================== */
.globl USIC0_0_Veneer
USIC0_0_Veneer:
LDR R0, =USIC0_0_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl USIC0_1_Veneer
USIC0_1_Veneer:
LDR R0, =USIC0_1_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl USIC0_2_Veneer
USIC0_2_Veneer:
LDR R0, =USIC0_2_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl USIC0_3_Veneer
USIC0_3_Veneer:
LDR R0, =USIC0_3_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl USIC0_4_Veneer
USIC0_4_Veneer:
LDR R0, =USIC0_4_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl USIC0_5_Veneer
USIC0_5_Veneer:
LDR R0, =USIC0_5_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl VADC0_C0_0_Veneer
VADC0_C0_0_Veneer:
LDR R0, =VADC0_C0_0_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl VADC0_C0_1_Veneer
VADC0_C0_1_Veneer:
LDR R0, =VADC0_C0_1_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl VADC0_G0_0_Veneer
VADC0_G0_0_Veneer:
LDR R0, =VADC0_G0_0_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl VADC0_G0_1_Veneer
VADC0_G0_1_Veneer:
LDR R0, =VADC0_G0_1_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl VADC0_G1_0_Veneer
VADC0_G1_0_Veneer:
LDR R0, =VADC0_G1_0_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl VADC0_G1_1_Veneer
VADC0_G1_1_Veneer:
LDR R0, =VADC0_G1_1_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl CCU40_0_Veneer
CCU40_0_Veneer:
LDR R0, =CCU40_0_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl CCU40_1_Veneer
CCU40_1_Veneer:
LDR R0, =CCU40_1_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl CCU40_2_Veneer
CCU40_2_Veneer:
LDR R0, =CCU40_2_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl CCU40_3_Veneer
CCU40_3_Veneer:
LDR R0, =CCU40_3_IRQHandler
MOV PC,R0
.long 0
.long 0
.long 0
.long 0
/* ======================================================================== */
.globl LEDTS0_0_Veneer
LEDTS0_0_Veneer:
LDR R0, =LEDTS0_0_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl LEDTS1_0_Veneer
LEDTS1_0_Veneer:
LDR R0, =LEDTS1_0_IRQHandler
MOV PC,R0
/* ======================================================================== */
.globl BCCU0_0_Veneer
BCCU0_0_Veneer:
LDR R0, =BCCU0_0_IRQHandler
MOV PC,R0
/* ======================================================================== */
/* ======================================================================== */
/* ============= END OF INTERRUPT HANDLER DEFINITION ======================== */
.end