OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [MB96340_Softune/] [FreeRTOS_96348hs_SK16FX100PMC/] [Src/] [START.ASM] - Blame information for rev 584

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 584 jeremybenn
;====================================================================
2
; THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS.
3
;  FUJITSU MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY
4
;         FOR ANY ERRORS OR ELIGIBILITY FOR ANY PURPOSES.
5
;
6
;    Startup file for memory and basic controller initialisation
7
;
8
;    MB96300 Family C Compiler
9
;
10
;    (C) FUJITSU MICROELECTRONICS EUROPE 1998-2008
11
;====================================================================
12
 
13
          .PROGRAM  STARTUP
14
          .TITLE    "STARTUP FILE FOR MEMORY INITIALISATION"
15
 
16
;====================================================================
17
; 1  Contents
18
;====================================================================
19
; 1   Contents
20
; 2   Disclaimer
21
; 3   History
22
;
23
; 4   SETTINGS              (USER INTERFACE)
24
; 4.1  Controller Series
25
; 4.2   C-language Memory model
26
; 4.3   Function-Call Interface
27
; 4.4   Constant Data Handling
28
; 4.5   Stack Type and Stack Size
29
; 4.6   General Register Bank
30
; 4.7   Low-Level Library Interface
31
; 4.8   Clock Selection
32
; 4.9   Clock Stabilization Time
33
; 4.10  External Bus Interface
34
; 4.11  ROM Mirror configuration
35
; 4.12  Flash Security
36
; 4.13  Flash Write Protection
37
; 4.14  Boot Vector
38
; 4.15  UART scanning
39
; 4.16  Enable RAMCODE Copying
40
; 4.17  Enable information stamp in ROM
41
; 4.18  Enable Background Debugging Mode
42
;
43
; 5   Section and Data Declaration
44
; 5.1   Several fixed addresses (fixed for MB963xx controllers)
45
; 5.2   Declaration of __near addressed data sections
46
; 5.3   Declaration of RAMCODE section and labels
47
; 5.4   Declaration of sections containing other sections description
48
; 5.5   Stack area and stack top definition/declaration
49
; 5.6   Direct page register dummy label definition
50
;
51
; 6   Start-Up Code
52
; 6.1   Import external symbols
53
; 6.2   Program start (the boot vector should point here)
54
; 6.3   "NOT RESET YET" WARNING
55
; 6.4   Initialisation of processor status
56
; 6.5   Set clock ratio (ignore subclock)
57
; 6.6   Set external bus configuration
58
; 6.7   Prepare stacks and set the active stack type
59
; 6.8   Copy initial values to data areas
60
; 6.9   Clear uninitialised data areas to zero
61
; 6.10  Set Data Bank Register (DTB) and Direct Page Register (DPR)
62
; 6.11  Wait for PLL to stabilise
63
; 6.12  Initialise Low-Level Library Interface
64
; 6.13  Call C-language main function
65
; 6.14  Shut down library
66
; 6.15  Program end loop
67
; 6.16  Set Flash Security
68
; 6.17  Set Flash write protection
69
; 6.18  Debug address specification
70
;
71
;====================================================================
72
; 2  Disclaimer
73
;====================================================================
74
;                  FUJITSU MICROELECTRONICS EUROPE GMBH
75
;                  Pittlerstrasse 47, 63225 Langen, Germany
76
;                  Tel.:++49 6103 690-0, Fax -122
77
;
78
;    The following software is for demonstration purposes only.
79
;    It is not fully tested, nor validated in order to fulfil
80
;    its task under all circumstances. Therefore, this software
81
;    or any part of it must only be used in an evaluation
82
;    laboratory environment.
83
;    This software is subject to the rules of our standard
84
;    DISCLAIMER, that is delivered with our SW-tools on the
85
;    Fujitsu Microcontrollers CD (V3.4 or higher "\START.HTM") or
86
;    on our Internet Pages:
87
;    http://www.fme.gsdc.de/gsdc.htm
88
;    http://emea.fujitsu.com/microelectronics
89
;
90
;====================================================================
91
; 3  History
92
;====================================================================
93
; $Id: START.ASM 2 2011-07-17 20:13:17Z filepang@gmail.com $
94
 
95
 
96
#define VERSION  "1.25"
97
/*
98
$Log: START.ASM,v $
99
Revision 1.25  2007/09/28 07:33:18  mcuae
100
Bug in BDM baudrate calculation corrected
101
 
102
Revision 1.24  2007/09/26 14:03:08  mcuae
103
- Device list for MB96340 series updated and expanded
104
 
105
Revision 1.23  2007/08/06 14:48:16  mcuae
106
- BDM section always reserved, filled with 0xFF, if not configured
107
 
108
Revision 1.22  2007/08/02 08:34:03  mcuae
109
- communication mode bits of BDM configuration grouped
110
 
111
Revision 1.21  2007/07/13 08:23:05  mwilla
112
device selection for BDM baud rate improved
113
 
114
Revision 1.20  2007/06/12 10:43:57  mwilla
115
- BDM-Baud-Rate calculation includes crystal frequency
116
 
117
Revision 1.19  2007/06/06 07:46:55  mwilla
118
- add Background Debugging Configuration
119
- Stack initialization moved before variable initialization
120
- values of cystal frequency and device macros changed
121
 
122
Revision 1.18  2007/04/16 07:56:02  phuene
123
- update clock settings when crystal is 8 MHz so that the CLKVCO is low
124
 
125
Revision 1.17  2007/04/10 11:30:43  phuene
126
- add MB96320 Series
127
- Clock settings optimized for CPU_8MHZ_CLKP2_8MHZ, CPU_12MHZ_CLKP2_12MHZ, CPU_16MHZ_CLKP2_16MHZ, CPU_24MHZ_CLKP2_24MHZ, CPU_32MHZ_CLKP2_32MHZ
128
- make the selection for the individual devices also consider the selected Series
129
- support 8 MHz crystal
130
- add clock setting CPU_32MHZ_CLKP1_16MHZ_CLKP2_16MHZ
131
- prohibit CPU_32MHZ_CLKP2_16MHZ, CPU_CLKP1_16MHZ_CLKP2_16MHZ for MB96F348H and MB96F348T according to functional limitation 16FXFL0014
132
 
133
Revision 1.16  2007/02/07 12:38:10  phuene
134
- support disabling the UART scanning in Internal Vector Mode
135
- distinguish between Reset Vector and Boot Vector: the Boot Vector points to the start of the user application
136
 
137
Revision 1.15  2007/02/07 09:00:19  phuene
138
- add .SKIP instructions to occupy the whole ROM configuration block area
139
 
140
Revision 1.14  2007/01/29 13:15:06  phuene
141
- fix CPU_4MHZ_MAIN_CLKP2_4MHZ clock setting
142
 
143
Revision 1.13  2007/01/03 10:40:14  phuene
144
- change clock setting CPU_24MHZ_CLKP2_16MHZ to CPU_24MHZ_CLKP2_12MHZ; this allows for better performance of MB96F348H/T
145
- use additional preprocessor statements to avoid checking for PLL ready twice in some cases
146
 
147
Revision 1.12  2007/01/02 10:16:20  phuene
148
- correct CLKP2 (CAN) clock for CPU_32MHZ and MB96F348H/T
149
- correct CLKP2 (CAN) clock for CPU_24MHZ for all other devices than MB96F348H/T
150
 
151
Revision 1.11  2006/12/28 10:49:52  phuene
152
- corrected PLL setting for CPU_16MHZ for MB96348H, MB96348T
153
 
154
Revision 1.10  2006/12/28 08:41:57  phuene
155
- correct revision number at new location
156
 
157
Revision 1.1  2006/12/28 07:20:01  phuene
158
- new location in CVS
159
 
160
Revision 1.9  2006/12/27 13:00:45  phuene
161
- add support for ROM Mirror when using the Simulator
162
- add support for 16FXFL0022, 16FXFL0023
163
 
164
Revision 1.8  2006/12/11 16:43:37  phuene
165
- fix typo
166
 
167
Revision 1.7  2006/12/11 16:35:08  phuene
168
- add setting for Clock Stabilization Times
169
- modify clock settings:
170
  - CLKP2 < 28 MHz
171
  - remove clock settings using more wait cycles than absolutely required
172
 
173
Revision 1.6  2006/11/03 13:38:45  phuene
174
- modify clock settings to also set the Flash Memory Timing
175
- add support for both parameter passing models
176
 
177
Revision 1.5  2006/08/07 14:01:44  phuene
178
- change default clock setting to PLLx4 for CLKS1, CLKS2
179
- correct clock setting
180
- disable Flash Security by default for Main Flash, Satellite Flash
181
- disable availability of Satellite Flash by default
182
 
183
Revision 0.1  2006/01/25 15:37:46  phu
184
- initial version based on start.asm for MB90340 Series, version 3.8
185
Revision 0.2  2006/07/14 15:37:46  phu
186
- include PIER settings for External Bus operation
187
Revision 0.3  2006/07/14 15:37:46  phu
188
- add MB96350 Series
189
- correct PIER settings for HRQ and RDY signals
190
Revision 0.4  2006/08/07 15:35:35  phu
191
- change default clock setting to PLLx4 for CLKS1, CLKS2
192
- correct clock setting
193
- disable Flash Security by default for Main Flash, Satellite Flash
194
- disable availability of Satellite Flash by default
195
*/
196
;====================================================================
197
 
198
;====================================================================
199
; 4  Settings
200
;====================================================================
201
;
202
; CHECK ALL OPTIONS WHETHER THEY FIT TO THE APPLICATION
203
;
204
; Configure this startup file in the "Settings" section. Search for
205
; comments with leading "; <<<". This points to the items to be set.
206
;====================================================================
207
#set      OFF       0
208
#set      ON        1
209
 
210
;====================================================================
211
; 4.1  Controller Series, Device
212
;====================================================================
213
 
214
#set      MB96320   0
215
#set      MB96340   1
216
#set      MB96350   2
217
#set      MB96360   3
218
#set      MB96380   4
219
 
220
#set      SERIES    MB96340        ; <<< select Series
221
 
222
 
223
; Only if SERIES = MB96340 was selected, please specify the device
224
; according to the following selection
225
; Note: Do not change order because of device number dependency in
226
; 6.5 Clock settings and 6.18 Debug address specification!
227
#set      MB96348HA  1
228
#set      MB96348TA  2
229
#set      MB96346RA  3
230
#set      MB96346YA  4
231
#set      MB96346AA  5
232
#set      MB96347RA  6
233
#set      MB96347YA  7
234
#set      MB96347AA  8
235
#set      MB96348RA  9
236
#set      MB96348YA  10
237
#set      MB96348AA  11
238
#set      MB96346RB  12
239
#set      MB96346AB  13
240
#set      MB96346YB  14
241
#set      MB96347RB  15
242
#set      MB96347AB  16
243
#set      MB96347YB  17
244
#set      MB96348CA  18
245
#set      MB96348HB  19
246
#set      MB96348TB  20
247
#set      MB96348RB  21
248
#set      MB96348AB  22
249
#set      MB96348YB  23
250
#set      MB96348CC  24
251
#set      MB96348HC  25
252
#set      MB96348TC  26
253
 
254
#set      DEVICE    MB96348HB      ; <<< select device if Series = MB96340
255
 
256
;====================================================================
257
; 4.2  C-language Memory model
258
;====================================================================
259
 
260
                                   ;      data      code
261
#set      SMALL     0              ;     16 Bit    16 Bit
262
#set      MEDIUM    1              ;     16 Bit    24 Bit
263
#set      COMPACT   2              ;     24 Bit    16 Bit
264
#set      LARGE     3              ;     24 Bit    24 Bit
265
#set      AUTOMODEL 4              ; works always, might occupy two
266
                                   ; additional bytes
267
 
268
 
269
#set      MEMMODEL  AUTOMODEL      ; <<< C-memory model
270
 
271
; The selected memory model should be set in order to fit to the
272
; model selected for the compiler.
273
; Note, in this startup version AUTOMODEL will work for all
274
; C-models. However, if the compiler is configured for SMALL or
275
; COMPACT, two additional bytes on stack are occupied. If this is not
276
; acceptable, the above setting should be set to the correct model.
277
 
278
;====================================================================
279
; 4.3  Function-Call Interface
280
;====================================================================
281
          #if __REG_PASS__
282
            .REG_PASS
283
          #endif
284
 
285
; Above statement informs Assembler on compatibility of start-up code
286
; to  Function Call Interface  as selected for the application. There
287
; is nothing to configure.
288
; The Function-Call Interface specifies the method of passing parame-
289
; ter from function caller to callee.  The standard method of FCC907S
290
; compiler  uses  "stack argument passing".  Alternatively,  language
291
; tools can be configured for "register argument passing".
292
; For details see the compiler manual.
293
; This start-up file is compatible to both interfaces.
294
 
295
;====================================================================
296
; 4.4  Constant Data Handling
297
;====================================================================
298
 
299
#set      ROMCONST    0            ; works only with compiler ROMCONST
300
#set      RAMCONST    1            ; works with BOTH compiler settings
301
#set      AUTOCONST   RAMCONST     ; works with BOTH compiler settings
302
 
303
#set      CONSTDATA   AUTOCONST    ; <<< set RAM/ROM/AUTOCONST
304
 
305
; - AUTOCONST (default) is the same as RAMCONST
306
; - RAMCONST/AUTOCONST should always work, even if compiler is set to
307
;   ROMCONST. If compiler is set to ROMCONST and this startup file is
308
;   set to RAMCONST or AUTOCONST, this startup file will generate an
309
;   empty section CINIT in RAM. However, the code, which copies from
310
;   CONST to CINIT will not have any effect, because size of section is 0.
311
; - It is highly recommended to set the compiler to ROMCONST for
312
;   single-chip mode or internal ROM+ext bus. The start-up file
313
;   should be set to AUTOCONST.
314
; - ROMCONST setting on systems with full external bus requires exter-
315
;   nal address mapping.
316
;   Single-chip can be emulated by the emulator debugger.
317
;   ROM mirror can also be used with simulator.
318
;
319
; see also ROM MIRROR options
320
 
321
;====================================================================
322
; 4.5  Stack Type and Stack Size
323
;====================================================================
324
 
325
#set      USRSTACK      0       ; user stack: for main program
326
#set      SYSSTACK      1       ; system stack: for main program and interrupts
327
 
328
#set      STACKUSE  SYSSTACK    ; <<< set active stack
329
 
330
#set      STACK_RESERVE  ON     ; <<< reserve stack area in this module
331
#set      STACK_SYS_SIZE 1500   ; <<< byte size of System stack
332
#set      STACK_USR_SIZE 2      ; <<< byte size of User stack
333
 
334
#set      STACK_FILL    ON      ; <<< fills the stack area with pattern
335
#set      STACK_PATTERN 0x55AA  ; <<< the pattern to write to stack
336
 
337
; - If the active stack is set to SYSSTACK, it is used for main program
338
;   and interrupts. In this case, the user stack can be set to a dummy
339
;   size.
340
;   If the active stack is set to user stack, it is used for the main
341
;   program but the system stack is automatically activated, if an inter-
342
;   rupt is serviced. Both stack areas must have a reasonable size.
343
; - If STACK_RESERVE is ON, the sections USTACK and SSTACK are reserved
344
;   in this module. Otherwise, they have to be reserved in other modules.
345
;   If STACK_RESERVE is OFF, the size definitions STACK_SYS_SIZE and
346
;   STACK_USR_SIZE have no meaning.
347
; - Even if they are reserved in other modules, they are still initialised
348
;   in this start-up file.
349
; - Filling the stack with a pattern allows to dynamically check the stack
350
;   area, which had already been used.
351
;
352
; - If only system stack is used and SSB is linked to a different bank
353
;   than USB, make sure that all C-modules (which generate far pointers
354
;   to stack data) have "#pragma SSB". Applies only to exclusive confi-
355
;   gurations.
356
; - Note, several library functions require quite a big stack (due to
357
;   ANSI). Check the stack information files (*.stk) in the LIB\907
358
;   directory.
359
 
360
;====================================================================
361
; 4.6  General Register Bank
362
;====================================================================
363
 
364
#set      REGBANK   0           ; <<< set default register bank
365
 
366
; set the General Register Bank that is to be used after startup.
367
; Usually, this is bank 0, which applies to address H'180..H'18F. Set
368
; in the range from 0 to 31.
369
; Note: All used register banks have to be reserved (linker options).
370
 
371
#if REGBANK > 31 || REGBANK < 0
372
#  error REGBANK setting out of range
373
#endif
374
 
375
;====================================================================
376
; 4.7  Low-Level Library Interface
377
;====================================================================
378
 
379
#set      CLIBINIT  OFF         ; <<< select extended library usage
380
 
381
; This option has only to be set, if stream-IO/standard-IO function of
382
; the C-library have to be used (printf(), fopen()...). This also
383
; requires low-level functions to be defined by the application
384
; software.
385
; For other library functions (like e.g. sprintf()) all this is not
386
; necessary. However, several functions consume a large amount of stack.
387
 
388
;====================================================================
389
; 4.8  Clock Selection
390
;====================================================================
391
 
392
; The clock selection requires that a 4 MHz external clock is provided
393
; as the Main Clock. If a different frequency is used, the Flash Memory
394
; Timing settings must be checked!
395
 
396
#set      CLOCKWAIT      ON     ; <<< wait for stabilized clock, if
397
                                ;     Main Clock or PLL is used
398
 
399
; The clock is set quite early. However, if CLOCKWAIT is ON, polling
400
; for machine clock to be switched to Main Clock or PLL is done at
401
; the end of this file. Therefore, the stabilization time is not
402
; wasted. Main() will finally start at correct speed. Resources can
403
; be used immediately.
404
; Note: Some frequency settings (below) necessarily need a stabilized
405
; PLL for final settings. In these cases, the CLOCKWAIT setting above
406
; does not have any effect.
407
;
408
; This startup file version does not support subclock.
409
 
410
#set      FREQ_4MHZ       D'4000000L
411
#set      FREQ_8MHZ       D'8000000L
412
 
413
#set      CRYSTAL         FREQ_4MHZ  ; <<< select external crystal frequency
414
 
415
#set      CPU_4MHZ_MAIN_CLKP2_4MHZ            0x0004
416
#set      CPU_4MHZ_PLL_CLKP2_4MHZ             0x0104
417
#set      CPU_8MHZ_CLKP2_8MHZ                 0x0108
418
#set      CPU_12MHZ_CLKP2_12MHZ               0x010C
419
#set      CPU_16MHZ_CLKP2_16MHZ               0x0110
420
#set      CPU_24MHZ_CLKP2_12MHZ               0x0118
421
#set      CPU_32MHZ_CLKP2_16MHZ               0x0120
422
#set      CPU_32MHZ_CLKP1_16MHZ_CLKP2_16MHZ   0x0220
423
#set      CPU_48MHZ_CLKP2_16MHZ               0x0130
424
#set      CPU_56MHZ_CLKP2_14MHZ               0x0138
425
 
426
#set      CLOCK_SPEED     CPU_56MHZ_CLKP2_14MHZ              ; <<< set clock speeds
427
 
428
; The peripheral clock CLKP1 is set to the same frequency than the CPU.
429
; The peripheral clock CLKP2 has its setting. This is because it
430
; feeds only the CAN controllers and Sound Generators. These do not
431
; need high frequency clocks.
432
 
433
;====================================================================
434
; 4.9  Clock Stabilization Time
435
;====================================================================
436
 
437
#set      MC_2_10_CYCLES   0
438
#set      MC_2_12_CYCLES   1
439
#set      MC_2_13_CYCLES   2
440
#set      MC_2_14_CYCLES   3
441
#set      MC_2_15_CYCLES   4
442
#set      MC_2_16_CYCLES   5
443
#set      MC_2_17_CYCLES   6
444
#set      MC_2_18_CYCLES   7
445
 
446
#set      MC_STAB_TIME    MC_2_15_CYCLES  ; <<< select Main Clock Stabilization Time
447
 
448
;====================================================================
449
; 4.10 External Bus Interface
450
;====================================================================
451
 
452
#set      SINGLE_CHIP    0         ; all internal
453
#set      INTROM_EXTBUS  1         ; mask ROM or FLASH memory used
454
#set      EXTROM_EXTBUS  2         ; full external bus (INROM not used)
455
 
456
#set      BUSMODE SINGLE_CHIP      ; <<< set bus mode (see mode pins)
457
 
458
#set      MULTIPLEXED     0        ;
459
#set      NON_MULTIPLEXED 1        ; only if supported by the device
460
 
461
#set      ADDRESSMODE MULTIPLEXED  ; <<< set address-mode
462
 
463
; Some devices support multiplexed and/or non-multiplexed Bus mode
464
; please refer to the related datasheet/hardwaremanual
465
 
466
 
467
; If BUSMODE is "SINGLE_CHIP", ignore remaining bus settings.
468
 
469
; Select the used Chip Select areas
470
#set      CHIP_SELECT0    OFF      ; <<< enable chip select area
471
#set      CHIP_SELECT1    OFF      ; <<< enable chip select area
472
#set      CHIP_SELECT2    OFF      ; <<< enable chip select area
473
#set      CHIP_SELECT3    OFF      ; <<< enable chip select area
474
#set      CHIP_SELECT4    OFF      ; <<< enable chip select area
475
#set      CHIP_SELECT5    OFF      ; <<< enable chip select area
476
 
477
#set      HOLD_REQ           OFF   ; <<< select Hold function
478
#set      EXT_READY          OFF   ; <<< select external Ready function
479
#set      EXT_CLOCK_ENABLE   OFF   ; <<< select external bus clock output
480
#set      EXT_CLOCK_INVERT   OFF   ; <<< select clock inversion
481
#set      EXT_CLOCK_SUSPEND  OFF   ; <<< select if external clock is suspended when no transfer in progress
482
 
483
; The external bus clock is derived from core clock CLKB. Select the divider for the external bus clock.
484
 
485
#set      EXT_CLOCK_DIV1     0
486
#set      EXT_CLOCK_DIV2     1
487
#set      EXT_CLOCK_DIV4     2
488
#set      EXT_CLOCK_DIV8     3
489
#set      EXT_CLOCK_DIV16    4
490
#set      EXT_CLOCK_DIV32    5
491
#set      EXT_CLOCK_DIV64    6
492
#set      EXT_CLOCK_DIV128   7
493
 
494
#set      EXT_CLOCK_DIVISION  EXT_CLOCK_DIV1 ; <<< select clock divider
495
 
496
#set      ADDR_PINS_23_16    B'00000000     ; <<< select used address lines
497
                                            ;     A23..A16 to be output.
498
#set      ADDR_PINS_15_8     B'00000000     ; <<< select used address lines
499
                                            ;     A15..A8 to be output.
500
#set      ADDR_PINS_7_0      B'00000000     ; <<< select used address lines
501
                                            ;     A7..A0 to be output.
502
 
503
#set      LOW_BYTE_SIGNAL    OFF   ; select low byte signal LBX
504
#set      HIGH_BYTE_SIGNAL   OFF   ; select high byte signal UBX
505
#set      LOW_WRITE_STROBE   OFF   ; select write strobe signal WRLX/WRX
506
#set      HIGH_WRITE_STROBE  OFF   ; select write strobe signal WRHX
507
#set      READ_STROBE        OFF   ; select read strobe signal RDX
508
#set      ADDRESS_STROBE     OFF   ; select address strobe signal ALE/ASX
509
#set      ADDRESS_STROBE_LVL OFF   ; select address strobe function: OFF - active low; ON - active high
510
 
511
 
512
#set      CS0_CONFIG  B'0000000000000000    ; <<< select Chip Select Area 0 configuration
513
;                       |||||||||||||+++-- Automatic wait cycles (0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 8, 6: 16, 7: 32)
514
;                       ||||||||||||+----- Address Cycle Extension (0: not extended, 1: extension by 1 cycle)
515
;                       |||||||||||+------ Strobe timing (0: scheme 0, 1: scheme 1)
516
;                       ||||||||||+------- Write strobe function (0: WRLX strobe, 1: WRX strobe)
517
;                       |||||||||+-------- Endianess (0: little endian, 1: big endian)
518
;                       ||||||||+--------- Bus width (0: 16bit, 1: 8bit)
519
;                       |||||+++---------- ignored
520
;                       ||||+------------- Chip Select output enable (0: CS disabled, 1: CS enabled)
521
;                       |||+-------------- Chip Select level (0: low active, 1: high active)
522
;                       ||+--------------- Access type limitation (0: code and data, 1: data only)
523
;                       ++---------------- ignored
524
 
525
#set      CS1_CONFIG  B'0000000000000000    ; <<< select Chip Select Area 1 configuration
526
;                       |||||||||||||+++-- Automatic wait cycles (0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 8, 6: 16, 7: 32)
527
;                       ||||||||||||+----- Address Cycle Extension (0: not extended, 1: extension by 1 cycle)
528
;                       |||||||||||+------ Strobe timing (0: scheme 0, 1: scheme 1)
529
;                       ||||||||||+------- Write strobe function (0: WRLX strobe, 1: WRX strobe)
530
;                       |||||||||+-------- Endianess (0: little endian, 1: big endian)
531
;                       ||||||||+--------- Bus width (0: 16bit, 1: 8bit)
532
;                       |||||+++---------- ignored
533
;                       ||||+------------- Chip Select output enable (0: CS disabled, 1: CS enabled)
534
;                       |||+-------------- Chip Select level (0: low active, 1: high active)
535
;                       ||+--------------- Access type limitation (0: code and data, 1: data only)
536
;                       ++---------------- ignored
537
 
538
#set      CS2_CONFIG  B'0000011000000000    ; <<< select Chip Select Area 2 configuration
539
;                       |||||||||||||+++-- Automatic wait cycles (0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 8, 6: 16, 7: 32)
540
;                       ||||||||||||+----- Address Cycle Extension (0: not extended, 1: extension by 1 cycle)
541
;                       |||||||||||+------ Strobe timing (0: scheme 0, 1: scheme 1)
542
;                       ||||||||||+------- Write strobe function (0: WRLX strobe, 1: WRX strobe)
543
;                       |||||||||+-------- Endianess (0: little endian, 1: big endian)
544
;                       ||||||||+--------- Bus width (0: 16bit, 1: 8bit)
545
;                       |||||+++---------- External area size (0: 64kB, 1: 128kB, 2: 256kB, 3: 512kB, 4: 1MB, 5: 2MB, 6: 4MB, 7: 8MB)
546
;                       ||||+------------- Chip Select output enable (0: CS disabled, 1: CS enabled)
547
;                       |||+-------------- Chip Select level (0: low active, 1: high active)
548
;                       ||+--------------- Access type limitation (0: code and data, 1: data only)
549
;                       ++---------------- ignored
550
 
551
#set      CS3_CONFIG  B'0000011000000000    ; <<< select Chip Select Area 3 configuration
552
;                       |||||||||||||+++-- Automatic wait cycles (0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 8, 6: 16, 7: 32)
553
;                       ||||||||||||+----- Address Cycle Extension (0: not extended, 1: extension by 1 cycle)
554
;                       |||||||||||+------ Strobe timing (0: scheme 0, 1: scheme 1)
555
;                       ||||||||||+------- Write strobe function (0: WRLX strobe, 1: WRX strobe)
556
;                       |||||||||+-------- Endianess (0: little endian, 1: big endian)
557
;                       ||||||||+--------- Bus width (0: 16bit, 1: 8bit)
558
;                       |||||+++---------- External area size (0: 64kB, 1: 128kB, 2: 256kB, 3: 512kB, 4: 1MB, 5: 2MB, 6: 4MB, 7: 8MB)
559
;                       ||||+------------- Chip Select output enable (0: CS disabled, 1: CS enabled)
560
;                       |||+-------------- Chip Select level (0: low active, 1: high active)
561
;                       ||+--------------- Access type limitation (0: code and data, 1: data only)
562
;                       ++---------------- ignored
563
 
564
#set      CS4_CONFIG  B'0000011000000000    ; <<< select Chip Select Area 4 configuration
565
;                       |||||||||||||+++-- Automatic wait cycles (0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 8, 6: 16, 7: 32)
566
;                       ||||||||||||+----- Address Cycle Extension (0: not extended, 1: extension by 1 cycle)
567
;                       |||||||||||+------ Strobe timing (0: scheme 0, 1: scheme 1)
568
;                       ||||||||||+------- Write strobe function (0: WRLX strobe, 1: WRX strobe)
569
;                       |||||||||+-------- Endianess (0: little endian, 1: big endian)
570
;                       ||||||||+--------- Bus width (0: 16bit, 1: 8bit)
571
;                       |||||+++---------- External area size (0: 64kB, 1: 128kB, 2: 256kB, 3: 512kB, 4: 1MB, 5: 2MB, 6: 4MB, 7: 8MB)
572
;                       ||||+------------- Chip Select output enable (0: CS disabled, 1: CS enabled)
573
;                       |||+-------------- Chip Select level (0: low active, 1: high active)
574
;                       ||+--------------- Access type limitation (0: code and data, 1: data only)
575
;                       ++---------------- ignored
576
 
577
#set      CS5_CONFIG  B'0000011000000000    ; <<< select Chip Select Area 5 configuration
578
;                       |||||||||||||+++-- Automatic wait cycles (0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 8, 6: 16, 7: 32)
579
;                       ||||||||||||+----- Address Cycle Extension (0: not extended, 1: extension by 1 cycle)
580
;                       |||||||||||+------ Strobe timing (0: scheme 0, 1: scheme 1)
581
;                       ||||||||||+------- Write strobe function (0: WRLX strobe, 1: WRX strobe)
582
;                       |||||||||+-------- Endianess (0: little endian, 1: big endian)
583
;                       ||||||||+--------- Bus width (0: 16bit, 1: 8bit)
584
;                       |||||+++---------- External area size (0: 64kB, 1: 128kB, 2: 256kB, 3: 512kB, 4: 1MB, 5: 2MB, 6: 4MB, 7: 8MB)
585
;                       ||||+------------- Chip Select output enable (0: CS disabled, 1: CS enabled)
586
;                       |||+-------------- Chip Select level (0: low active, 1: high active)
587
;                       ||+--------------- Access type limitation (0: code and data, 1: data only)
588
;                       ++---------------- ignored
589
 
590
 
591
#set      CS2_START  0x00       ; select start bank of chip select area; valid values: 0x00..0xFF
592
#set      CS3_START  0x40       ; select start bank of chip select area; valid values: 0x00..0xFF
593
#set      CS4_START  0x80       ; select start bank of chip select area; valid values: 0x00..0xFF
594
#set      CS5_START  0xC0       ; select start bank of chip select area; valid values: 0x00..0xFF
595
 
596
 
597
;====================================================================
598
; 4.11 ROM Mirror configuration
599
;====================================================================
600
 
601
#set      MIRROR_8KB    0
602
#set      MIRROR_16KB   1
603
#set      MIRROR_24KB   2
604
#set      MIRROR_32KB   3
605
 
606
#set      ROMMIRROR     ON          ; <<< ROM mirror function ON/OFF
607
#set      MIRROR_BANK   0xF         ; <<< ROM Mirror bank, allowed entries: 0x0..0xF for the banks 0xF0..0xFF
608
#set      MIRROR_SIZE   MIRROR_32KB ; <<< ROM Mirror size
609
 
610
; One can select which ROM area to mirror into the upper half of bank 00.
611
; If ROMMIRROR = OFF is selected, the address range 0x008000..0x00FFFF
612
; shows the contents of the respective area of bank 1: 0x018000..0x01FFFF.
613
; If ROMMIRROR = ON is selected, the memory bank to mirror can be selected.
614
; Available banks are 0xF0 to 0xFF. Furthermore, the ROM Mirror area size can
615
; be selected. 4 sizes are available: 8 kB, 16 kB, 24 kB, or 32 kB. The ROM Mirror
616
; from the highest address of the selected bank downwards, e.g. if bank 0xFF and
617
; mirror size 24 kB is selected, the memory range 0xFFA000..0xFFFFFF is mirrored
618
; to address range 0x00A000..0x00FFFF. The memory area not selected for
619
; ROM Mirror is still mirrored from bank 0x01.
620
; This is necessary to get the compiler ROMCONST option working. This is intended
621
; to increase performance, if a lot of dynamic data have to be accessed.
622
; In SMALL and MEDIUM model these data can be accessed within bank 0,
623
; which allows to use near addressing. Please make sure to have the linker
624
; setting adjusted accordingly!
625
 
626
 
627
;====================================================================
628
; 4.12 Flash Security
629
;====================================================================
630
 
631
#set      MAIN_SECURITY_ENABLE       OFF ; <<< enable Flash Security for Main Flash
632
#set      SATELLITE_FLASH            OFF ; <<< select if Satellite Flash is available
633
#set      SATELLITE_SECURITY_ENABLE  OFF ; <<< enable Flash Security for Satellite Flash
634
 
635
; set the Flash Security unlock key (16 bytes)
636
; all 0: unlock not possible
637
#set      MAIN_UNLOCK_0              0x00
638
#set      MAIN_UNLOCK_1              0x00
639
#set      MAIN_UNLOCK_2              0x00
640
#set      MAIN_UNLOCK_3              0x00
641
#set      MAIN_UNLOCK_4              0x00
642
#set      MAIN_UNLOCK_5              0x00
643
#set      MAIN_UNLOCK_6              0x00
644
#set      MAIN_UNLOCK_7              0x00
645
#set      MAIN_UNLOCK_8              0x00
646
#set      MAIN_UNLOCK_9              0x00
647
#set      MAIN_UNLOCK_10             0x00
648
#set      MAIN_UNLOCK_11             0x00
649
#set      MAIN_UNLOCK_12             0x00
650
#set      MAIN_UNLOCK_13             0x00
651
#set      MAIN_UNLOCK_14             0x00
652
#set      MAIN_UNLOCK_15             0x00
653
 
654
#set      SATELLITE_UNLOCK_0         0x00
655
#set      SATELLITE_UNLOCK_1         0x00
656
#set      SATELLITE_UNLOCK_2         0x00
657
#set      SATELLITE_UNLOCK_3         0x00
658
#set      SATELLITE_UNLOCK_4         0x00
659
#set      SATELLITE_UNLOCK_5         0x00
660
#set      SATELLITE_UNLOCK_6         0x00
661
#set      SATELLITE_UNLOCK_7         0x00
662
#set      SATELLITE_UNLOCK_8         0x00
663
#set      SATELLITE_UNLOCK_9         0x00
664
#set      SATELLITE_UNLOCK_10        0x00
665
#set      SATELLITE_UNLOCK_11        0x00
666
#set      SATELLITE_UNLOCK_12        0x00
667
#set      SATELLITE_UNLOCK_13        0x00
668
#set      SATELLITE_UNLOCK_14        0x00
669
#set      SATELLITE_UNLOCK_15        0x00
670
 
671
 
672
;====================================================================
673
; 4.13  Flash Write Protection
674
;====================================================================
675
 
676
#set      MAIN_FLASH_WRITE_PROTECT        OFF       ; <<< select Flash write protection
677
#set      PROTECT_SECTOR_SA0              OFF       ; <<< select individual sector to protect
678
#set      PROTECT_SECTOR_SA1              OFF       ; <<< select individual sector to protect
679
#set      PROTECT_SECTOR_SA2              OFF       ; <<< select individual sector to protect
680
#set      PROTECT_SECTOR_SA3              OFF       ; <<< select individual sector to protect
681
#set      PROTECT_SECTOR_SA32             OFF       ; <<< select individual sector to protect
682
#set      PROTECT_SECTOR_SA33             OFF       ; <<< select individual sector to protect
683
#set      PROTECT_SECTOR_SA34             OFF       ; <<< select individual sector to protect
684
#set      PROTECT_SECTOR_SA35             OFF       ; <<< select individual sector to protect
685
#set      PROTECT_SECTOR_SA36             OFF       ; <<< select individual sector to protect
686
#set      PROTECT_SECTOR_SA37             OFF       ; <<< select individual sector to protect
687
#set      PROTECT_SECTOR_SA38             OFF       ; <<< select individual sector to protect
688
#set      PROTECT_SECTOR_SA39             OFF       ; <<< select individual sector to protect
689
 
690
#set      SATELLITE_FLASH_WRITE_PROTECT   OFF       ; <<< select Flash write protection
691
#set      PROTECT_SECTOR_SB0              OFF       ; <<< select individual sector to protect
692
#set      PROTECT_SECTOR_SB1              OFF       ; <<< select individual sector to protect
693
#set      PROTECT_SECTOR_SB2              OFF       ; <<< select individual sector to protect
694
#set      PROTECT_SECTOR_SB3              OFF       ; <<< select individual sector to protect
695
 
696
 
697
;====================================================================
698
; 4.14  Boot Vector
699
;====================================================================
700
 
701
#set      BOOT_VECTOR_TABLE  1              ; enable boot vector
702
#set      BOOT_VECTOR_FIXED  2              ; enable boot vector
703
 
704
#set      BOOT_VECTOR   BOOT_VECTOR_TABLE   ; <<< select type of boot vector
705
 
706
; If boot vector generation is enabled (BOOT_VECTOR_TABLE, BOOT_VECTOR_FIXED),
707
; appropriate code is generated. If it is disabled (OFF), start-up file does
708
; not care about.
709
;
710
;   BOOT_VECTOR_TABLE: - Create table entry at address oxFFFFDC.
711
;                      - Any start address can be set and start-up file will
712
;                        set address of this start code.
713
;   BOOT_VECTOR_FIXED: - Instead of table entry, a special marker is set in
714
;                        ROM Configuration Block, which enables the fixed
715
;                        start address 0xDF0080. This is prefered setting
716
;                        for user boot loaders.
717
;                 OFF: - Do not set table entry and marker. This might be used
718
;                        for application to be loaded by boot loader.
719
;
720
; Note
721
; BOOT_VECTOR_TABLE setting can also be used, if all other interrupt vectors
722
; are specified via "pragma intvect". Only if interrupts 0..7 are specified
723
; via "pragma intvect", these will conflict with the vector in this module.
724
; The reason is the INTVECT section, which includes the whole area from the
725
; lowest to the highest specified vector.
726
 
727
#if BOOT_VECTOR == BOOT_VECTOR_TABLE
728
          .SECTION        RESVECT, CONST, LOCATE=H'FFFFDC
729
          .DATA.E _start
730
          .SECTION        BOOT_SELECT, CONST, LOCATE=H'DF0030
731
          .DATA.L 0xFFFFFFFF
732
 
733
#else
734
#  if BOOT_VECTOR == BOOT_VECTOR_FIXED
735
          .SECTION        BOOT_SELECT, CONST, LOCATE=H'DF0030
736
          .DATA.L 0x292D3A7B        ; Magic Word
737
#  else
738
          .SECTION        BOOT_SELECT, CONST, LOCATE=H'DF0030
739
          .SKIP   4
740
#  endif
741
#endif
742
 
743
;====================================================================
744
; 4.15  UART scanning
745
;====================================================================
746
 
747
#set      UART_SCANNING   OFF        ; <<< enable UART scanning in
748
                                     ;     Internal Vector Mode
749
;
750
; By default, the MCU scans in Internal Vector Mode for a UART
751
; communication after reset. This enables to establish a serial
752
; communication without switching to Serial Communication Mode.
753
; For the final aplpication, sset this switch to OFF to achieve the
754
; fastest start-up time.
755
 
756
#if UART_SCANNING == ON
757
          .SECTION        UART_SCAN_SELECT, CONST, LOCATE=H'DF0034
758
          .DATA.L 0xFFFFFFFF
759
#else
760
          .SECTION        UART_SCAN_SELECT, CONST, LOCATE=H'DF0034
761
          .DATA.L 0x292D3A7B
762
#endif
763
          .SKIP   0x08
764
 
765
 
766
;====================================================================
767
; 4.16  Enable RAMCODE Copying
768
;====================================================================
769
 
770
#set      COPY_RAMCODE      OFF     ; <<< enable RAMCODE section to
771
                                    ; be copied from ROM to RAM
772
 
773
; To get this option properly working the code to be executed has to
774
; be linked to section RAMCODE (e.g. by #pragma section). The section
775
; RAMCODE has be located in RAM and the section @RAMCODE has to be
776
; located at a fixed address in ROM by linker settings.
777
 
778
;====================================================================
779
; 4.17  Enable information stamp in ROM
780
;====================================================================
781
 
782
#set      VERSION_STAMP     OFF     ; <<< enable version number in
783
                                    ; separated section
784
 
785
 
786
#if VERSION_STAMP == ON
787
          .SECTION  VERSIONS, CONST ; change name, if necessary
788
          .SDATA    "Start ", VERSION, "\n\0"
789
#endif
790
 
791
;====================================================================
792
; 4.18  Enable Background Debugging Mode
793
;====================================================================
794
 
795
#set      BACKGROUND_DEBUGGING  ON ; <<< enable Background Debugging
796
                                    ; mode
797
 
798
#if __CONFIG__ == 1
799
        #set      BDM_CONFIGURATION  B'0000000000010001  ; <<< set BDM configuration
800
        ;                                    ||||||||++--- BdmUART
801
        ;                                    ||||||||      (0: A, 1: B, 2: C, 3: D)
802
        ;                                    ||||||++----- BdmSynchMode
803
        ;                                    ||||||        (0: Async., 1: Sync.
804
        ;                                    ||||||        2: BdmKLine, 3: res.)
805
        ;                                    |||||+------- BdmAutoStart
806
        ;                                    ||||+-------- BdmExtBreakpointCfg
807
        ;                                    |||+--------- BdmKeepRClock
808
        ;                                    ||+---------- BdmCaliRClock
809
        ;                                    |+----------- BdmKeepBCD
810
        ;                                    +------------ BdmUserKernel
811
 
812
#elif __CONFIG__ == 2
813
        #set      BDM_CONFIGURATION  B'0000000000010000  ; <<< set BDM configuration
814
        ;                                    ||||||||++--- BdmUART
815
        ;                                    ||||||||      (0: A, 1: B, 2: C, 3: D)
816
        ;                                    ||||||++----- BdmSynchMode
817
        ;                                    ||||||        (0: Async., 1: Sync.
818
        ;                                    ||||||        2: BdmKLine, 3: res.)
819
        ;                                    |||||+------- BdmAutoStart
820
        ;                                    ||||+-------- BdmExtBreakpointCfg
821
        ;                                    |||+--------- BdmKeepRClock
822
        ;                                    ||+---------- BdmCaliRClock
823
        ;                                    |+----------- BdmKeepBCD
824
        ;                                    +------------ BdmUserKernel
825
 
826
#elif __CONFIG__ == 3
827
        #set      BDM_CONFIGURATION  B'0000000000010001  ; <<< set BDM configuration
828
        ;                                    ||||||||++--- BdmUART
829
        ;                                    ||||||||      (0: A, 1: B, 2: C, 3: D)
830
        ;                                    ||||||++----- BdmSynchMode
831
        ;                                    ||||||        (0: Async., 1: Sync.
832
        ;                                    ||||||        2: BdmKLine, 3: res.)
833
        ;                                    |||||+------- BdmAutoStart
834
        ;                                    ||||+-------- BdmExtBreakpointCfg
835
        ;                                    |||+--------- BdmKeepRClock
836
        ;                                    ||+---------- BdmCaliRClock
837
        ;                                    |+----------- BdmKeepBCD
838
        ;                                    +------------ BdmUserKernel
839
 
840
#elif __CONFIG__ == 4
841
        #set      BDM_CONFIGURATION  B'0000000000010000  ; <<< set BDM configuration
842
        ;                                    ||||||||++--- BdmUART
843
        ;                                    ||||||||      (0: A, 1: B, 2: C, 3: D)
844
        ;                                    ||||||++----- BdmSynchMode
845
        ;                                    ||||||        (0: Async., 1: Sync.
846
        ;                                    ||||||        2: BdmKLine, 3: res.)
847
        ;                                    |||||+------- BdmAutoStart
848
        ;                                    ||||+-------- BdmExtBreakpointCfg
849
        ;                                    |||+--------- BdmKeepRClock
850
        ;                                    ||+---------- BdmCaliRClock
851
        ;                                    |+----------- BdmKeepBCD
852
        ;                                    +------------ BdmUserKernel
853
 
854
#else
855
        #error Either of the __USE_COMTEST__ and __USE_TASKLIST__ should be defined
856
 
857
#endif
858
 
859
 
860
#set      BDM_BAUDRATE    115200   ; <<< set Baudrate in Bits/s for BDM
861
 
862
#set      BDM_EXT_CONFIG  0xFFFFFF ; <<< set external Config/Kernel
863
 
864
#set      BDM_WD_PATTERN  0x00     ; <<< set watchdog pattern
865
 
866
#set      BDM_PFCS0       0x0000   ; <<< set default breakpoint
867
#set      BDM_PFCS1       0x0000   ; configurations
868
#set      BDM_PFCS2       0x0000
869
#set      BDM_PFCS3       0x0000
870
 
871
#set      BDM_PFA0        0xFFFFFF ; <<< set address
872
#set      BDM_PFA1        0xFFFFFF ; configurations
873
#set      BDM_PFA2        0xFFFFFF
874
#set      BDM_PFA3        0xFFFFFF
875
#set      BDM_PFA4        0xFFFFFF
876
#set      BDM_PFA5        0xFFFFFF
877
#set      BDM_PFA6        0xFFFFFF
878
#set      BDM_PFA7        0xFFFFFF
879
 
880
#set      BDM_PFD0        0xFFFFFF ; <<< set patch data
881
#set      BDM_PFD1        0xFFFFFF ; configurations
882
#set      BDM_PFD2        0xFFFFFF
883
#set      BDM_PFD3        0xFFFFFF
884
#set      BDM_PFD4        0xFFFFFF
885
#set      BDM_PFD5        0xFFFFFF
886
#set      BDM_PFD6        0xFFFFFF
887
#set      BDM_PFD7        0xFFFFFF
888
 
889
 
890
; <<< END OF SETTINGS >>>
891
 
892
;====================================================================
893
; 5  Section and Data Declaration
894
;====================================================================
895
 
896
;====================================================================
897
; 5.1  Several fixed addresses (fixed for MB963xx controllers)
898
;====================================================================
899
 
900
MFMCS      .EQU      0x03F1          ; Main Flash Memory configuration register
901
MFMTC      .EQU      0x03F2          ; Main Flash Memory timing register
902
SFMCS      .EQU      0x03F5          ; Satellite Flash Memory configuration register
903
SFMTC      .EQU      0x03F6          ; Satellite Flash Memory timing register
904
ROMM       .EQU      0x03AE          ; ROM mirror control register
905
CKSR       .EQU      0x0401          ; Clock select control register
906
CKSSR      .EQU      0x0402          ; Clock stabilization select register
907
CKMR       .EQU      0x0403          ; Clock monitor register
908
CKFCR      .EQU      0x0404          ; Clock frequency control register
909
PLLCR      .EQU      0x0406          ; PLL control register
910
VRCR       .EQU      0x042C          ; Voltage Regulator Control register
911
#if BUSMODE != SINGLE_CHIP           ; only for devices with external bus
912
PIER00     .EQU      0x0444
913
PIER01     .EQU      0x0445
914
PIER02     .EQU      0x0446
915
PIER03     .EQU      0x0447
916
PIER12     .EQU      0x0450
917
EACL0      .EQU      0x06E0
918
EACH0      .EQU      0x06E1
919
EACL1      .EQU      0x06E2
920
EACH1      .EQU      0x06E3
921
EACL2      .EQU      0x06E4
922
EACH2      .EQU      0x06E5
923
EACL3      .EQU      0x06E6
924
EACH3      .EQU      0x06E7
925
EACL4      .EQU      0x06E8
926
EACH4      .EQU      0x06E9
927
EACL5      .EQU      0x06EA
928
EACH5      .EQU      0x06EB
929
EAS2       .EQU      0x06EC
930
EAS3       .EQU      0x06ED
931
EAS4       .EQU      0x06EE
932
EAS5       .EQU      0x06EF
933
EBM        .EQU      0x06F0
934
EBCF       .EQU      0x06F1
935
EBAE0      .EQU      0x06F2
936
EBAE1      .EQU      0x06F3
937
EBAE2      .EQU      0x06F4
938
EBCS       .EQU      0x06F5
939
#endif ; BUSMODE != SINGLE_CHIP
940
 
941
;====================================================================
942
; 5.2  Declaration of __near addressed data sections
943
;====================================================================
944
 
945
; sections to be cleared
946
          .SECTION  DATA,      DATA,   ALIGN=2  ; zero clear area
947
          .SECTION  DATA2,     DATA,   ALIGN=2  ; zero clear area
948
          .SECTION  DIRDATA,   DIR,    ALIGN=2  ; zero clear direct
949
          .SECTION  LIBDATA,   DATA,   ALIGN=2  ; zero clear lib area
950
 
951
; sections to be initialised with start-up values
952
          .SECTION  INIT,      DATA,   ALIGN=2  ; initialised area
953
          .SECTION  INIT2,     DATA,   ALIGN=2  ; initialised area
954
          .SECTION  DIRINIT,   DIR,    ALIGN=2  ; initialised dir
955
          .SECTION  LIBINIT,   DATA,   ALIGN=2  ; initialised lib area
956
#if CONSTDATA == RAMCONST
957
          .SECTION  CINIT,     DATA,   ALIGN=2  ; initialised const
958
          .SECTION  CINIT2,    DATA,   ALIGN=2  ; initialised const
959
#endif
960
 
961
; sections containing start-up values for initialised sections above
962
          .SECTION  DCONST,    CONST,  ALIGN=2  ; DINIT initialisers
963
          .SECTION  DIRCONST, DIRCONST,ALIGN=2  ; DIRINIT initialisers
964
          .SECTION  LIBDCONST, CONST,  ALIGN=2  ; LIBDCONST init val
965
 
966
          ; following section is either copied to CINIT (RAMCONST) or
967
          ; mapped by ROM-mirror function (ROMCONST)
968
          .SECTION  CONST,     CONST,  ALIGN=2  ; CINIT initialisers
969
          .SECTION  CONST2,    CONST,  ALIGN=2  ; CINIT initialisers
970
 
971
;====================================================================
972
; 5.3  Declaration of RAMCODE section and labels
973
;====================================================================
974
 
975
#if COPY_RAMCODE == ON
976
          .SECTION  RAMCODE,   CODE,  ALIGN=1
977
          .IMPORT _RAM_RAMCODE                  ; provided by linker
978
          .IMPORT _ROM_RAMCODE                  ; provided by linker
979
#endif
980
 
981
 
982
;====================================================================
983
; 5.4  Declaration of sections containing other sections description
984
;====================================================================
985
 
986
; DCLEAR contains start address and size of all sections to be cleared
987
; DTRANS contains source and destination address and size of all
988
; sections to be initialised with start-up values
989
; The compiler automatically adds a descriptor for each __far addressed
990
; data section to DCLEAR or DTRANS. These __far sections are separated
991
; for each C-module.
992
 
993
; In addition the start-up file adds the descriptors of the previously
994
; declared __near section here. This way the same code in the start-up
995
; file can be used for initialising all sections.
996
 
997
   .SECTION  DCLEAR,    CONST,  ALIGN=2  ; zero clear table
998
   ;    Address         Bank            Size
999
   .DATA.H DATA,    BNKSEC DATA,    SIZEOF(DATA   )
1000
   .DATA.H DIRDATA, BNKSEC DIRDATA, SIZEOF(DIRDATA)
1001
   .DATA.H LIBDATA, BNKSEC LIBDATA, SIZEOF(LIBDATA)
1002
 
1003
   .SECTION  DTRANS,    CONST,  ALIGN=2  ; copy table
1004
   ;    Address         Bank               Address     Bank          Size
1005
   .DATA.H DCONST,   BNKSEC DCONST,   INIT,   BNKSEC INIT,   SIZEOF INIT
1006
   .DATA.H DIRCONST, BNKSEC DIRCONST, DIRINIT,BNKSEC DIRINIT,SIZEOF DIRINIT
1007
   .DATA.H LIBDCONST,BNKSEC LIBDCONST,LIBINIT,BNKSEC LIBINIT,SIZEOF LIBINIT
1008
 
1009
#if CONSTDATA == RAMCONST
1010
   .DATA.H CONST,    BNKSEC CONST,    CINIT,  BNKSEC CINIT,  SIZEOF CINIT
1011
   .DATA.H CONST2,   BNKSEC CONST,    CINIT2, BNKSEC CINIT2, SIZEOF CINIT2
1012
#endif
1013
 
1014
#if COPY_RAMCODE == ON
1015
   .DATA.L _ROM_RAMCODE, _RAM_RAMCODE
1016
   .DATA.H SIZEOF RAMCODE
1017
#endif
1018
 
1019
;====================================================================
1020
; 5.5  Stack area and stack top definition/declaration
1021
;====================================================================
1022
#if STACK_RESERVE == ON
1023
            .SECTION  SSTACK, STACK, ALIGN=2
1024
 
1025
            .EXPORT __systemstack, __systemstack_top
1026
__systemstack:
1027
            .RES.B    (STACK_SYS_SIZE + 1) & 0xFFFE
1028
__systemstack_top:
1029
SSTACK_TOP:
1030
 
1031
            .SECTION  USTACK, STACK, ALIGN=2
1032
 
1033
            .EXPORT __userstack, __userstack_top
1034
__userstack:
1035
            .RES.B    (STACK_USR_SIZE + 1) & 0xFFFE
1036
__userstack_top:
1037
USTACK_TOP:
1038
 
1039
#else
1040
            .SECTION  SSTACK, STACK, ALIGN=2
1041
            .SECTION  USTACK, STACK, ALIGN=2
1042
 
1043
            .IMPORT __systemstack, __systemstack_top
1044
            .IMPORT __userstack, __userstack_top
1045
#endif
1046
 
1047
;====================================================================
1048
; 5.6  Direct page register dummy label definition
1049
;====================================================================
1050
 
1051
          .SECTION  DIRDATA  ; zero clear direct
1052
DIRDATA_S:                                      ; label for DPR init
1053
 
1054
; This label is used to get the page of the __direct data.
1055
; Depending on the linkage order of this startup file the label is
1056
; placed anywhere within the __direct data page. However, the
1057
; statement "PAGE (DIRDATA_S)" is processed. Therefore, the lower
1058
; 8 Bit of the address of DIRDATA_S are not relevant and this feature
1059
; becomes linkage order independent.
1060
; Note, the linker settings have to make sure that all __direct
1061
; data are located within the same physical page (256 Byte block).
1062
 
1063
;====================================================================
1064
; 6  Start-Up Code
1065
;====================================================================
1066
 
1067
;====================================================================
1068
; 6.1  Import external symbols
1069
;====================================================================
1070
 
1071
          .IMPORT   _main                    ; user code entrance
1072
#if CLIBINIT == ON
1073
          .IMPORT   __stream_init
1074
          .IMPORT   _exit
1075
          .EXPORT   __exit
1076
#endif
1077
          .EXPORT   _start
1078
 
1079
;====================================================================
1080
;   ___  _____   __    ___  _____
1081
;  /       |    /  \  |   \   |
1082
;  \___    |   |    | |___/   |
1083
;      \   |   |----| |  \    |
1084
;   ___/   |   |    | |   \   |      Begin of actual code section
1085
;====================================================================
1086
          .SECTION  CODE_START, CODE, ALIGN=1
1087
 
1088
;====================================================================
1089
; 6.2  Program start (the reset vector should point here)
1090
;====================================================================
1091
_start:
1092
          NOP  ; This NOP is only for debugging. On debugger the IP
1093
               ; (instruction pointer) should point here after reset
1094
 
1095
;====================================================================
1096
; 6.3  "NOT RESET YET" WARNING
1097
;====================================================================
1098
notresetyet:
1099
          NOP  ; read hint below!!!!!!!
1100
; If the debugger stays at this NOP after download, the controller has
1101
; not been reset yet. In order to reset all hardware registers it is
1102
; highly recommended to reset the controller.
1103
; However, if no reset vector has been defined on purpose, this start
1104
; address can also be used.
1105
; This mechanism is using the .END instruction at the end of this mo-
1106
; dule. It is not necessary for controller operation but improves
1107
; security during debugging (mainly emulator debugger).
1108
; If the debugger stays here after a single step from label "_start"
1109
; to label "notresetyet", this note can be ignored.
1110
 
1111
;====================================================================
1112
; 6.4  Initialisation of processor status
1113
;====================================================================
1114
          AND  CCR, #0x80          ; disable interrupts
1115
          MOV  ILM,#7              ; set interrupt level mask to ALL
1116
          MOV  RP,#REGBANK         ; set register bank pointer
1117
 
1118
;====================================================================
1119
; 6.5  Set clock ratio (ignore subclock)
1120
;====================================================================
1121
          MOVN A, #0               ; set bank 0 in DTB for the case that
1122
          MOV  DTB, A              ; start-up code was not jumped by reset
1123
 
1124
          MOV  CKSSR, #(0xF8 | MC_STAB_TIME)  ; set clock stabilization time
1125
 
1126
#if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_4MHZ_MAIN_CLKP2_4MHZ)
1127
          MOV  CKSR,  #0xB5
1128
#endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_4MHZ_MAIN_CLKP2_4MHZ)
1129
 
1130
#if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_4MHZ_MAIN_CLKP2_4MHZ)
1131
          CLRB MFMCS:4
1132
          CLRB MFMCS:5
1133
          CLRB SFMCS:4
1134
          CLRB SFMCS:5
1135
          MOVW CKFCR, #0x1111
1136
          MOV  CKSR,  #0xB5
1137
#endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_4MHZ_MAIN_CLKP2_4MHZ)
1138
 
1139
#if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_4MHZ_PLL_CLKP2_4MHZ)
1140
#  if ((SERIES == MB96340) && (DEVICE < 3))
1141
          MOVW PLLCR, #0x00E0
1142
          MOV  CKSR,  #0xFA
1143
#  else
1144
          MOVW PLLCR, #0x00A1
1145
          MOVW CKFCR, #0x1111
1146
          MOVW MFMTC, #0x2128
1147
#    if SATELLITE_FLASH == ON
1148
          MOVW SFMTC, #0x2128
1149
#    endif ; SATELLITE_FLASH == ON
1150
          MOV  CKSR,  #0xFA
1151
#  endif ; ((SERIES == MB96340) && (DEVICE < 3))
1152
#endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_4MHZ_PLL_CLKP2_4MHZ)
1153
 
1154
#if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_4MHZ_PLL_CLKP2_4MHZ)
1155
#  if ((SERIES == MB96340) && (DEVICE < 3))
1156
          MOVW PLLCR, #0x0060
1157
          CLRB MFMCS:4
1158
          CLRB MFMCS:5
1159
          CLRB SFMCS:4
1160
          CLRB SFMCS:5
1161
          MOVW CKFCR, #0x1111
1162
          MOV  CKSR,  #0xFA
1163
#  else
1164
          MOVW PLLCR, #0x0060
1165
          MOVW CKFCR, #0x1111
1166
          MOVW MFMTC, #0x2128
1167
#    if SATELLITE_FLASH == ON
1168
          MOVW SFMTC, #0x2128
1169
#    endif ; SATELLITE_FLASH == ON
1170
          MOV  CKSR,  #0xFA
1171
#  endif ; ((SERIES == MB96340) && (DEVICE < 3))
1172
#endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_4MHZ_PLL_CLKP2_4MHZ)
1173
 
1174
#if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_8MHZ_CLKP2_8MHZ)
1175
#  if ((SERIES == MB96340) && (DEVICE < 3))
1176
          MOVW PLLCR, #0x00A1
1177
          MOV  CKSR,  #0xFA
1178
#  else
1179
          MOVW PLLCR, #0x0043
1180
          MOVW CKFCR, #0x1111
1181
          MOVW MFMTC, #0x2128
1182
#    if SATELLITE_FLASH == ON
1183
          MOVW SFMTC, #0x2128
1184
#    endif ; SATELLITE_FLASH == ON
1185
          MOV  CKSR,  #0xFA
1186
#  endif ; ((SERIES == MB96340) && (DEVICE < 3))
1187
#endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_8MHZ_CLKP2_8MHZ)
1188
 
1189
#if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_8MHZ_CLKP2_8MHZ)
1190
#  if ((SERIES == MB96340) && (DEVICE < 3))
1191
          MOVW PLLCR, #0x0060
1192
          MOV  CKSR,  #0xFA
1193
#  else
1194
          MOVW PLLCR, #0x0081
1195
          MOVW CKFCR, #0x1111
1196
          MOVW MFMTC, #0x2128
1197
#    if SATELLITE_FLASH == ON
1198
          MOVW SFMTC, #0x2128
1199
#    endif ; SATELLITE_FLASH == ON
1200
          MOV  CKSR,  #0xFA
1201
#  endif ; ((SERIES == MB96340) && (DEVICE < 3))
1202
#endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_8MHZ_CLKP2_8MHZ)
1203
 
1204
#if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_12MHZ_CLKP2_12MHZ)
1205
#  if ((SERIES == MB96340) && (DEVICE < 3))
1206
          MOVW PLLCR, #0x0062
1207
          MOV  CKSR,  #0xFA
1208
#  else
1209
          MOVW PLLCR, #0x0025
1210
          MOVW CKFCR, #0x1111
1211
          MOVW MFMTC, #0x2128
1212
#    if SATELLITE_FLASH == ON
1213
          MOVW SFMTC, #0x2128
1214
#    endif ; SATELLITE_FLASH == ON
1215
          MOV  CKSR,  #0xFA
1216
#  endif ; ((SERIES == MB96340) && (DEVICE < 3))
1217
#endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_12MHZ_CLKP2_12MHZ)
1218
 
1219
#if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_12MHZ_CLKP2_12MHZ)
1220
#  if ((SERIES == MB96340) && (DEVICE < 3))
1221
          MOVW PLLCR, #0x0082
1222
          CLRB MFMCS:4
1223
          CLRB MFMCS:5
1224
          CLRB SFMCS:4
1225
          CLRB SFMCS:5
1226
          MOVW CKFCR, #0x1111
1227
          MOV  CKSR,  #0xFA
1228
#  else
1229
          MOVW PLLCR, #0x0082
1230
          MOVW CKFCR, #0x1111
1231
          MOVW MFMTC, #0x2128
1232
#    if SATELLITE_FLASH == ON
1233
          MOVW SFMTC, #0x2128
1234
#    endif ; SATELLITE_FLASH == ON
1235
          MOV  CKSR,  #0xFA
1236
#  endif ; ((SERIES == MB96340) && (DEVICE < 3))
1237
#endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_12MHZ_CLKP2_12MHZ)
1238
 
1239
#if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_16MHZ_CLKP2_16MHZ)
1240
#  if ((SERIES == MB96340) && (DEVICE < 3))
1241
          MOVW PLLCR, #0x0043
1242
          MOV  CKSR,  #0xFA
1243
#  else
1244
          MOVW PLLCR, #0x0027
1245
          MOVW CKFCR, #0x1111
1246
          MOVW MFMTC, #0x2279
1247
#    if SATELLITE_FLASH == ON
1248
          MOVW SFMTC, #0x2279
1249
#    endif ; SATELLITE_FLASH == ON
1250
          MOV  CKSR,  #0xFA
1251
#  endif ; ((SERIES == MB96340) && (DEVICE < 3))
1252
#endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_16MHZ_CLKP2_16MHZ)
1253
 
1254
#if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_16MHZ_CLKP2_16MHZ)
1255
#  if ((SERIES == MB96340) && (DEVICE < 3))
1256
          MOVW PLLCR, #0x0081
1257
          MOV  CKSR,  #0xFA
1258
#  else
1259
          MOVW PLLCR, #0x0003
1260
          MOVW CKFCR, #0x1111
1261
          MOVW MFMTC, #0x2279
1262
#    if SATELLITE_FLASH == ON
1263
          MOVW SFMTC, #0x2279
1264
#    endif ; SATELLITE_FLASH == ON
1265
          MOV  CKSR,  #0xFA
1266
#  endif ; ((SERIES == MB96340) && (DEVICE < 3))
1267
#endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_16MHZ_CLKP2_16MHZ)
1268
 
1269
#if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_24MHZ_CLKP2_12MHZ)
1270
#  if ((SERIES == MB96340) && (DEVICE < 3))
1271
          MOVW PLLCR, #0x0025
1272
          MOVW CKFCR, #0x1001
1273
          MOV  CKSR,  #0xFA
1274
#  else
1275
          MOVW PLLCR, #0x000B
1276
          MOVW CKFCR, #0x3111
1277
          MOVW MFMTC, #0x4C09
1278
#    if SATELLITE_FLASH == ON
1279
          MOVW SFMTC, #0x4C09
1280
#    endif ; SATELLITE_FLASH == ON
1281
          MOV  CKSR,  #0xFA
1282
#  endif ; ((SERIES == MB96340) && (DEVICE < 3))
1283
#endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_24MHZ_CLKP2_12MHZ)
1284
 
1285
#if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_24MHZ_CLKP2_12MHZ)
1286
#  if ((SERIES == MB96340) && (DEVICE < 3))
1287
          MOVW PLLCR, #0x0082
1288
          MOVW CKFCR, #0x1001
1289
          MOV  CKSR,  #0xFA
1290
#  else
1291
          MOVW PLLCR, #0x0005
1292
          MOVW CKFCR, #0x3111
1293
          MOVW MFMTC, #0x4C09
1294
#    if SATELLITE_FLASH == ON
1295
          MOVW SFMTC, #0x4C09
1296
#    endif ; SATELLITE_FLASH == ON
1297
          MOV  CKSR,  #0xFA
1298
#  endif ; ((SERIES == MB96340) && (DEVICE < 3))
1299
#endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_24MHZ_CLKP2_12MHZ)
1300
 
1301
#if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP2_16MHZ)
1302
#  if ((SERIES == MB96340) && (DEVICE < 3))
1303
#    error Setting prohibited due to 16FXFL0014
1304
#  else
1305
          MOVW PLLCR, #0x000F
1306
          MOVW CKFCR, #0x3111
1307
          MOVW MFMTC, #0x4C09
1308
#    if SATELLITE_FLASH == ON
1309
          MOVW SFMTC, #0x4C09
1310
#    endif ; SATELLITE_FLASH == ON
1311
          MOV  CKSR,  #0xFA
1312
#  endif ; ((SERIES == MB96340) && (DEVICE < 3))
1313
#endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP2_16MHZ)
1314
 
1315
#if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP2_16MHZ)
1316
#  if ((SERIES == MB96340) && (DEVICE < 3))
1317
#    error Setting prohibited due to 16FXFL0014
1318
#  else
1319
          MOVW PLLCR, #0x0007
1320
          MOVW CKFCR, #0x3111
1321
          MOVW MFMTC, #0x4C09
1322
#    if SATELLITE_FLASH == ON
1323
          MOVW SFMTC, #0x4C09
1324
#    endif ; SATELLITE_FLASH == ON
1325
          MOV  CKSR,  #0xFA
1326
#  endif ; ((SERIES == MB96340) && (DEVICE < 3))
1327
#endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP2_16MHZ)
1328
 
1329
#if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP1_16MHZ_CLKP2_16MHZ)
1330
#  if ((SERIES == MB96340) && (DEVICE < 3))
1331
#    error Setting prohibited due to 16FXFL0014
1332
#  else
1333
          MOVW PLLCR, #0x000F
1334
          MOVW CKFCR, #0x3311
1335
          MOVW MFMTC, #0x4C09
1336
#    if SATELLITE_FLASH == ON
1337
          MOVW SFMTC, #0x4C09
1338
#    endif ; SATELLITE_FLASH == ON
1339
          MOV  CKSR,  #0xFA
1340
#  endif ; ((SERIES == MB96340) && (DEVICE < 3))
1341
#endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP1_16MHZ_CLKP2_16MHZ)
1342
 
1343
#if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP1_16MHZ_CLKP2_16MHZ)
1344
#  if ((SERIES == MB96340) && (DEVICE < 3))
1345
#    error Setting prohibited due to 16FXFL0014
1346
#  else
1347
          MOVW PLLCR, #0x0007
1348
          MOVW CKFCR, #0x3311
1349
          MOVW MFMTC, #0x4C09
1350
#    if SATELLITE_FLASH == ON
1351
          MOVW SFMTC, #0x4C09
1352
#    endif ; SATELLITE_FLASH == ON
1353
          MOV  CKSR,  #0xFA
1354
#  endif ; ((SERIES == MB96340) && (DEVICE < 3))
1355
#endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP1_16MHZ_CLKP2_16MHZ)
1356
 
1357
#if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_48MHZ_CLKP2_16MHZ)
1358
          MOVW PLLCR, #0x000B
1359
          MOVW CKFCR, #0x2001
1360
          MOVW MFMTC, #0x223A
1361
#  if SATELLITE_FLASH == ON
1362
          MOVW SFMTC, #0x223A
1363
#  endif ; SATELLITE_FLASH == ON
1364
          MOV  CKSR,  #0xFA
1365
#endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_48MHZ_CLKP2_16MHZ)
1366
 
1367
#if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_48MHZ_CLKP2_16MHZ)
1368
          MOVW PLLCR, #0x0005
1369
          MOVW CKFCR, #0x2001
1370
          MOVW MFMTC, #0x223A
1371
#  if SATELLITE_FLASH == ON
1372
          MOVW SFMTC, #0x223A
1373
#  endif ; SATELLITE_FLASH == ON
1374
          MOV  CKSR,  #0xFA
1375
#endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_48MHZ_CLKP2_16MHZ)
1376
 
1377
#if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_56MHZ_CLKP2_14MHZ)
1378
          MOVW PLLCR, #0x000D
1379
          MOVW CKFCR, #0x3001
1380
          MOVW MFMTC, #0x4B3B
1381
#  if SATELLITE_FLASH == ON
1382
          MOVW SFMTC, #0x4B3B
1383
#  endif ; SATELLITE_FLASH == ON
1384
          MOV  CKSR,  #0xFA
1385
#endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_56MHZ_CLKP2_14MHZ)
1386
 
1387
#if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_56MHZ_CLKP2_14MHZ)
1388
          MOVW PLLCR, #0x0006
1389
          MOVW CKFCR, #0x3001
1390
          MOVW MFMTC, #0x4B3B
1391
          MOV  MFMCS, #0x70
1392
#  if SATELLITE_FLASH == ON
1393
          MOVW SFMTC, #0x4B3B
1394
          MOV  SFMCS, #0x70
1395
#  endif ; SATELLITE_FLASH == ON
1396
          MOV  VRCR,  #0xF6
1397
          MOV  CKSR,  #0xFA
1398
#endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_56MHZ_CLKP2_14MHZ)
1399
 
1400
 
1401
;====================================================================
1402
; 6.6  Set external bus configuaration
1403
;====================================================================
1404
 
1405
#if BUSMODE != SINGLE_CHIP         ; ext bus used
1406
           MOV  EBCF, #((HOLD_REQ << 7) | (EXT_READY << 6) | (EXT_CLOCK_ENABLE << 5) | (EXT_CLOCK_INVERT << 4) | (EXT_CLOCK_SUSPEND << 3) | EXT_CLOCK_DIVISION)
1407
           MOV  EBAE0,#ADDR_PINS_7_0
1408
           MOV  EBAE1,#ADDR_PINS_15_8
1409
           MOV  EBAE2,#ADDR_PINS_23_16
1410
           MOV  EBCS, #((ADDRESS_STROBE_LVL << 6) | (ADDRESS_STROBE << 5) | (READ_STROBE << 4) | (HIGH_WRITE_STROBE << 3) | (LOW_WRITE_STROBE << 2) | (HIGH_BYTE_SIGNAL << 1) | LOW_BYTE_SIGNAL)
1411
           MOVW EACL0,#CS0_CONFIG
1412
           MOVW EACL1,#CS1_CONFIG
1413
           MOVW EACL2,#CS2_CONFIG
1414
           MOVW EACL3,#CS3_CONFIG
1415
           MOVW EACL4,#CS4_CONFIG
1416
           MOVW EACL5,#CS5_CONFIG
1417
           MOV  EAS2, #CS2_START
1418
           MOV  EAS3, #CS3_START
1419
           MOV  EAS4, #CS4_START
1420
           MOV  EAS5, #CS5_START
1421
           MOV  EBM,  #((ADDRESSMODE << 7) | ((BUSMODE-1) << 6) | (CHIP_SELECT5 << 5) | (CHIP_SELECT4 << 4) | (CHIP_SELECT3 << 3) | (CHIP_SELECT2 << 2) | (CHIP_SELECT1 << 1) | CHIP_SELECT0) ; set address mode, ROM access
1422
 
1423
#  if SERIES == MB96320 || SERIES == MB96340 || SERIES == MB96350
1424
           MOV  PIER00,#0xFF
1425
#    if (CS0_CONFIG & 0x0080) == 0 || (CS1_CONFIG & 0x0080) == 0 || (CS2_CONFIG & 0x0080) == 0 || (CS3_CONFIG & 0x0080) == 0 || (CS4_CONFIG & 0x0080) == 0 || (CS5_CONFIG & 0x0080) == 0
1426
           MOV  PIER01,#0xFF
1427
#    endif
1428
#    if HOLD_REQ == ON
1429
           SETB PIER03:4
1430
#    endif
1431
#    if EXT_READY == ON
1432
           SETB PIER03:6
1433
#    endif
1434
#  else if SERIES == MB96380
1435
           MOV  PIER01,#0xFF
1436
#    if (CS0_CONFIG & 0x0080) == 0 || (CS1_CONFIG & 0x0080) == 0 || (CS2_CONFIG & 0x0080) == 0 || (CS3_CONFIG & 0x0080) == 0 || (CS4_CONFIG & 0x0080) == 0 || (CS5_CONFIG & 0x0080) == 0
1437
           MOV  PIER02,#0xFF
1438
#    endif
1439
#    if HOLD_REQ == ON
1440
           SETB PIER12:7
1441
#    endif
1442
#    if EXT_READY == ON
1443
           SETB PIER00:2
1444
#    endif
1445
#  endif
1446
 
1447
#endif
1448
 
1449
#if BUSMODE == INTROM_EXTBUS     ; EXTBUS and INTROM/EXTROM
1450
#  if ROMMIRROR == OFF && CONSTDATA == ROMCONST
1451
#    error Mirror function must be ON to mirror internal ROM
1452
#  endif
1453
#endif
1454
 
1455
ROMM_CONFIG    .EQU     ((MIRROR_BANK << 4) | (MIRROR_SIZE << 1) | (ROMMIRROR))
1456
           MOV  ROMM, #ROMM_CONFIG
1457
 
1458
 
1459
;====================================================================
1460
; 6.7  Prepare stacks and set the default stack type
1461
;====================================================================
1462
 
1463
          AND  CCR,#H'DF            ; clear system stack flag
1464
          MOVL A, #(__userstack_top) & ~1
1465
          MOVW SP,A                 ; load offset of stack top to pointer
1466
          SWAPW                     ; swap higher word to AL
1467
          MOV  USB, A               ; set bank
1468
 
1469
#if STACK_FILL == ON                ; preset the stack
1470
          MOV  ADB, A
1471
          MOVW A, #USTACK           ; load start stack address to AL
1472
          MOVW A, #STACK_PATTERN    ; AL -> AH, pattern in AL
1473
          MOVW RW0, #SIZEOF(USTACK) / 2 ; get byte count
1474
          FILSWI    ADB             ; write pattern to stack
1475
#endif
1476
 
1477
          OR   CCR,#H'20            ; set System stack flag
1478
          MOVL A, #(__systemstack_top) & ~1
1479
          MOVW SP,A                 ; load offset of stack top to pointer
1480
          SWAPW                     ; swap higher word to AL
1481
          MOV  SSB, A               ; set bank
1482
 
1483
#if STACK_FILL == ON                ; preset the stack
1484
          MOV  ADB, A
1485
          MOVW A, #SSTACK           ; load start stack address to AL
1486
          MOVW A, #STACK_PATTERN    ; AL -> AH, pattern in AL
1487
          MOVW RW0, #SIZEOF(SSTACK) / 2; get byte count
1488
          FILSWI    ADB             ; write pattern to stack
1489
#endif
1490
 
1491
#if STACKUSE == USRSTACK
1492
          AND  CCR,#H'DF            ; clear system stack flag
1493
#endif
1494
 
1495
 
1496
;   The following macro is needed because of the AUTOMODEL option. If the
1497
;   model is not known while assembling the module, one has to expect
1498
;   completion of streaminit() by RET or RETP. Because RET removes 2 bytes
1499
;   from stack and RETP removes 4 bytes from stack, SP is reloaded.
1500
 
1501
#  macro RELOAD_SP
1502
 
1503
#if STACKUSE == USRSTACK
1504
          MOVW A, #(__userstack_top) & ~1
1505
#else
1506
          MOVW A, #(__systemstack_top) & ~1
1507
#endif
1508
          MOVW SP,A
1509
#  endm
1510
 
1511
 
1512
;====================================================================
1513
; 6.8  Copy initial values to data areas.
1514
;====================================================================
1515
;
1516
; Each C-module has its own __far INIT section. The names are generic.
1517
; DCONST_module contains the initialisers for the far data of the one
1518
; module. INIT_module reserves the RAM area, which has to be loaded
1519
; with the data from DCONST_module. ("module" is the name of the *.c
1520
; file)
1521
; All separated DCONST_module/INIT_module areas are described in
1522
; DTRANS section by start addresses and length of each far section.
1523
;   0000 1. source address (ROM)
1524
;   0004 1. destination address (RAM)
1525
;   0008 length of sections 1
1526
;   000A 2. source address  (ROM)
1527
;   000E 2. destination address (RAM)
1528
;   0012 length of sections 2
1529
;   0014 3. source address ...
1530
; In addition the start-up file adds the descriptors of the __near
1531
; sections to this table. The order of the descriptors in this table
1532
; depends on the linkage order.
1533
;====================================================================
1534
          MOV  A, #BNKSEC DTRANS   ; get bank of table
1535
          MOV  DTB, A              ; store bank in DTB
1536
          MOVW RW1, #DTRANS        ; get start offset of table
1537
          OR   CCR, #H'20          ; System stack flag set (SSB used)
1538
          BRA  LABEL2              ; branch to loop condition
1539
LABEL1:
1540
          MOVW A, @RW1+6           ; get bank of destination
1541
          MOV  SSB, A              ; save dest bank in SSB
1542
          MOVW A, @RW1+2           ; get source bank
1543
          MOV  ADB, A              ; save source bank in ADB
1544
          MOVW A, @RW1+4           ; move destination addr in AL
1545
          MOVW A, @RW1             ; AL -> AH, src addr -> AL
1546
          MOVW RW0, @RW1+8         ; number of bytes to copy -> RW0
1547
          MOVSI     SPB, ADB       ; copy data
1548
          MOVN A, #10              ; length of one table entry is 10
1549
          ADDW RW1, A              ; set pointer to next table entry
1550
LABEL2:
1551
          MOVW A, RW1              ; get address of next block
1552
          SUBW A, #DTRANS          ; sub address of first block
1553
          CMPW A, #SIZEOF (DTRANS) ; all blocks processed ?
1554
          BNE  LABEL1              ; if not, branch
1555
 
1556
 
1557
;====================================================================
1558
; 6.9   Clear uninitialised data areas to zero
1559
;====================================================================
1560
;
1561
; Each C-module has its own __far DATA section. The names are generic.
1562
; DATA_module contains the reserved area (RAM) to be cleared.
1563
; ("module" is the name of the *.c file)
1564
; All separated DATA_module areas are described in DCLEAR section by
1565
; start addresses and length of all far section.
1566
;   0000 1. section address (RAM)
1567
;   0004 length of section 1
1568
;   0006 2. section address (RAM)
1569
;   000A length of section 2
1570
;   000C 3. section address (RAM)
1571
;   0010 length of section 3 ...
1572
; In addition the start-up file adds the descriptors of the __near
1573
; sections to this table. The order of the descriptors in this table
1574
; depends on the linkage order.
1575
;====================================================================
1576
          MOV  A, #BNKSEC DCLEAR   ; get bank of table
1577
          MOV  DTB, A              ; store bank in DTB
1578
          MOVW RW1, #DCLEAR        ; get start offset of table
1579
          BRA  LABEL4              ; branch to loop condition
1580
LABEL3:
1581
          MOV  A, @RW1+2           ; get section bank
1582
          MOV  ADB, A              ; save section bank in ADB
1583
          MOVW RW0, @RW1+4         ; number of bytes to copy -> RW0
1584
          MOVW A, @RW1             ; move section addr in AL
1585
          MOVN A, #0               ; AL -> AH, init value -> AL
1586
          FILSI     ADB            ; write 0 to section
1587
          MOVN A, #6               ; length of one table entry is 6
1588
          ADDW RW1, A              ; set pointer to next table entry
1589
LABEL4:
1590
          MOVW A, RW1              ; get address of next block
1591
          SUBW A, #DCLEAR          ; sub address of first block
1592
          CMPW A, #SIZEOF (DCLEAR) ; all blocks processed ?
1593
          BNE  LABEL3              ; if not, branch
1594
 
1595
 
1596
 
1597
;====================================================================
1598
; 6.10  Set Data Bank Register (DTB) and Direct Page Register (DPR)
1599
;====================================================================
1600
          MOV  A,#BNKSEC DATA          ; User data bank offset
1601
          MOV  DTB,A
1602
 
1603
          MOV  A,#PAGE DIRDATA_S       ; User direct page
1604
          MOV  DPR,A
1605
 
1606
;====================================================================
1607
; 6.11  Wait for clocks to stabilise
1608
;====================================================================
1609
 
1610
#if (CLOCK_SPEED == CPU_4MHZ_MAIN_CLKP2_4MHZ) && (CLOCKWAIT == ON)
1611
no_MC_yet:
1612
          BBC  CKMR:5,no_MC_yet        ; check MCM and wait for
1613
                                       ; Main Clock to stabilize
1614
#endif ; wait for Main Clock
1615
 
1616
#if (((CRYSTAL == FREQ_4MHZ) ||(CRYSTAL == FREQ_8MHZ)) && \
1617
     ((CLOCK_SPEED == CPU_12MHZ_CLKP2_12MHZ) || \
1618
     (CLOCK_SPEED == CPU_16MHZ_CLKP2_16MHZ) || \
1619
     (CLOCK_SPEED == CPU_24MHZ_CLKP2_12MHZ)))
1620
no_PLL_0WS:
1621
          BBC  CKMR:6, no_PLL_0WS
1622
 
1623
#  if ! ((SERIES == MB96340) && (DEVICE < 3))
1624
          MOVW MFMTC, #0x2208
1625
#    if SATELLITE_FLASH == ON
1626
          MOVW SFMTC, #0x2208
1627
#    endif ; SATELLITE_FLASH == ON
1628
#  endif ; ! ((SERIES == MB96340) && (DEVICE < 3))
1629
#endif
1630
 
1631
#if ((CRYSTAL == FREQ_4MHZ) || (CRYSTAL == FREQ_8MHZ)) && \
1632
     ((CLOCK_SPEED == CPU_32MHZ_CLKP2_16MHZ) || \
1633
      (CLOCK_SPEED == CPU_32MHZ_CLKP1_16MHZ_CLKP2_16MHZ)) && \
1634
    ! ((SERIES == MB96340) && (DEVICE < 3))
1635
no_PLL_1WS:
1636
          BBC  CKMR:6, no_PLL_1WS
1637
 
1638
          MOVW MFMTC, #0x6B09
1639
#  if SATELLITE_FLASH == ON
1640
          MOVW SFMTC, #0x6B09
1641
#  endif ; SATELLITE_FLASH == ON
1642
#endif
1643
 
1644
#if (CLOCKWAIT == ON) && \
1645
    ((CLOCK_SPEED == CPU_4MHZ_PLL_CLKP2_4MHZ) || \
1646
     (CLOCK_SPEED == CPU_8MHZ_CLKP2_8MHZ) || \
1647
     (CLOCK_SPEED == CPU_48MHZ_CLKP2_16MHZ) || \
1648
     (CLOCK_SPEED == CPU_56MHZ_CLKP2_14MHZ))
1649
no_PLL_yet:
1650
          BBC  CKMR:6,no_PLL_yet       ; check PCM and wait for
1651
                                       ; PLL to stabilize
1652
#endif ; wait for PLL
1653
 
1654
;====================================================================
1655
; 6.12  Initialise Low-Level Library Interface
1656
;====================================================================
1657
;
1658
; Call lib init function and reload stack afterwards, if AUTOMODEL
1659
;====================================================================
1660
#if CLIBINIT == ON
1661
#  if MEMMODEL == SMALL || MEMMODEL == COMPACT
1662
          CALL __stream_init       ; initialise library IO
1663
#  else                            ; MEDIUM, LARGE, AUTOMODEL
1664
          CALLP __stream_init      ; initialise library IO
1665
#    if MEMMODEL == AUTOMODEL
1666
          RELOAD_SP                ; reload stack since stream_init was
1667
                                   ; possibly left by RET (not RETP)
1668
#    endif  ; AUTOMODEL
1669
#  endif  ; MEDIUM, LARGE, AUTOMODEL
1670
#endif  ; LIBINI
1671
 
1672
;====================================================================
1673
; 6.13  Call C-language main function
1674
;====================================================================
1675
#if MEMMODEL == SMALL || MEMMODEL == COMPACT
1676
          CALL _main               ; Start main function
1677
#else                              ; MEDIUM, LARGE, AUTOMODEL
1678
          CALLP _main              ; Start main function
1679
                                   ; ignore remaining word on stack,
1680
                                   ; if main was completed by RET
1681
#endif
1682
;====================================================================
1683
; 6.14  Shut down library
1684
;====================================================================
1685
#if CLIBINIT == ON
1686
#  if MEMMODEL == SMALL || MEMMODEL == COMPACT
1687
          CALL _exit
1688
#  else                            ; MEDIUM, LARGE, AUTOMODEL
1689
          CALLP _exit              ; ignore remaining word on stack,
1690
                                   ; if main was completed by RET
1691
#  endif
1692
__exit:
1693
#endif
1694
 
1695
;====================================================================
1696
; 6.15  Program end loop
1697
;====================================================================
1698
 
1699
end:      BRA  end                 ; Loop
1700
 
1701
 
1702
;====================================================================
1703
; 6.16 Set Flash Security
1704
;====================================================================
1705
 
1706
          .SECTION MAIN_SECURITY, CONST, LOCATE=H'DF0000
1707
#if MAIN_SECURITY_ENABLE == 0
1708
              .DATA.W 0xFFFF ; Security DISABLED
1709
              .SKIP   16
1710
#else MAIN_SECURITY_ENABLE == 1
1711
              .DATA.W 0x0099 ; Security ENABLED
1712
              .DATA.W ((MAIN_UNLOCK_1 << 8) | MAIN_UNLOCK_0)
1713
              .DATA.W ((MAIN_UNLOCK_3 << 8) | MAIN_UNLOCK_2)
1714
              .DATA.W ((MAIN_UNLOCK_5 << 8) | MAIN_UNLOCK_4)
1715
              .DATA.W ((MAIN_UNLOCK_7 << 8) | MAIN_UNLOCK_6)
1716
              .DATA.W ((MAIN_UNLOCK_9 << 8) | MAIN_UNLOCK_8)
1717
              .DATA.W ((MAIN_UNLOCK_11 << 8) | MAIN_UNLOCK_10)
1718
              .DATA.W ((MAIN_UNLOCK_13 << 8) | MAIN_UNLOCK_12)
1719
              .DATA.W ((MAIN_UNLOCK_15 << 8) | MAIN_UNLOCK_14)
1720
#endif
1721
              .SKIP   4
1722
              .SKIP   6
1723
 
1724
#if SATELLITE_FLASH == ON
1725
          .SECTION SATELLITE_SECURITY, CONST, LOCATE=H'DE0000
1726
#  if SATELLITE_SECURITY_ENABLE == 0
1727
              .DATA.W 0xFFFF ; Security DISABLED
1728
              .SKIP   16
1729
#  else SATELLITE_SECURITY_ENABLE == 1
1730
              .DATA.W 0x0099 ; Security ENABLED
1731
              .DATA.W ((SATELLITE_UNLOCK_1 << 8) | SATELLITE_UNLOCK_0)
1732
              .DATA.W ((SATELLITE_UNLOCK_3 << 8) | SATELLITE_UNLOCK_2)
1733
              .DATA.W ((SATELLITE_UNLOCK_5 << 8) | SATELLITE_UNLOCK_4)
1734
              .DATA.W ((SATELLITE_UNLOCK_7 << 8) | SATELLITE_UNLOCK_6)
1735
              .DATA.W ((SATELLITE_UNLOCK_9 << 8) | SATELLITE_UNLOCK_8)
1736
              .DATA.W ((SATELLITE_UNLOCK_11 << 8) | SATELLITE_UNLOCK_10)
1737
              .DATA.W ((SATELLITE_UNLOCK_13 << 8) | SATELLITE_UNLOCK_12)
1738
              .DATA.W ((SATELLITE_UNLOCK_15 << 8) | SATELLITE_UNLOCK_14)
1739
#  endif
1740
              .SKIP   4
1741
              .SKIP   6
1742
#endif ; SATELLITE_FLASH == ON
1743
 
1744
 
1745
;====================================================================
1746
; 6.17 Set Flash write protection
1747
;====================================================================
1748
 
1749
          .SECTION MAIN_PROTECT, CONST, LOCATE=H'DF001C
1750
#if MAIN_FLASH_WRITE_PROTECT == ON
1751
          .DATA.L 0x292D3A7B
1752
          .DATA.B ~((PROTECT_SECTOR_SA3 << 3) | (PROTECT_SECTOR_SA2 << 2) | (PROTECT_SECTOR_SA1 << 1) | PROTECT_SECTOR_SA0)
1753
          .DATA.E 0xFFFFFF
1754
          .DATA.B ~((PROTECT_SECTOR_SA39 << 7) | (PROTECT_SECTOR_SA38 << 6) | (PROTECT_SECTOR_SA37 << 5) | (PROTECT_SECTOR_SA36 << 4) | (PROTECT_SECTOR_SA35 << 3) | (PROTECT_SECTOR_SA34 << 2) | (PROTECT_SECTOR_SA33 << 1) | PROTECT_SECTOR_SA32)
1755
          .SKIP   3
1756
#else
1757
          .DATA.L 0xFFFFFFFF
1758
          .SKIP   8
1759
#endif ; MAIN_FLASH_WRITE_PROTECT
1760
          .SKIP   8
1761
 
1762
#if SATELLITE_FLASH == ON
1763
          .SECTION SATELLITE_PROTECT, CONST, LOCATE=H'DE001C
1764
#  if SATELLITE_FLASH_WRITE_PROTECT == ON
1765
          .DATA.L 0x292D3A7B
1766
          .DATA.B ~((PROTECT_SECTOR_SB3 << 3) | (PROTECT_SECTOR_SB2 << 2) | (PROTECT_SECTOR_SB1 << 1) | PROTECT_SECTOR_SB0)
1767
          .SKIP   7
1768
#  else
1769
          .DATA.L 0xFFFFFFFF
1770
          .SKIP   8
1771
#  endif ; SATELLITE_FLASH_WRITE_PROTECT
1772
          .SKIP   8
1773
#endif ; SATELLITE_FLASH == ON
1774
 
1775
 
1776
;====================================================================
1777
; 6.18 Debug address specification
1778
;====================================================================
1779
;
1780
; BDM configuration section should always be defined for later
1781
; configuration by e.g. debugger tool or (special) programmer tool.
1782
 
1783
          .SECTION BDM_CONFIG, CONST, LOCATE=H'DF0040
1784
 
1785
#if BACKGROUND_DEBUGGING == ON
1786
 
1787
          .DATA.L 0x292D3A7B
1788
 
1789
          .ORG    H'DF0044
1790
          .DATA.W BDM_CONFIGURATION
1791
 
1792
          .ORG    H'DF0046
1793
#  if (SERIES == MB96340 && DEVICE < 3)
1794
#    error Device does not support background debugging
1795
#  endif ; (SERIES == MB96340 && DEVICE < 3)
1796
 
1797
#  if (SERIES == MB96340 && DEVICE < 12)
1798
          .DATA.W (D'16 * CRYSTAL + BDM_BAUDRATE) / BDM_BAUDRATE
1799
#  else
1800
          .DATA.W (D'32 * CRYSTAL + BDM_BAUDRATE) / BDM_BAUDRATE
1801
#  endif ; (SERIES == MB96340 && if DEVICE < 12)
1802
 
1803
          .ORG    H'DF0048
1804
          .DATA.E BDM_EXT_CONFIG
1805
 
1806
          .ORG    H'DF004B
1807
          .DATA.B BDM_WD_PATTERN
1808
 
1809
          .ORG    H'DF0050
1810
          .DATA.W BDM_PFCS0
1811
          .DATA.W BDM_PFCS1
1812
          .DATA.W BDM_PFCS2
1813
          .DATA.W BDM_PFCS3
1814
 
1815
          .DATA.E BDM_PFA0, BDM_PFA1
1816
          .DATA.E BDM_PFA2, BDM_PFA3
1817
          .DATA.E BDM_PFA4, BDM_PFA5
1818
          .DATA.E BDM_PFA6, BDM_PFA7
1819
 
1820
          .DATA.W BDM_PFD0, BDM_PFD1
1821
          .DATA.W BDM_PFD2, BDM_PFD3
1822
          .DATA.W BDM_PFD4, BDM_PFD5
1823
          .DATA.W BDM_PFD6, BDM_PFD7
1824
#else
1825
          .DATAB.B 64, 0xFF        ; fill section with 0xFF
1826
 
1827
#endif ; BACKGROUND_DEBUGGING == ON
1828
 
1829
          .ORG    0xDF0080
1830
          .END notresetyet         ; define debugger start address
1831
 
1832
 
1833
;====================================================================
1834
; ----------------------- End of Start-up file ---------------------
1835
;====================================================================

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.