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