Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/ad-dyno1-ebz/ADuC702x.s

raw
1 ;/*****************************************************************************/
2 ;/* STARTUP.S: Startup file for ADI ADuC702x device series */
3 ;/*****************************************************************************/
4 ;/* <<< Use Configuration Wizard in Context Menu >>> */
5 ;/*****************************************************************************/
6 ;/* This file is part of the uVision/ARM development tools. */
7 ;/* Copyright (c) 2005-2006 Keil Software. All rights reserved. */
8 ;/* This software may only be used under the terms of a valid, current, */
9 ;/* end user licence from KEIL for a compatible version of KEIL software */
10 ;/* development tools. Nothing else gives you the right to use this software. */
11 ;/*****************************************************************************/
12
13
14 ;/*
15 ; * The STARTUP.S code is executed after CPU Reset. This file may be
16 ; * translated with the following SET symbols. In uVision these SET
17 ; * symbols are entered under Options - ASM - Define.
18 ; *
19 ; * RAM_INTVEC: when set the startup code copies exception vectors
20 ; * from on-chip Flash to on-chip RAM and remaps RAM to address 0.
21 ; */
22
23
24 ; Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs
25
26 Mode_USR EQU 0x10
27 Mode_FIQ EQU 0x11
28 Mode_IRQ EQU 0x12
29 Mode_SVC EQU 0x13
30 Mode_ABT EQU 0x17
31 Mode_UND EQU 0x1B
32 Mode_SYS EQU 0x1F
33
34 I_Bit EQU 0x80 ; when I bit is set, IRQ is disabled
35 F_Bit EQU 0x40 ; when F bit is set, FIQ is disabled
36
37
38 ;// <h> Stack Configuration (Stack Sizes in Bytes)
39 ;// <o0> Undefined Mode <0x0-0xFFFFFFFF:8>
40 ;// <o1> Supervisor Mode <0x0-0xFFFFFFFF:8>
41 ;// <o2> Abort Mode <0x0-0xFFFFFFFF:8>
42 ;// <o3> Fast Interrupt Mode <0x0-0xFFFFFFFF:8>
43 ;// <o4> Interrupt Mode <0x0-0xFFFFFFFF:8>
44 ;// <o5> User/System Mode <0x0-0xFFFFFFFF:8>
45 ;// </h>
46
47 UND_Stack_Size EQU 0x00000080
48 SVC_Stack_Size EQU 0x00000080
49 ABT_Stack_Size EQU 0x00000080
50 FIQ_Stack_Size EQU 0x00000080
51 IRQ_Stack_Size EQU 0x00000080
52 USR_Stack_Size EQU 0x00000400
53
54 Stack_Size EQU (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \
55 FIQ_Stack_Size + IRQ_Stack_Size + USR_Stack_Size)
56
57 AREA STACK, NOINIT, READWRITE, ALIGN=3
58 Stack_Mem SPACE Stack_Size
59
60 Stack_Top EQU Stack_Mem + Stack_Size
61
62
63 ;// <h> Heap Configuration
64 ;// <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF>
65 ;// </h>
66
67 Heap_Size EQU 0x00000000
68
69 AREA HEAP, NOINIT, READWRITE, ALIGN=3
70 Heap_Mem SPACE Heap_Size
71
72
73 ; MMR definitions
74 MMR_BASE EQU 0xFFFF0000 ; MMR Base Address
75 REMAP_OFFSET EQU 0x0220
76 POWKEY1_OFFSET EQU 0x0404
77 POWCON_OFFSET EQU 0x0408
78 POWKEY2_OFFSET EQU 0x040C
79
80 ;// <e> PLL Setup
81 ;// <o1.0..2> CD: PLL Multiplier Selection
82 ;// <0-7>
83 ;// <i> CD Value
84 ;// <o1.3> FINT: Fast Interrupt
85 ;// <0-1>
86 ;// <i> Switches to CD0 for FIQ
87 ;// </e>
88 PLL_SETUP EQU 1
89 PLLCFG_Val EQU 0x00000001
90
91
92 ;// <e> Pin Setup
93 GPIO_SETUP EQU 0
94 GPIOBASE EQU 0xFFFFF400
95
96 ;// <h> Port 0
97 ;// <o.0..1> P0.0 <0=> GPIO <1=> CMPOUT <2=> MS2 <3=> PLAI[7]
98 ;// <o.4..5> P0.1 <0=> GPIO <1=> --- <2=> XBEN0 <3=> ---
99 ;// <o.8..9> P0.2 <0=> GPIO <1=> --- <2=> XBEN1 <3=> ---
100 ;// <o.12..13> P0.3 <0=> GPIO <1=> TRST <2=> XA16 <3=> ADCBUSY
101 ;// <o.16..17> P0.4 <0=> GPIO/IRQ0 <1=> CONVSTART <2=> MS1 <3=> PLAO[1]
102 ;// <o.20..21> P0.5 <0=> GPIO/IRQ1 <1=> ADCBUSY <2=> MS0 <3=> PLAO[2]
103 ;// <o.24..25> P0.6 <0=> GPIO <1=> MRST <2=> XAE <3=> PLAO[3]
104 ;// <o.28..29> P0.7 <0=> GPIO <1=> ECLK <2=> SIN <3=> PLAO[4]
105 ;// </h>
106 GP0CON_Val EQU 0x00000000
107
108 ;// <h> Port 1
109 ;// <o.0..1> P1.0 <0=> GPIO <1=> SIN <2=> I2C0SCL <3=> PLAI[0]
110 ;// <o.4..5> P1.1 <0=> GPIO <1=> SOUT <2=> I2C0SDA <3=> PLAI[1]
111 ;// <o.8..9> P1.2 <0=> GPIO <1=> RTS <2=> I2C1SCL <3=> PLAI[2]
112 ;// <o.12..13> P1.3 <0=> GPIO <1=> CTS <2=> I2C1SDA <3=> PLAI[3]
113 ;// <o.16..17> P1.4 <0=> GPIO/IRQ2 <1=> RI <2=> SPICLK <3=> PLAI[4]
114 ;// <o.20..21> P1.5 <0=> GPIO/IRQ3 <1=> DCD <2=> SPIMISO <3=> PLAI[5]
115 ;// <o.24..25> P1.6 <0=> GPIO <1=> DSR <2=> SPIMOSI <3=> PLAI[6]
116 ;// <o.28..29> P1.7 <0=> GPIO <1=> DTR <2=> SPICSL <3=> PLAO[0]
117 ;// </h>
118 GP1CON_Val EQU 0x00000000
119
120 ;// <h> Port 2
121 ;// <o.0..1> P2.0 <0=> GPIO <1=> CONVSTART <2=> SOUT <3=> PLAO[5]
122 ;// <o.4..5> P2.1 <0=> GPIO <1=> --- <2=> XWS <3=> PLAO[6]
123 ;// <o.8..9> P2.2 <0=> GPIO <1=> --- <2=> XRS <3=> PLAO[7]
124 ;// <o.12..13> P2.3 <0=> GPIO <1=> --- <2=> XAE <3=> ---
125 ;// <o.16..17> P2.4 <0=> GPIO <1=> --- <2=> MS0 <3=> ---
126 ;// <o.20..21> P2.5 <0=> GPIO <1=> --- <2=> MS1 <3=> ---
127 ;// <o.24..25> P2.6 <0=> GPIO <1=> --- <2=> MS2 <3=> ---
128 ;// <o.28..29> P2.7 <0=> GPIO <1=> --- <2=> MS3 <3=> ---
129 ;// </h>
130 GP2CON_Val EQU 0x00000000
131
132 ;// <h> Port 3
133 ;// <o.0..1> P3.0 <0=> GPIO <1=> PWM0H <2=> XAD0 <3=> PLAI[8]
134 ;// <o.4..5> P3.1 <0=> GPIO <1=> PWM0L <2=> XAD1 <3=> PLAI[9]
135 ;// <o.8..9> P3.2 <0=> GPIO <1=> PWM1H <2=> XAD2 <3=> PLAI[10]
136 ;// <o.12..13> P3.3 <0=> GPIO <1=> PWM1L <2=> XAD3 <3=> PLAI[11]
137 ;// <o.16..17> P3.4 <0=> GPIO <1=> PWM2H <2=> XAD4 <3=> PLAI[12]
138 ;// <o.20..21> P3.5 <0=> GPIO <1=> PWM2L <2=> XAD5 <3=> PLAI[13]
139 ;// <o.24..25> P3.6 <0=> GPIO <1=> PWMTRIP <2=> XAD6 <3=> PLAI[14]
140 ;// <o.28..29> P3.7 <0=> GPIO <1=> PWMSYNC <2=> XAD7 <3=> PLAI[15]
141 ;// </h>
142 GP3CON_Val EQU 0x00000000
143
144 ;// <h> Port 4
145 ;// <o.0..1> P4.0 <0=> GPIO <1=> --- <2=> XAD8 <3=> PLAO[8]
146 ;// <o.4..5> P4.1 <0=> GPIO <1=> --- <2=> XAD9 <3=> PLAO[9]
147 ;// <o.8..9> P4.2 <0=> GPIO <1=> --- <2=> XAD10 <3=> PLAO[10]
148 ;// <o.12..13> P4.3 <0=> GPIO <1=> --- <2=> XAD11 <3=> PLAO[11]
149 ;// <o.16..17> P4.4 <0=> GPIO <1=> --- <2=> XAD12 <3=> PLAO[12]
150 ;// <o.20..21> P4.5 <0=> GPIO <1=> --- <2=> XAD13 <3=> PLAO[13]
151 ;// <o.24..25> P4.6 <0=> GPIO <1=> --- <2=> XAD14 <3=> PLAO[14]
152 ;// <o.28..29> P4.7 <0=> GPIO <1=> --- <2=> XAD15 <3=> PLAO[15]
153 ;// </h>
154 GP4CON_Val EQU 0x00000000
155
156 ;// </e>
157
158
159 ;// <e> External Memory Interface
160 XM_SETUP EQU 0
161 XMBASE EQU 0xFFFFF000
162
163 ;// <e.0> Enable Memory Region 0
164 ;// <o.1> Data Bus Width <0=> 8-bit <1=> 16-bit
165 ;// <o1.11> Enable Dynamic Addressing
166 ;// <o1.15> Byte Enabled Write Strobe
167 ;// <o1.10> Disable extra Address Latch Hold Cycle
168 ;// <o1.8> Disable extra Write Address Hold Cycle
169 ;// <o1.9> Disable Read Bus Turn Cycle
170 ;// <o1.12..14> Address Wait States <0-7>
171 ;// <i> Number of Wait States added for AE
172 ;// <o1.0..3> Read Wait States <0-15>
173 ;// <i> Number of Wait States added for RS
174 ;// <o1.4..7> Write Wait States <0-15>
175 ;// <i> Number of Wait States added for WS
176 ;// </e>
177 XM0CON_Val EQU 0x00000000
178 XM0PAR_Val EQU 0x000070FF
179
180 ;// <e.0> Enable Memory Region 1
181 ;// <o.1> Data Bus Width <0=> 8-bit <1=> 16-bit
182 ;// <o1.11> Enable Dynamic Addressing
183 ;// <o1.15> Byte Enabled Write Strobe
184 ;// <o1.10> Disable extra Address Latch Hold Cycle
185 ;// <o1.8> Disable extra Write Address Hold Cycle
186 ;// <o1.9> Disable Read Bus Turn Cycle
187 ;// <o1.12..14> Address Wait States <0-7>
188 ;// <i> Number of Wait States added for AE
189 ;// <o1.0..3> Read Wait States <0-15>
190 ;// <i> Number of Wait States added for RS
191 ;// <o1.4..7> Write Wait States <0-15>
192 ;// <i> Number of Wait States added for WS
193 ;// </e>
194 XM1CON_Val EQU 0x00000000
195 XM1PAR_Val EQU 0x000070FF
196
197 ;// <e.0> Enable Memory Region 2
198 ;// <o.1> Data Bus Width <0=> 8-bit <1=> 16-bit
199 ;// <o1.11> Enable Dynamic Addressing
200 ;// <o1.15> Byte Enabled Write Strobe
201 ;// <o1.10> Disable extra Address Latch Hold Cycle
202 ;// <o1.8> Disable extra Write Address Hold Cycle
203 ;// <o1.9> Disable Read Bus Turn Cycle
204 ;// <o1.12..14> Address Wait States <0-7>
205 ;// <i> Number of Wait States added for AE
206 ;// <o1.0..3> Read Wait States <0-15>
207 ;// <i> Number of Wait States added for RS
208 ;// <o1.4..7> Write Wait States <0-15>
209 ;// <i> Number of Wait States added for WS
210 ;// </e>
211 XM2CON_Val EQU 0x00000000
212 XM2PAR_Val EQU 0x000070FF
213
214 ;// <e.0> Enable Memory Region 3
215 ;// <o.1> Data Bus Width <0=> 8-bit <1=> 16-bit
216 ;// <o1.11> Enable Dynamic Addressing
217 ;// <o1.15> Byte Enabled Write Strobe
218 ;// <o1.10> Disable extra Address Latch Hold Cycle
219 ;// <o1.8> Disable extra Write Address Hold Cycle
220 ;// <o1.9> Disable Read Bus Turn Cycle
221 ;// <o1.12..14> Address Wait States <0-7>
222 ;// <i> Number of Wait States added for AE
223 ;// <o1.0..3> Read Wait States <0-15>
224 ;// <i> Number of Wait States added for RS
225 ;// <o1.4..7> Write Wait States <0-15>
226 ;// <i> Number of Wait States added for WS
227 ;// </e>
228 XM3CON_Val EQU 0x00000000
229 XM3PAR_Val EQU 0x000070FF
230
231 ;// <e.0> Memory Muxed Mode
232 XMCFG_Val EQU 0x00000001
233 ;// </e>
234
235 ;// </e>
236
237
238 PRESERVE8
239
240
241 ; Area Definition and Entry Point
242 ; Startup Code must be linked first at Address at which it expects to run.
243
244 AREA Reset, CODE, READONLY
245 ARM
246
247
248 ; Exception Vectors
249 ; Mapped to Address 0.
250 ; Absolute addressing mode must be used.
251 ; Dummy Handlers are implemented as infinite loops which can be modified.
252
253 Vectors LDR PC, Reset_Addr
254 LDR PC, Undef_Addr
255 LDR PC, SWI_Addr
256 LDR PC, PAbt_Addr
257 LDR PC, DAbt_Addr
258 DCD 0xFFFFFFFF ; Reserved Vector
259 LDR PC, IRQ_Addr
260 LDR PC, FIQ_Addr
261
262 EXTERN Undef_Handler
263 EXTERN SWI_Handler
264 EXTERN PAbt_Handler
265 EXTERN DAbt_Handler
266 EXTERN IRQ_Handler
267 EXTERN FIQ_Handler
268
269 Reset_Addr DCD Reset_Handler
270 Undef_Addr DCD Undef_Handler
271 SWI_Addr DCD SWI_Handler
272 PAbt_Addr DCD PAbt_Handler
273 DAbt_Addr DCD DAbt_Handler
274 DCD 0xFFFFFFFF ; Reserved Address
275 IRQ_Addr DCD IRQ_Handler
276 FIQ_Addr DCD FIQ_Handler
277
278
279 ; Reset Handler
280
281 EXPORT Reset_Handler
282 Reset_Handler
283
284
285 ; Setup PLL
286 IF PLL_SETUP <> 0
287 LDR R0, =MMR_BASE
288 MOV R1, #0x01
289 STR R1, [R0,#POWKEY1_OFFSET]
290 MOV R1, #PLLCFG_Val
291 STR R1, [R0,#POWCON_OFFSET]
292 MOV R1, #0xF4
293 STR R1, [R0,#POWKEY2_OFFSET]
294 ENDIF ; PLL_SETUP
295
296
297 ; Setup Pins
298 IF GPIO_SETUP <> 0
299
300 ADR R10, GPIO_CFG ; Pointer to GPIO CFG
301 LDMIA R10, {R0-R5} ; Load GPIO Configuration
302 STMIA R0, {R1-R5} ; Store GPxCON
303 B GPIO_END
304
305 GPIO_CFG DCD GPIOBASE
306 DCD GP0CON_Val
307 DCD GP1CON_Val
308 DCD GP2CON_Val
309 DCD GP3CON_Val
310 DCD GP4CON_Val
311 GPIO_END
312
313 ENDIF ; GPIO_SETUP
314
315
316 ; Setup External Memory Interface
317 IF XM_SETUP <> 0
318
319 ADR R10, XM_CFG ; Pointer to XM CFG
320 LDMIA R10, {R0-R9} ; Load XM Configuration
321 STR R1, [R0],#0x10 ; Store XMCFG
322 STMIA R0, {R2-R9} ; Store XMxCON & XMxPAR
323 B XM_END
324
325 XM_CFG DCD XMBASE
326 DCD XMCFG_Val
327 DCD XM0CON_Val
328 DCD XM1CON_Val
329 DCD XM2CON_Val
330 DCD XM3CON_Val
331 DCD XM0PAR_Val
332 DCD XM1PAR_Val
333 DCD XM2PAR_Val
334 DCD XM3PAR_Val
335 XM_END
336
337 ENDIF ; XM_SETUP
338
339
340 ; Copy Exception Vectors to Internal RAM and Remap Memory
341 ; (when Interrupt Vectors are in RAM)
342
343 IF :DEF:RAM_INTVEC
344 ADR R8, Vectors ; Source
345 LDR R9, =0x00010000 ; Destination
346 LDMIA R8!, {R0-R7} ; Load Vectors
347 STMIA R9!, {R0-R7} ; Store Vectors
348 LDMIA R8!, {R0-R7} ; Load Handler Addresses
349 STMIA R9!, {R0-R7} ; Store Handler Addresses
350 LDR R0, =MMR_BASE
351 MOV R1, #1
352 STR R1, [R0,#REMAP_OFFSET]
353 ENDIF
354
355
356 ; Setup Stack for each mode
357
358 LDR R0, =Stack_Top
359
360 ; Enter Undefined Instruction Mode and set its Stack Pointer
361 MSR CPSR_c, #Mode_UND:OR:I_Bit:OR:F_Bit
362 MOV SP, R0
363 SUB R0, R0, #UND_Stack_Size
364
365 ; Enter Abort Mode and set its Stack Pointer
366 MSR CPSR_c, #Mode_ABT:OR:I_Bit:OR:F_Bit
367 MOV SP, R0
368 SUB R0, R0, #ABT_Stack_Size
369
370 ; Enter FIQ Mode and set its Stack Pointer
371 MSR CPSR_c, #Mode_FIQ:OR:I_Bit:OR:F_Bit
372 MOV SP, R0
373 SUB R0, R0, #FIQ_Stack_Size
374
375 ; Enter IRQ Mode and set its Stack Pointer
376 MSR CPSR_c, #Mode_IRQ:OR:I_Bit:OR:F_Bit
377 MOV SP, R0
378 SUB R0, R0, #IRQ_Stack_Size
379
380 ; Enter Supervisor Mode and set its Stack Pointer
381 MSR CPSR_c, #Mode_SVC:OR:I_Bit:OR:F_Bit
382 MOV SP, R0
383 SUB R0, R0, #SVC_Stack_Size
384
385 ; Enter User Mode and set its Stack Pointer
386 MSR CPSR_c, #Mode_USR
387 MOV SP, R0
388 SUB SL, SP, #USR_Stack_Size
389
390
391 ; Enter the C code
392
393 IMPORT __main
394 LDR R0, =__main
395 BX R0
396
397
398 ; User Initial Stack & Heap
399 AREA |.text|, CODE, READONLY
400
401 IMPORT __use_two_region_memory
402 EXPORT __user_initial_stackheap
403 __user_initial_stackheap
404
405 LDR R0, = Heap_Mem
406 LDR R1, =(Stack_Mem + USR_Stack_Size)
407 LDR R2, = (Heap_Mem + Heap_Size)
408 LDR R3, = Stack_Mem
409 BX LR
410
411
412 END