1 ;====================================================================
2 ; $Id: START.ASM,v 1.31 2008/02/27 10:23:34 mcuae Exp $
3 ;====================================================================
4 ; THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS.
5 ; FUJITSU MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY
6 ; FOR ANY ERRORS OR ELIGIBILITY FOR ANY PURPOSES.
8 ; Startup file for memory and basic controller initialisation
10 ; MB96300 Family C Compiler
12 ; (C) FUJITSU MICROELECTRONICS EUROPE 1998-2008
13 ;====================================================================
16 .TITLE "STARTUP FILE FOR MEMORY INITIALISATION"
18 ;====================================================================
20 ;====================================================================
25 ; 4 SETTINGS (USER INTERFACE)
26 ; 4.1 Controller Series, Device
27 ; 4.2 C-language Memory model
28 ; 4.3 Function-Call Interface
29 ; 4.4 Constant Data Handling
30 ; 4.5 Stack Type and Stack Size
31 ; 4.6 General Register Bank
32 ; 4.7 Low-Level Library Interface
35 ; 4.9 Clock Stabilization Time
36 ; 4.10 External Bus Interface
37 ; 4.11 ROM Mirror configuration
39 ; 4.13 Flash Write Protection
42 ; 4.16 Enable RAMCODE Copying
43 ; 4.17 Enable information stamp in ROM
44 ; 4.18 Enable Background Debugging Mode
46 ; 5 Section and Data Declaration
47 ; 5.1 Several fixed addresses (fixed for MB963xx controllers)
48 ; 5.2 Declaration of __near addressed data sections
49 ; 5.3 Declaration of RAMCODE section and labels
50 ; 5.4 Declaration of sections containing other sections description
51 ; 5.5 Stack area and stack top definition/declaration
52 ; 5.6 Direct page register dummy label definition
53 ; 5.7 Set Flash Security
54 ; 5.8 Set Flash write protection
55 ; 5.9 Debug address specification
58 ; 6.1 Import external symbols
59 ; 6.2 Program start (the boot vector should point here)
60 ; 6.3 "NOT RESET YET" WARNING
61 ; 6.4 Initialisation of processor status
62 ; 6.5 Set clock ratio (ignore subclock)
63 ; 6.6 Set external bus configuration
64 ; 6.7 Prepare stacks and set the active stack type
65 ; 6.8 Copy initial values to data areas
66 ; 6.9 Clear uninitialized data areas to zero
67 ; 6.10 Set Data Bank Register (DTB) and Direct Page Register (DPR)
68 ; 6.11 ICU register initialization workaround
69 ; 6.12 Wait for PLL to stabilize
70 ; 6.13 Initialise Low-Level Library Interface
71 ; 6.14 Call C-language main function
72 ; 6.15 Shut down library
73 ; 6.16 Program end loop
75 ;====================================================================
77 ;====================================================================
78 ; FUJITSU MICROELECTRONICS EUROPE GMBH
79 ; Pittlerstrasse 47, 63225 Langen, Germany
80 ; Tel.:++49 6103 690-0, Fax -122
82 ; The following software is for demonstration purposes only.
83 ; It is not fully tested, nor validated in order to fulfil
84 ; its task under all circumstances. Therefore, this software
85 ; or any part of it must only be used in an evaluation
86 ; laboratory environment.
87 ; This software is subject to the rules of our standard
88 ; DISCLAIMER, that is delivered with our SW-tools on the
89 ; Fujitsu Microcontrollers DVD (V5.0 or higher "\START.HTM") or
90 ; on our Internet Pages:
91 ; http://www.fme.gsdc.de/gsdc.htm
92 ; http://emea.fujitsu.com/microelectronics
94 ;====================================================================
96 ;====================================================================
97 ; $Id: START.ASM,v 1.31 2008/02/27 10:23:34 mcuae Exp $
99 #define VERSION "1.31"
102 Revision 1.31 2008/02/27 10:23:34 mcuae
103 - CPU_48MHZ_CLKP1_32MHZ_CLKP2_16MHZ clock setting added
105 Revision 1.30 2008/02/26 15:28:21 mcuae
106 - clock settings corrected
107 - Main/Satellite Flash term outdated, now: Flash A, Flash B
109 Revision 1.29 2008/02/11 15:26:33 mwilla
110 - device configuration for ext. bus i/f settings updated
112 Revision 1.28 2008/01/25 08:03:48 mwilla
113 - clock settings corrected and optimized
115 Revision 1.27 2008/01/04 12:26:08 mwilla
116 - device list expanded
117 - clock settings optimized
119 Revision 1.26 2007/10/17 11:53:34 mwilla
120 - device list expanded
121 - ICU initialization workaround added
122 - sections settings grouped
124 Revision 1.25 2007/09/28 07:33:18 mwilla
125 - Bug in BDM baudrate calculation corrected
127 Revision 1.24 2007/09/26 14:03:08 mwilla
128 - Device list for MB96340 series updated and expanded
130 Revision 1.23 2007/08/06 14:48:16 mwilla
131 - BDM section always reserved, filled with 0xFF, if not configured
133 Revision 1.22 2007/08/02 08:34:03 mwilla
134 - communication mode bits of BDM configuration grouped
136 Revision 1.21 2007/07/13 08:23:05 mwilla
137 - device selection for BDM baud rate improved
139 Revision 1.20 2007/06/12 10:43:57 mwilla
140 - BDM-Baud-Rate calculation includes crystal frequency
142 Revision 1.19 2007/06/06 07:46:55 mwilla
143 - add Background Debugging Configuration
144 - Stack initialization moved before variable initialization
145 - values of cystal frequency and device macros changed
147 Revision 1.18 2007/04/16 07:56:02 phuene
148 - update clock settings when crystal is 8 MHz so that the CLKVCO is low
150 Revision 1.17 2007/04/10 11:30:43 phuene
152 - Clock settings optimized for CPU_8MHZ_CLKP2_8MHZ, CPU_12MHZ_CLKP2_12MHZ, CPU_16MHZ_CLKP2_16MHZ, CPU_24MHZ_CLKP2_24MHZ, CPU_32MHZ_CLKP2_32MHZ
153 - make the selection for the individual devices also consider the selected Series
154 - support 8 MHz crystal
155 - add clock setting CPU_32MHZ_CLKP1_16MHZ_CLKP2_16MHZ
156 - prohibit CPU_32MHZ_CLKP2_16MHZ, CPU_CLKP1_16MHZ_CLKP2_16MHZ for MB96F348H and MB96F348T according to functional limitation 16FXFL0014
158 Revision 1.16 2007/02/07 12:38:10 phuene
159 - support disabling the UART scanning in Internal Vector Mode
160 - distinguish between Reset Vector and Boot Vector: the Boot Vector points to the start of the user application
162 Revision 1.15 2007/02/07 09:00:19 phuene
163 - add .SKIP instructions to occupy the whole ROM configuration block area
165 Revision 1.14 2007/01/29 13:15:06 phuene
166 - fix CPU_4MHZ_MAIN_CLKP2_4MHZ clock setting
168 Revision 1.13 2007/01/03 10:40:14 phuene
169 - change clock setting CPU_24MHZ_CLKP2_16MHZ to CPU_24MHZ_CLKP2_12MHZ; this allows for better performance of MB96F348H/T
170 - use additional preprocessor statements to avoid checking for PLL ready twice in some cases
172 Revision 1.12 2007/01/02 10:16:20 phuene
173 - correct CLKP2 (CAN) clock for CPU_32MHZ and MB96F348H/T
174 - correct CLKP2 (CAN) clock for CPU_24MHZ for all other devices than MB96F348H/T
176 Revision 1.11 2006/12/28 10:49:52 phuene
177 - corrected PLL setting for CPU_16MHZ for MB96348H, MB96348T
179 Revision 1.10 2006/12/28 08:41:57 phuene
180 - correct revision number at new location
182 Revision 1.1 2006/12/28 07:20:01 phuene
183 - new location in CVS
185 Revision 1.9 2006/12/27 13:00:45 phuene
186 - add support for ROM Mirror when using the Simulator
187 - add support for 16FXFL0022, 16FXFL0023
189 Revision 1.8 2006/12/11 16:43:37 phuene
192 Revision 1.7 2006/12/11 16:35:08 phuene
193 - add setting for Clock Stabilization Times
194 - modify clock settings:
196 - remove clock settings using more wait cycles than absolutely required
198 Revision 1.6 2006/11/03 13:38:45 phuene
199 - modify clock settings to also set the Flash Memory Timing
200 - add support for both parameter passing models
202 Revision 1.5 2006/08/07 14:01:44 phuene
203 - change default clock setting to PLLx4 for CLKS1, CLKS2
204 - correct clock setting
205 - disable Flash Security by default for Main Flash, Satellite Flash
206 - disable availability of Satellite Flash by default
208 Revision 0.1 2006/01/25 15:37:46 phu
209 - initial version based on start.asm for MB90340 Series, version 3.8
210 Revision 0.2 2006/07/14 15:37:46 phu
211 - include PIER settings for External Bus operation
212 Revision 0.3 2006/07/14 15:37:46 phu
214 - correct PIER settings for HRQ and RDY signals
215 Revision 0.4 2006/08/07 15:35:35 phu
216 - change default clock setting to PLLx4 for CLKS1, CLKS2
217 - correct clock setting
218 - disable Flash Security by default for Main Flash, Satellite Flash
219 - disable availability of Satellite Flash by default
221 ;====================================================================
223 ;====================================================================
225 ;====================================================================
227 ; CHECK ALL OPTIONS WHETHER THEY FIT TO THE APPLICATION
229 ; Configure this startup file in the "Settings" section. Search for
230 ; comments with leading "; <<<". This points to the items to be set.
231 ;====================================================================
235 ;====================================================================
236 ; 4.1 Controller Series, Device
237 ;====================================================================
248 #set SERIES MB96350 ; <<< select Series
251 ; Please specify the device according to the following selection;
253 ; Note: Do not change order because of device number dependency in
254 ; 6.5 Clock settings, 5.9 Debug address specification,
255 ; and 6.11 ICU register initialization workaround!
323 #set DEVICE MB96356RxA ; <<< select device
325 ;====================================================================
326 ; 4.2 C-language Memory model
327 ;====================================================================
330 #set SMALL 0 ; 16 Bit 16 Bit
331 #set MEDIUM 1 ; 16 Bit 24 Bit
332 #set COMPACT 2 ; 24 Bit 16 Bit
333 #set LARGE 3 ; 24 Bit 24 Bit
334 #set AUTOMODEL 4 ; works always, might occupy two
338 #set MEMMODEL AUTOMODEL ; <<< C-memory model
340 ; The selected memory model should be set in order to fit to the
341 ; model selected for the compiler.
342 ; Note, in this startup version AUTOMODEL will work for all
343 ; C-models. However, if the compiler is configured for SMALL or
344 ; COMPACT, two additional bytes on stack are occupied. If this is not
345 ; acceptable, the above setting should be set to the correct model.
347 ;====================================================================
348 ; 4.3 Function-Call Interface
349 ;====================================================================
355 ; Above statement informs Assembler on compatibility of start-up code
356 ; to Function Call Interface as selected for the application. There
357 ; is nothing to configure.
358 ; The Function-Call Interface specifies the method of passing parame-
359 ; ter from function caller to callee. The standard method of FCC907S
360 ; compiler uses "stack argument passing". Alternatively, language
361 ; tools can be configured for "register argument passing".
362 ; For details see the compiler manual.
363 ; This start-up file is compatible to both interfaces.
365 ;====================================================================
366 ; 4.4 Constant Data Handling
367 ;====================================================================
369 #set ROMCONST 0 ; works only with compiler ROMCONST
370 #set RAMCONST 1 ; works with BOTH compiler settings
371 #set AUTOCONST RAMCONST ; works with BOTH compiler settings
373 #set CONSTDATA AUTOCONST ; <<< set RAM/ROM/AUTOCONST
375 ; - AUTOCONST (default) is the same as RAMCONST
376 ; - RAMCONST/AUTOCONST should always work, even if compiler is set to
377 ; ROMCONST. If compiler is set to ROMCONST and this startup file is
378 ; set to RAMCONST or AUTOCONST, this startup file will generate an
379 ; empty section CINIT in RAM. However, the code, which copies from
380 ; CONST to CINIT will not have any effect, because size of section is 0.
381 ; - It is highly recommended to set the compiler to ROMCONST for
382 ; single-chip mode or internal ROM+ext bus. The start-up file
383 ; should be set to AUTOCONST.
384 ; - ROMCONST setting on systems with full external bus requires exter-
385 ; nal address mapping.
386 ; Single-chip can be emulated by the emulator debugger.
387 ; ROM mirror can also be used with simulator.
389 ; see also ROM MIRROR options
391 ;====================================================================
392 ; 4.5 Stack Type and Stack Size
393 ;====================================================================
395 #set USRSTACK 0 ; user stack: for main program
396 #set SYSSTACK 1 ; system stack: for main program and interrupts
398 #set STACKUSE SYSSTACK ; <<< set active stack
400 #set STACK_RESERVE ON ; <<< reserve stack area in this module
401 #set STACK_SYS_SIZE 200 ; <<< byte size of System stack
402 #set STACK_USR_SIZE 2 ; <<< byte size of User stack
404 #set STACK_FILL ON ; <<< fills the stack area with pattern
405 #set STACK_PATTERN 0x55AA ; <<< the pattern to write to stack
407 ; - If the active stack is set to SYSSTACK, it is used for main program
408 ; and interrupts. In this case, the user stack can be set to a dummy
410 ; If the active stack is set to user stack, it is used for the main
411 ; program but the system stack is automatically activated, if an inter-
412 ; rupt is serviced. Both stack areas must have a reasonable size.
413 ; - If STACK_RESERVE is ON, the sections USTACK and SSTACK are reserved
414 ; in this module. Otherwise, they have to be reserved in other modules.
415 ; If STACK_RESERVE is OFF, the size definitions STACK_SYS_SIZE and
416 ; STACK_USR_SIZE have no meaning.
417 ; - Even if they are reserved in other modules, they are still initialised
418 ; in this start-up file.
419 ; - Filling the stack with a pattern allows to dynamically check the stack
420 ; area, which had already been used.
422 ; - If only system stack is used and SSB is linked to a different bank
423 ; than USB, make sure that all C-modules (which generate far pointers
424 ; to stack data) have "#pragma SSB". Applies only to exclusive confi-
426 ; - Note, several library functions require quite a big stack (due to
427 ; ANSI). Check the stack information files (*.stk) in the LIB\907
430 ;====================================================================
431 ; 4.6 General Register Bank
432 ;====================================================================
434 #set REGBANK 0 ; <<< set default register bank
436 ; set the General Register Bank that is to be used after startup.
437 ; Usually, this is bank 0, which applies to address H'180..H'18F. Set
438 ; in the range from 0 to 31.
439 ; Note: All used register banks have to be reserved (linker options).
441 #if REGBANK > 31 || REGBANK < 0
442 # error REGBANK setting out of range
445 ;====================================================================
446 ; 4.7 Low-Level Library Interface
447 ;====================================================================
449 #set CLIBINIT OFF ; <<< select extended library usage
451 ; This option has only to be set, if stream-IO/standard-IO function of
452 ; the C-library have to be used (printf(), fopen()...). This also
453 ; requires low-level functions to be defined by the application
455 ; For other library functions (like e.g. sprintf()) all this is not
456 ; necessary. However, several functions consume a large amount of stack.
458 ;====================================================================
459 ; 4.8 Clock Selection
460 ;====================================================================
462 ; The clock selection requires that a 4 MHz external clock is provided
463 ; as the Main Clock. If a different frequency is used, the Flash Memory
464 ; Timing settings must be checked!
466 #set CLOCKWAIT ON ; <<< wait for stabilized clock, if
467 ; Main Clock or PLL is used
469 ; The clock is set quite early. However, if CLOCKWAIT is ON, polling
470 ; for machine clock to be switched to Main Clock or PLL is done at
471 ; the end of this file. Therefore, the stabilization time is not
472 ; wasted. Main() will finally start at correct speed. Resources can
473 ; be used immediately.
474 ; Note: Some frequency settings (below) necessarily need a stabilized
475 ; PLL for final settings. In these cases, the CLOCKWAIT setting above
476 ; does not have any effect.
478 ; This startup file version does not support subclock.
480 #set FREQ_4MHZ D'4000000L
481 #set FREQ_8MHZ D'8000000L
483 #set CRYSTAL FREQ_4MHZ ; <<< select external crystal frequency
485 #set CPU_4MHZ_MAIN_CLKP2_4MHZ 0x0004
486 #set CPU_4MHZ_PLL_CLKP2_4MHZ 0x0104
487 #set CPU_8MHZ_CLKP2_8MHZ 0x0108
488 #set CPU_12MHZ_CLKP2_12MHZ 0x010C
489 #set CPU_16MHZ_CLKP2_16MHZ 0x0110
490 #set CPU_24MHZ_CLKP2_12MHZ 0x0118
491 #set CPU_32MHZ_CLKP2_16MHZ 0x0120
492 #set CPU_32MHZ_CLKP1_16MHZ_CLKP2_16MHZ 0x0220
493 #set CPU_48MHZ_CLKP2_16MHZ 0x0130
494 #set CPU_48MHZ_CLKP1_32MHZ_CLKP2_16MHZ 0x0230
495 #set CPU_56MHZ_CLKP2_14MHZ 0x0138
497 #set CLOCK_SPEED CPU_56MHZ_CLKP2_14MHZ ; <<< set clock speeds
499 ; The peripheral clock CLKP1 is set to the same frequency than the CPU.
500 ; The peripheral clock CLKP2 has its setting. This is because it
501 ; feeds only the CAN controllers and Sound Generators. These do not
502 ; need high frequency clocks.
504 ;====================================================================
505 ; 4.9 Clock Stabilization Time
506 ;====================================================================
508 #set MC_2_10_CYCLES 0
509 #set MC_2_12_CYCLES 1
510 #set MC_2_13_CYCLES 2
511 #set MC_2_14_CYCLES 3
512 #set MC_2_15_CYCLES 4
513 #set MC_2_16_CYCLES 5
514 #set MC_2_17_CYCLES 6
515 #set MC_2_18_CYCLES 7
517 #set MC_STAB_TIME MC_2_15_CYCLES ; <<< select Main Clock Stabilization Time
519 ;====================================================================
520 ; 4.10 External Bus Interface
521 ;====================================================================
523 #set SINGLE_CHIP 0 ; all internal
524 #set INTROM_EXTBUS 1 ; mask ROM or FLASH memory used
525 #set EXTROM_EXTBUS 2 ; full external bus (INROM not used)
527 #set BUSMODE SINGLE_CHIP ; <<< set bus mode (see mode pins)
530 #set NON_MULTIPLEXED 1 ; only if supported by the device
532 #set ADDRESSMODE MULTIPLEXED ; <<< set address-mode
534 ; Some devices support multiplexed and/or non-multiplexed Bus mode
535 ; please refer to the related datasheet/hardwaremanual
538 ; If BUSMODE is "SINGLE_CHIP", ignore remaining bus settings.
540 ; Select the used Chip Select areas
541 #set CHIP_SELECT0 OFF ; <<< enable chip select area
542 #set CHIP_SELECT1 OFF ; <<< enable chip select area
543 #set CHIP_SELECT2 OFF ; <<< enable chip select area
544 #set CHIP_SELECT3 OFF ; <<< enable chip select area
545 #set CHIP_SELECT4 OFF ; <<< enable chip select area
546 #set CHIP_SELECT5 OFF ; <<< enable chip select area
548 #set HOLD_REQ OFF ; <<< select Hold function
549 #set EXT_READY OFF ; <<< select external Ready function
550 #set EXT_CLOCK_ENABLE OFF ; <<< select external bus clock output
551 #set EXT_CLOCK_INVERT OFF ; <<< select clock inversion
552 #set EXT_CLOCK_SUSPEND OFF ; <<< select if external clock is suspended when no transfer in progress
554 ; The external bus clock is derived from core clock CLKB. Select the divider for the external bus clock.
556 #set EXT_CLOCK_DIV1 0
557 #set EXT_CLOCK_DIV2 1
558 #set EXT_CLOCK_DIV4 2
559 #set EXT_CLOCK_DIV8 3
560 #set EXT_CLOCK_DIV16 4
561 #set EXT_CLOCK_DIV32 5
562 #set EXT_CLOCK_DIV64 6
563 #set EXT_CLOCK_DIV128 7
565 #set EXT_CLOCK_DIVISION EXT_CLOCK_DIV1 ; <<< select clock divider
567 #set ADDR_PINS_23_16 B'00000000 ; <<< select used address lines
568 ; A23..A16 to be output.
569 #set ADDR_PINS_15_8 B'00000000 ; <<< select used address lines
570 ; A15..A8 to be output.
571 #set ADDR_PINS_7_0 B'00000000 ; <<< select used address lines
572 ; A7..A0 to be output.
574 #set LOW_BYTE_SIGNAL OFF ; <<< select low byte signal LBX
575 #set HIGH_BYTE_SIGNAL OFF ; <<< select high byte signal UBX
576 #set LOW_WRITE_STROBE OFF ; <<< select write strobe signal WRLX/WRX
577 #set HIGH_WRITE_STROBE OFF ; <<< select write strobe signal WRHX
578 #set READ_STROBE OFF ; <<< select read strobe signal RDX
579 #set ADDRESS_STROBE OFF ; <<< select address strobe signal ALE/ASX
580 #set ADDRESS_STROBE_LVL OFF ; <<< select address strobe function: OFF - active low; ON - active high
583 #set CS0_CONFIG B'0000000000000000 ; <<< select Chip Select Area 0 configuration
584 ; |||||||||||||+++-- Automatic wait cycles (0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 8, 6: 16, 7: 32)
585 ; ||||||||||||+----- Address Cycle Extension (0: not extended, 1: extension by 1 cycle)
586 ; |||||||||||+------ Strobe timing (0: scheme 0, 1: scheme 1)
587 ; ||||||||||+------- Write strobe function (0: WRLX strobe, 1: WRX strobe)
588 ; |||||||||+-------- Endianess (0: little endian, 1: big endian)
589 ; ||||||||+--------- Bus width (0: 16bit, 1: 8bit)
590 ; |||||+++---------- ignored
591 ; ||||+------------- Chip Select output enable (0: CS disabled, 1: CS enabled)
592 ; |||+-------------- Chip Select level (0: low active, 1: high active)
593 ; ||+--------------- Access type limitation (0: code and data, 1: data only)
594 ; ++---------------- ignored
596 #set CS1_CONFIG B'0000000000000000 ; <<< select Chip Select Area 1 configuration
597 ; |||||||||||||+++-- Automatic wait cycles (0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 8, 6: 16, 7: 32)
598 ; ||||||||||||+----- Address Cycle Extension (0: not extended, 1: extension by 1 cycle)
599 ; |||||||||||+------ Strobe timing (0: scheme 0, 1: scheme 1)
600 ; ||||||||||+------- Write strobe function (0: WRLX strobe, 1: WRX strobe)
601 ; |||||||||+-------- Endianess (0: little endian, 1: big endian)
602 ; ||||||||+--------- Bus width (0: 16bit, 1: 8bit)
603 ; |||||+++---------- ignored
604 ; ||||+------------- Chip Select output enable (0: CS disabled, 1: CS enabled)
605 ; |||+-------------- Chip Select level (0: low active, 1: high active)
606 ; ||+--------------- Access type limitation (0: code and data, 1: data only)
607 ; ++---------------- ignored
609 #set CS2_CONFIG B'0000011000000000 ; <<< select Chip Select Area 2 configuration
610 ; |||||||||||||+++-- Automatic wait cycles (0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 8, 6: 16, 7: 32)
611 ; ||||||||||||+----- Address Cycle Extension (0: not extended, 1: extension by 1 cycle)
612 ; |||||||||||+------ Strobe timing (0: scheme 0, 1: scheme 1)
613 ; ||||||||||+------- Write strobe function (0: WRLX strobe, 1: WRX strobe)
614 ; |||||||||+-------- Endianess (0: little endian, 1: big endian)
615 ; ||||||||+--------- Bus width (0: 16bit, 1: 8bit)
616 ; |||||+++---------- External area size (0: 64kB, 1: 128kB, 2: 256kB, 3: 512kB, 4: 1MB, 5: 2MB, 6: 4MB, 7: 8MB)
617 ; ||||+------------- Chip Select output enable (0: CS disabled, 1: CS enabled)
618 ; |||+-------------- Chip Select level (0: low active, 1: high active)
619 ; ||+--------------- Access type limitation (0: code and data, 1: data only)
620 ; ++---------------- ignored
622 #set CS3_CONFIG B'0000011000000000 ; <<< select Chip Select Area 3 configuration
623 ; |||||||||||||+++-- Automatic wait cycles (0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 8, 6: 16, 7: 32)
624 ; ||||||||||||+----- Address Cycle Extension (0: not extended, 1: extension by 1 cycle)
625 ; |||||||||||+------ Strobe timing (0: scheme 0, 1: scheme 1)
626 ; ||||||||||+------- Write strobe function (0: WRLX strobe, 1: WRX strobe)
627 ; |||||||||+-------- Endianess (0: little endian, 1: big endian)
628 ; ||||||||+--------- Bus width (0: 16bit, 1: 8bit)
629 ; |||||+++---------- External area size (0: 64kB, 1: 128kB, 2: 256kB, 3: 512kB, 4: 1MB, 5: 2MB, 6: 4MB, 7: 8MB)
630 ; ||||+------------- Chip Select output enable (0: CS disabled, 1: CS enabled)
631 ; |||+-------------- Chip Select level (0: low active, 1: high active)
632 ; ||+--------------- Access type limitation (0: code and data, 1: data only)
633 ; ++---------------- ignored
635 #set CS4_CONFIG B'0000011000000000 ; <<< select Chip Select Area 4 configuration
636 ; |||||||||||||+++-- Automatic wait cycles (0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 8, 6: 16, 7: 32)
637 ; ||||||||||||+----- Address Cycle Extension (0: not extended, 1: extension by 1 cycle)
638 ; |||||||||||+------ Strobe timing (0: scheme 0, 1: scheme 1)
639 ; ||||||||||+------- Write strobe function (0: WRLX strobe, 1: WRX strobe)
640 ; |||||||||+-------- Endianess (0: little endian, 1: big endian)
641 ; ||||||||+--------- Bus width (0: 16bit, 1: 8bit)
642 ; |||||+++---------- External area size (0: 64kB, 1: 128kB, 2: 256kB, 3: 512kB, 4: 1MB, 5: 2MB, 6: 4MB, 7: 8MB)
643 ; ||||+------------- Chip Select output enable (0: CS disabled, 1: CS enabled)
644 ; |||+-------------- Chip Select level (0: low active, 1: high active)
645 ; ||+--------------- Access type limitation (0: code and data, 1: data only)
646 ; ++---------------- ignored
648 #set CS5_CONFIG B'0000011000000000 ; <<< select Chip Select Area 5 configuration
649 ; |||||||||||||+++-- Automatic wait cycles (0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 8, 6: 16, 7: 32)
650 ; ||||||||||||+----- Address Cycle Extension (0: not extended, 1: extension by 1 cycle)
651 ; |||||||||||+------ Strobe timing (0: scheme 0, 1: scheme 1)
652 ; ||||||||||+------- Write strobe function (0: WRLX strobe, 1: WRX strobe)
653 ; |||||||||+-------- Endianess (0: little endian, 1: big endian)
654 ; ||||||||+--------- Bus width (0: 16bit, 1: 8bit)
655 ; |||||+++---------- External area size (0: 64kB, 1: 128kB, 2: 256kB, 3: 512kB, 4: 1MB, 5: 2MB, 6: 4MB, 7: 8MB)
656 ; ||||+------------- Chip Select output enable (0: CS disabled, 1: CS enabled)
657 ; |||+-------------- Chip Select level (0: low active, 1: high active)
658 ; ||+--------------- Access type limitation (0: code and data, 1: data only)
659 ; ++---------------- ignored
662 #set CS2_START 0x00 ; <<< select start bank of chip select area; valid values: 0x00..0xFF
663 #set CS3_START 0x40 ; <<< select start bank of chip select area; valid values: 0x00..0xFF
664 #set CS4_START 0x80 ; <<< select start bank of chip select area; valid values: 0x00..0xFF
665 #set CS5_START 0xC0 ; <<< select start bank of chip select area; valid values: 0x00..0xFF
668 ;====================================================================
669 ; 4.11 ROM Mirror configuration
670 ;====================================================================
677 #set ROMMIRROR ON ; <<< ROM mirror function ON/OFF
678 #set MIRROR_BANK 0xF ; <<< ROM Mirror bank, allowed entries: 0x0..0xF for the banks 0xF0..0xFF
679 #set MIRROR_SIZE MIRROR_32KB ; <<< ROM Mirror size
681 ; One can select which ROM area to mirror into the upper half of bank 00.
682 ; If ROMMIRROR = OFF is selected, the address range 0x008000..0x00FFFF
683 ; shows the contents of the respective area of bank 1: 0x018000..0x01FFFF.
684 ; If ROMMIRROR = ON is selected, the memory bank to mirror can be selected.
685 ; Available banks are 0xF0 to 0xFF. Furthermore, the ROM Mirror area size can
686 ; be selected. 4 sizes are available: 8 kB, 16 kB, 24 kB, or 32 kB. The ROM Mirror
687 ; from the highest address of the selected bank downwards, e.g. if bank 0xFF and
688 ; mirror size 24 kB is selected, the memory range 0xFFA000..0xFFFFFF is mirrored
689 ; to address range 0x00A000..0x00FFFF. The memory area not selected for
690 ; ROM Mirror is still mirrored from bank 0x01.
691 ; This is necessary to get the compiler ROMCONST option working. This is intended
692 ; to increase performance, if a lot of dynamic data have to be accessed.
693 ; In SMALL and MEDIUM model these data can be accessed within bank 0,
694 ; which allows to use near addressing. Please make sure to have the linker
695 ; setting adjusted accordingly!
698 ;====================================================================
699 ; 4.12 Flash Security
700 ;====================================================================
702 #set FLASH_A_SECURITY_ENABLE OFF ; <<< enable Flash Security for Flash A (old "Main Flash")
703 #set FLASH_B_AVAILABLE OFF ; <<< select if Flash B is available
704 #set FLASH_B_SECURITY_ENABLE OFF ; <<< enable Flash Security for Flash B (old "Satellite Flash")
706 ; set the Flash Security unlock key (16 bytes)
707 ; all 0: unlock not possible
708 #set FLASH_A_UNLOCK_0 0x00
709 #set FLASH_A_UNLOCK_1 0x00
710 #set FLASH_A_UNLOCK_2 0x00
711 #set FLASH_A_UNLOCK_3 0x00
712 #set FLASH_A_UNLOCK_4 0x00
713 #set FLASH_A_UNLOCK_5 0x00
714 #set FLASH_A_UNLOCK_6 0x00
715 #set FLASH_A_UNLOCK_7 0x00
716 #set FLASH_A_UNLOCK_8 0x00
717 #set FLASH_A_UNLOCK_9 0x00
718 #set FLASH_A_UNLOCK_10 0x00
719 #set FLASH_A_UNLOCK_11 0x00
720 #set FLASH_A_UNLOCK_12 0x00
721 #set FLASH_A_UNLOCK_13 0x00
722 #set FLASH_A_UNLOCK_14 0x00
723 #set FLASH_A_UNLOCK_15 0x00
725 #set FLASH_B_UNLOCK_0 0x00
726 #set FLASH_B_UNLOCK_1 0x00
727 #set FLASH_B_UNLOCK_2 0x00
728 #set FLASH_B_UNLOCK_3 0x00
729 #set FLASH_B_UNLOCK_4 0x00
730 #set FLASH_B_UNLOCK_5 0x00
731 #set FLASH_B_UNLOCK_6 0x00
732 #set FLASH_B_UNLOCK_7 0x00
733 #set FLASH_B_UNLOCK_8 0x00
734 #set FLASH_B_UNLOCK_9 0x00
735 #set FLASH_B_UNLOCK_10 0x00
736 #set FLASH_B_UNLOCK_11 0x00
737 #set FLASH_B_UNLOCK_12 0x00
738 #set FLASH_B_UNLOCK_13 0x00
739 #set FLASH_B_UNLOCK_14 0x00
740 #set FLASH_B_UNLOCK_15 0x00
743 ;====================================================================
744 ; 4.13 Flash Write Protection
745 ;====================================================================
747 #set FLASH_A_WRITE_PROTECT OFF ; <<< select Flash A write protection
748 #set PROTECT_SECTOR_SA0 OFF ; <<< select individual sector to protect
749 #set PROTECT_SECTOR_SA1 OFF ; <<< select individual sector to protect
750 #set PROTECT_SECTOR_SA2 OFF ; <<< select individual sector to protect
751 #set PROTECT_SECTOR_SA3 OFF ; <<< select individual sector to protect
752 #set PROTECT_SECTOR_SA32 OFF ; <<< select individual sector to protect
753 #set PROTECT_SECTOR_SA33 OFF ; <<< select individual sector to protect
754 #set PROTECT_SECTOR_SA34 OFF ; <<< select individual sector to protect
755 #set PROTECT_SECTOR_SA35 OFF ; <<< select individual sector to protect
756 #set PROTECT_SECTOR_SA36 OFF ; <<< select individual sector to protect
757 #set PROTECT_SECTOR_SA37 OFF ; <<< select individual sector to protect
758 #set PROTECT_SECTOR_SA38 OFF ; <<< select individual sector to protect
759 #set PROTECT_SECTOR_SA39 OFF ; <<< select individual sector to protect
761 #set FLASH_B_WRITE_PROTECT OFF ; <<< select Flash write protection
762 #set PROTECT_SECTOR_SB0 OFF ; <<< select individual sector to protect
763 #set PROTECT_SECTOR_SB1 OFF ; <<< select individual sector to protect
764 #set PROTECT_SECTOR_SB2 OFF ; <<< select individual sector to protect
765 #set PROTECT_SECTOR_SB3 OFF ; <<< select individual sector to protect
768 ;====================================================================
770 ;====================================================================
772 #set BOOT_VECTOR_TABLE 1 ; enable boot vector
773 #set BOOT_VECTOR_FIXED 2 ; enable boot vector
775 #set BOOT_VECTOR BOOT_VECTOR_TABLE ; <<< select type of boot vector
777 ; If boot vector generation is enabled (BOOT_VECTOR_TABLE, BOOT_VECTOR_FIXED),
778 ; appropriate code is generated. If it is disabled (OFF), start-up file does
781 ; BOOT_VECTOR_TABLE: - Create table entry at address oxFFFFDC.
782 ; - Any start address can be set and start-up file will
783 ; set address of this start code.
784 ; BOOT_VECTOR_FIXED: - Instead of table entry, a special marker is set in
785 ; ROM Configuration Block, which enables the fixed
786 ; start address 0xDF0080. This is prefered setting
787 ; for user boot loaders.
788 ; OFF: - Do not set table entry and marker. This might be used
789 ; for application to be loaded by boot loader.
792 ; BOOT_VECTOR_TABLE setting can also be used, if all other interrupt vectors
793 ; are specified via "pragma intvect". Only if interrupts 0..7 are specified
794 ; via "pragma intvect", these will conflict with the vector in this module.
795 ; The reason is the INTVECT section, which includes the whole area from the
796 ; lowest to the highest specified vector.
798 #if BOOT_VECTOR == BOOT_VECTOR_TABLE
799 .SECTION RESVECT, CONST, LOCATE=H'FFFFDC
801 .SECTION BOOT_SELECT, CONST, LOCATE=H'DF0030
805 # if BOOT_VECTOR == BOOT_VECTOR_FIXED
806 .SECTION BOOT_SELECT, CONST, LOCATE=H'DF0030
807 .DATA.L 0x292D3A7B ; "Magic Word"
809 .SECTION BOOT_SELECT, CONST, LOCATE=H'DF0030
814 ;====================================================================
816 ;====================================================================
818 #set UART_SCANNING OFF ; <<< enable UART scanning in
819 ; Internal Vector Mode
821 ; By default, the MCU scans in Internal Vector Mode for a UART
822 ; communication after reset. This enables to establish a serial
823 ; communication without switching to Serial Communication Mode.
824 ; For the final application, set this switch to OFF to achieve the
825 ; fastest start-up time.
827 #if UART_SCANNING == ON
828 # if ((SERIES == MB96340) && (DEVICE < 3))
829 # error Device does not support UART scanning on/off
831 .SECTION UART_SCAN_SELECT, CONST, LOCATE=H'DF0034
833 # endif ; (SERIES == MB96340 && DEVICE < 3)
835 .SECTION UART_SCAN_SELECT, CONST, LOCATE=H'DF0034
836 .DATA.L 0x292D3A7B ; Decativation "Magic Word"
841 ;====================================================================
842 ; 4.16 Enable RAMCODE Copying
843 ;====================================================================
845 #set COPY_RAMCODE OFF ; <<< enable RAMCODE section to
846 ; be copied from ROM to RAM
848 ; To get this option properly working the code to be executed has to
849 ; be linked to section RAMCODE (e.g. by #pragma section). The section
850 ; RAMCODE has be located in RAM and the section @RAMCODE has to be
851 ; located at a fixed address in ROM by linker settings.
853 ;====================================================================
854 ; 4.17 Enable information stamp in ROM
855 ;====================================================================
857 #set VERSION_STAMP OFF ; <<< enable version number in
861 #if VERSION_STAMP == ON
862 .SECTION VERSIONS, CONST ; change name, if necessary
863 .SDATA "Start ", VERSION, "\n\0"
866 ;====================================================================
867 ; 4.18 Enable Background Debugging Mode
868 ;====================================================================
870 #set BACKGROUND_DEBUGGING ON ; <<< enable Background Debugging
873 #set BDM_CONFIGURATION B'0000000000010011 ; <<< set BDM configuration
874 ; ||||||||++--- BdmUART
875 ; |||||||| (0: A, 1: B, 2: C, 3: D)
876 ; ||||||++----- BdmSynchMode
877 ; |||||| (0: Async., 1: Sync.
878 ; |||||| 2: BdmKLine, 3: res.)
879 ; |||||+------- BdmAutoStart
880 ; ||||+-------- BdmExtBreakpointCfg
881 ; |||+--------- BdmKeepRClock
882 ; ||+---------- BdmCaliRClock
883 ; |+----------- BdmKeepBCD
884 ; +------------ BdmUserKernel
886 #set BDM_BAUDRATE 115200 ; <<< set Baudrate in Bits/s for BDM
888 #set BDM_EXT_CONFIG 0xFFFFFF ; <<< set external Config/Kernel
890 #set BDM_WD_PATTERN 0x00 ; <<< set watchdog pattern
892 #set BDM_PFCS0 0x0000 ; <<< set default breakpoint
893 #set BDM_PFCS1 0x0000 ; configurations
894 #set BDM_PFCS2 0x0000
895 #set BDM_PFCS3 0x0000
897 #set BDM_PFA0 0xFFFFFF ; <<< set address
898 #set BDM_PFA1 0xFFFFFF ; configurations
899 #set BDM_PFA2 0xFFFFFF
900 #set BDM_PFA3 0xFFFFFF
901 #set BDM_PFA4 0xFFFFFF
902 #set BDM_PFA5 0xFFFFFF
903 #set BDM_PFA6 0xFFFFFF
904 #set BDM_PFA7 0xFFFFFF
906 #set BDM_PFD0 0xFFFF ; <<< set patch data
907 #set BDM_PFD1 0xFFFF ; configurations
916 ; <<< END OF SETTINGS >>>
918 ;====================================================================
919 ; 5 Section and Data Declaration
920 ;====================================================================
922 ;====================================================================
923 ; 5.1 Several fixed addresses (fixed for MB963xx controllers)
924 ;====================================================================
926 MCSRA .EQU 0x03F1 ; Flash A Memory configuration register
927 MTCRA .EQU 0x03F2 ; Flash A Memory timing register
928 MCSRB .EQU 0x03F5 ; Flash B Memory configuration register
929 MTCRB .EQU 0x03F6 ; Flash B Memory timing register
930 ROMM .EQU 0x03AE ; ROM mirror control register
931 CKSR .EQU 0x0401 ; Clock select control register
932 CKSSR .EQU 0x0402 ; Clock stabilization select register
933 CKMR .EQU 0x0403 ; Clock monitor register
934 CKFCR .EQU 0x0404 ; Clock frequency control register
935 PLLCR .EQU 0x0406 ; PLL control register
936 VRCR .EQU 0x042C ; Voltage Regulator Control register
937 ICE01 .EQU 0x0041 ; Input capture 0/1 source
938 ICE67 .EQU 0x0053 ; Input capture 6/7 source
939 ICE89 .EQU 0x0515 ; Input capture 8/9 source
940 ICE1011 .EQU 0x051B ; Input capture 10/11 source
941 ICS89 .EQU 0x0514 ; Input capture 8/9 edge select
942 ICS1011 .EQU 0x051A ; Input capture 10/11 edge select
943 TCCSL2 .EQU 0x0502 ; Free running timer 2 control/status register
944 TCCSL3 .EQU 0x0506 ; Free running timer 3 control/status register
945 #if BUSMODE != SINGLE_CHIP ; only for devices with external bus
973 #endif ; BUSMODE != SINGLE_CHIP
975 ;====================================================================
976 ; 5.2 Declaration of __near addressed data sections
977 ;====================================================================
979 ; sections to be cleared
980 .SECTION DATA, DATA, ALIGN=2 ; zero clear area
981 .SECTION DATA2, DATA, ALIGN=2 ; zero clear area
982 .SECTION DIRDATA, DIR, ALIGN=2 ; zero clear direct
983 .SECTION LIBDATA, DATA, ALIGN=2 ; zero clear lib area
985 ; sections to be initialised with start-up values
986 .SECTION INIT, DATA, ALIGN=2 ; initialised area
987 .SECTION INIT2, DATA, ALIGN=2 ; initialised area
988 .SECTION DIRINIT, DIR, ALIGN=2 ; initialised dir
989 .SECTION LIBINIT, DATA, ALIGN=2 ; initialised lib area
990 #if CONSTDATA == RAMCONST
991 .SECTION CINIT, DATA, ALIGN=2 ; initialised const
992 .SECTION CINIT2, DATA, ALIGN=2 ; initialised const
995 ; sections containing start-up values for initialised sections above
996 .SECTION DCONST, CONST, ALIGN=2 ; DINIT initialisers
997 .SECTION DIRCONST, DIRCONST,ALIGN=2 ; DIRINIT initialisers
998 .SECTION LIBDCONST, CONST, ALIGN=2 ; LIBDCONST init val
1000 ; following section is either copied to CINIT (RAMCONST) or
1001 ; mapped by ROM-mirror function (ROMCONST)
1002 .SECTION CONST, CONST, ALIGN=2 ; CINIT initialisers
1003 .SECTION CONST2, CONST, ALIGN=2 ; CINIT initialisers
1005 ;====================================================================
1006 ; 5.3 Declaration of RAMCODE section and labels
1007 ;====================================================================
1009 #if COPY_RAMCODE == ON
1010 .SECTION RAMCODE, CODE, ALIGN=1
1011 .IMPORT _RAM_RAMCODE ; provided by linker
1012 .IMPORT _ROM_RAMCODE ; provided by linker
1016 ;====================================================================
1017 ; 5.4 Declaration of sections containing other sections description
1018 ;====================================================================
1020 ; DCLEAR contains start address and size of all sections to be cleared
1021 ; DTRANS contains source and destination address and size of all
1022 ; sections to be initialised with start-up values
1023 ; The compiler automatically adds a descriptor for each __far addressed
1024 ; data section to DCLEAR or DTRANS. These __far sections are separated
1025 ; for each C-module.
1027 ; In addition the start-up file adds the descriptors of the previously
1028 ; declared __near section here. This way the same code in the start-up
1029 ; file can be used for initialising all sections.
1031 .SECTION DCLEAR, CONST, ALIGN=2 ; zero clear table
1033 .DATA.H DATA, BNKSEC DATA, SIZEOF(DATA )
1034 .DATA.H DIRDATA, BNKSEC DIRDATA, SIZEOF(DIRDATA)
1035 .DATA.H LIBDATA, BNKSEC LIBDATA, SIZEOF(LIBDATA)
1037 .SECTION DTRANS, CONST, ALIGN=2 ; copy table
1038 ; Address Bank Address Bank Size
1039 .DATA.H DCONST, BNKSEC DCONST, INIT, BNKSEC INIT, SIZEOF INIT
1040 .DATA.H DIRCONST, BNKSEC DIRCONST, DIRINIT,BNKSEC DIRINIT,SIZEOF DIRINIT
1041 .DATA.H LIBDCONST,BNKSEC LIBDCONST,LIBINIT,BNKSEC LIBINIT,SIZEOF LIBINIT
1043 #if CONSTDATA == RAMCONST
1044 .DATA.H CONST, BNKSEC CONST, CINIT, BNKSEC CINIT, SIZEOF CINIT
1045 .DATA.H CONST2, BNKSEC CONST, CINIT2, BNKSEC CINIT2, SIZEOF CINIT2
1048 #if COPY_RAMCODE == ON
1049 .DATA.L _ROM_RAMCODE, _RAM_RAMCODE
1050 .DATA.H SIZEOF RAMCODE
1053 ;====================================================================
1054 ; 5.5 Stack area and stack top definition/declaration
1055 ;====================================================================
1056 #if STACK_RESERVE == ON
1057 .SECTION SSTACK, STACK, ALIGN=2
1059 .EXPORT __systemstack, __systemstack_top
1061 .RES.B (STACK_SYS_SIZE + 1) & 0xFFFE
1065 .SECTION USTACK, STACK, ALIGN=2
1067 .EXPORT __userstack, __userstack_top
1069 .RES.B (STACK_USR_SIZE + 1) & 0xFFFE
1074 .SECTION SSTACK, STACK, ALIGN=2
1075 .SECTION USTACK, STACK, ALIGN=2
1077 .IMPORT __systemstack, __systemstack_top
1078 .IMPORT __userstack, __userstack_top
1081 ;====================================================================
1082 ; 5.6 Direct page register dummy label definition
1083 ;====================================================================
1085 .SECTION DIRDATA ; zero clear direct
1086 DIRDATA_S: ; label for DPR init
1088 ; This label is used to get the page of the __direct data.
1089 ; Depending on the linkage order of this startup file the label is
1090 ; placed anywhere within the __direct data page. However, the
1091 ; statement "PAGE (DIRDATA_S)" is processed. Therefore, the lower
1092 ; 8 Bit of the address of DIRDATA_S are not relevant and this feature
1093 ; becomes linkage order independent.
1094 ; Note, the linker settings have to make sure that all __direct
1095 ; data are located within the same physical page (256 Byte block).
1097 ;====================================================================
1098 ; 5.7 Set Flash Security
1099 ;====================================================================
1101 .SECTION FLASH_A_SECURITY, CONST, LOCATE=H'DF0000
1102 #if FLASH_A_SECURITY_ENABLE == 0
1103 .DATA.W 0xFFFF ; Security DISABLED
1105 #else FLASH_A_SECURITY_ENABLE == 1
1106 .DATA.W 0x0099 ; Security ENABLED
1107 .DATA.W ((FLASH_A_UNLOCK_1 << 8) | FLASH_A_UNLOCK_0)
1108 .DATA.W ((FLASH_A_UNLOCK_3 << 8) | FLASH_A_UNLOCK_2)
1109 .DATA.W ((FLASH_A_UNLOCK_5 << 8) | FLASH_A_UNLOCK_4)
1110 .DATA.W ((FLASH_A_UNLOCK_7 << 8) | FLASH_A_UNLOCK_6)
1111 .DATA.W ((FLASH_A_UNLOCK_9 << 8) | FLASH_A_UNLOCK_8)
1112 .DATA.W ((FLASH_A_UNLOCK_11 << 8) | FLASH_A_UNLOCK_10)
1113 .DATA.W ((FLASH_A_UNLOCK_13 << 8) | FLASH_A_UNLOCK_12)
1114 .DATA.W ((FLASH_A_UNLOCK_15 << 8) | FLASH_A_UNLOCK_14)
1119 #if FLASH_B_AVAILABLE == ON
1120 .SECTION FLASH_B_SECURITY, CONST, LOCATE=H'DE0000
1121 # if FLASH_B_SECURITY_ENABLE == 0
1122 .DATA.W 0xFFFF ; Security DISABLED
1124 # else FLASH_B_SECURITY_ENABLE == 1
1125 .DATA.W 0x0099 ; Security ENABLED
1126 .DATA.W ((FLASH_B_UNLOCK_1 << 8) | FLASH_B_UNLOCK_0)
1127 .DATA.W ((FLASH_B_UNLOCK_3 << 8) | FLASH_B_UNLOCK_2)
1128 .DATA.W ((FLASH_B_UNLOCK_5 << 8) | FLASH_B_UNLOCK_4)
1129 .DATA.W ((FLASH_B_UNLOCK_7 << 8) | FLASH_B_UNLOCK_6)
1130 .DATA.W ((FLASH_B_UNLOCK_9 << 8) | FLASH_B_UNLOCK_8)
1131 .DATA.W ((FLASH_B_UNLOCK_11 << 8) | FLASH_B_UNLOCK_10)
1132 .DATA.W ((FLASH_B_UNLOCK_13 << 8) | FLASH_B_UNLOCK_12)
1133 .DATA.W ((FLASH_B_UNLOCK_15 << 8) | FLASH_B_UNLOCK_14)
1137 #endif ; FLASH_B_AVAILABLE == ON
1140 ;====================================================================
1141 ; 5.8 Set Flash write protection
1142 ;====================================================================
1144 .SECTION FLASH_A_PROTECT, CONST, LOCATE=H'DF001C
1145 #if FLASH_A_WRITE_PROTECT == ON
1147 .DATA.B ~((PROTECT_SECTOR_SA3 << 3) | (PROTECT_SECTOR_SA2 << 2) | (PROTECT_SECTOR_SA1 << 1) | PROTECT_SECTOR_SA0)
1149 .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)
1154 #endif ; FLASH_A_WRITE_PROTECT
1157 #if FLASH_B_AVAILABLE == ON
1158 .SECTION FLASH_B_PROTECT, CONST, LOCATE=H'DE001C
1159 # if FLASH_B_WRITE_PROTECT == ON
1161 .DATA.B ~((PROTECT_SECTOR_SB3 << 3) | (PROTECT_SECTOR_SB2 << 2) | (PROTECT_SECTOR_SB1 << 1) | PROTECT_SECTOR_SB0)
1166 # endif ; FLASH_B_WRITE_PROTECT
1168 #endif ; FLASH_B_AVAILABLE == ON
1171 ;====================================================================
1172 ; 5.9 Debug address specification
1173 ;====================================================================
1175 ; BDM configuration section should always be defined for later
1176 ; configuration by e.g. debugger tool or (special) programmer tool.
1178 .SECTION BDM_CONFIG, CONST, LOCATE=H'DF0040
1180 #if BACKGROUND_DEBUGGING == ON
1185 .DATA.W BDM_CONFIGURATION
1188 # if ((SERIES == MB96340) && (DEVICE < 3))
1189 # error Device does not support background debugging
1190 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1192 # if ((SERIES == MB96340) && (DEVICE < 12))
1193 .DATA.W (D'16 * CRYSTAL + BDM_BAUDRATE) / BDM_BAUDRATE
1195 .DATA.W (D'32 * CRYSTAL + BDM_BAUDRATE) / BDM_BAUDRATE
1196 # endif ; ((SERIES == MB96340) && (DEVICE < 12))
1199 .DATA.E BDM_EXT_CONFIG
1202 .DATA.B BDM_WD_PATTERN
1210 .DATA.E BDM_PFA0, BDM_PFA1
1211 .DATA.E BDM_PFA2, BDM_PFA3
1212 .DATA.E BDM_PFA4, BDM_PFA5
1213 .DATA.E BDM_PFA6, BDM_PFA7
1215 .DATA.W BDM_PFD0, BDM_PFD1
1216 .DATA.W BDM_PFD2, BDM_PFD3
1217 .DATA.W BDM_PFD4, BDM_PFD5
1218 .DATA.W BDM_PFD6, BDM_PFD7
1220 .DATAB.B 64, 0xFF ; fill section with 0xFF
1222 #endif ; BACKGROUND_DEBUGGING == ON
1226 ;====================================================================
1228 ;====================================================================
1230 ;====================================================================
1231 ; 6.1 Import external symbols
1232 ;====================================================================
1234 .IMPORT _main ; user code entrance
1236 .IMPORT __stream_init
1242 ;====================================================================
1243 ; ___ _____ __ ___ _____
1245 ; \___ | | | |___/ |
1247 ; ___/ | | | | \ | Begin of actual code section
1249 ;====================================================================
1250 .SECTION CODE_START, CODE, ALIGN=1
1252 ;====================================================================
1253 ; 6.2 Program start (the reset vector should point here)
1254 ;====================================================================
1256 NOP ; This NOP is only for debugging. On debugger the IP
1257 ; (instruction pointer) should point here after reset
1259 ;====================================================================
1260 ; 6.3 "NOT RESET YET" WARNING
1261 ;====================================================================
1263 NOP ; read hint below!!!!!!!
1264 ; If the debugger stays at this NOP after download, the controller has
1265 ; not been reset yet. In order to reset all hardware registers it is
1266 ; highly recommended to reset the controller.
1267 ; However, if no reset vector has been defined on purpose, this start
1268 ; address can also be used.
1269 ; This mechanism is using the .END instruction at the end of this mo-
1270 ; dule. It is not necessary for controller operation but improves
1271 ; security during debugging (mainly emulator debugger).
1272 ; If the debugger stays here after a single step from label "_start"
1273 ; to label "notresetyet", this note can be ignored.
1275 ;====================================================================
1276 ; 6.4 Initialisation of processor status
1277 ;====================================================================
1278 AND CCR, #0x80 ; disable interrupts
1279 MOV ILM,#7 ; set interrupt level mask to ALL
1280 MOV RP,#REGBANK ; set register bank pointer
1282 ;====================================================================
1283 ; 6.5 Set clock ratio (ignore subclock)
1284 ;====================================================================
1285 MOVN A, #0 ; set bank 0 in DTB for the case that
1286 MOV DTB, A ; start-up code was not jumped by reset
1288 MOV CKSSR, #(0xF8 | MC_STAB_TIME) ; set clock stabilization time
1290 #if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_4MHZ_MAIN_CLKP2_4MHZ)
1292 #endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_4MHZ_MAIN_CLKP2_4MHZ)
1294 #if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_4MHZ_MAIN_CLKP2_4MHZ)
1301 # if FLASH_B_AVAILABLE == ON
1303 # endif ; FLASH_B_AVAILABLE == ON
1305 #endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_4MHZ_MAIN_CLKP2_4MHZ)
1307 #if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_4MHZ_PLL_CLKP2_4MHZ)
1308 # if ((SERIES == MB96340) && (DEVICE < 3))
1315 # if FLASH_B_AVAILABLE == ON
1317 # endif ; FLASH_B_AVAILABLE == ON
1319 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1320 #endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_4MHZ_PLL_CLKP2_4MHZ)
1322 #if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_4MHZ_PLL_CLKP2_4MHZ)
1323 # if ((SERIES == MB96340) && (DEVICE < 3))
1335 # if FLASH_B_AVAILABLE == ON
1337 # endif ; FLASH_B_AVAILABLE == ON
1339 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1340 #endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_4MHZ_PLL_CLKP2_4MHZ)
1342 #if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_8MHZ_CLKP2_8MHZ)
1343 # if ((SERIES == MB96340) && (DEVICE < 3))
1350 # if FLASH_B_AVAILABLE == ON
1352 # endif ; FLASH_B_AVAILABLE == ON
1354 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1355 #endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_8MHZ_CLKP2_8MHZ)
1357 #if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_8MHZ_CLKP2_8MHZ)
1358 # if ((SERIES == MB96340) && (DEVICE < 3))
1365 # if FLASH_B_AVAILABLE == ON
1367 # endif ; FLASH_B_AVAILABLE == ON
1369 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1370 #endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_8MHZ_CLKP2_8MHZ)
1372 #if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_12MHZ_CLKP2_12MHZ)
1373 # if ((SERIES == MB96340) && (DEVICE < 3))
1380 # if FLASH_B_AVAILABLE == ON
1382 # endif ; FLASH_B_AVAILABLE == ON
1384 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1385 #endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_12MHZ_CLKP2_12MHZ)
1387 #if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_12MHZ_CLKP2_12MHZ)
1388 # if ((SERIES == MB96340) && (DEVICE < 3))
1400 # if FLASH_B_AVAILABLE == ON
1402 # endif ; FLASH_B_AVAILABLE == ON
1404 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1405 #endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_12MHZ_CLKP2_12MHZ)
1407 #if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_16MHZ_CLKP2_16MHZ)
1408 # if ((SERIES == MB96340) && (DEVICE < 3))
1416 # if FLASH_B_AVAILABLE == ON
1419 # endif ; FLASH_B_AVAILABLE == ON
1422 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1423 #endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_16MHZ_CLKP2_16MHZ)
1425 #if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_16MHZ_CLKP2_16MHZ)
1426 # if ((SERIES == MB96340) && (DEVICE < 3))
1434 # if FLASH_B_AVAILABLE == ON
1437 # endif ; FLASH_B_AVAILABLE == ON
1440 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1441 #endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_16MHZ_CLKP2_16MHZ)
1443 #if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_24MHZ_CLKP2_12MHZ)
1444 # if ((SERIES == MB96340) && (DEVICE < 3))
1452 # if FLASH_B_AVAILABLE == ON
1454 # endif ; FLASH_B_AVAILABLE == ON
1456 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1457 #endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_24MHZ_CLKP2_12MHZ)
1459 #if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_24MHZ_CLKP2_12MHZ)
1460 # if ((SERIES == MB96340) && (DEVICE < 3))
1468 # if FLASH_B_AVAILABLE == ON
1470 # endif ; FLASH_B_AVAILABLE == ON
1472 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1473 #endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_24MHZ_CLKP2_12MHZ)
1475 #if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP2_16MHZ)
1476 # if ((SERIES == MB96340) && (DEVICE < 3))
1477 # error Setting prohibited due to 16FXFL0014
1483 # if FLASH_B_AVAILABLE == ON
1486 # endif ; FLASH_B_AVAILABLE == ON
1489 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1490 #endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP2_16MHZ)
1492 #if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP2_16MHZ)
1493 # if ((SERIES == MB96340) && (DEVICE < 3))
1494 # error Setting prohibited due to 16FXFL0014
1500 # if FLASH_B_AVAILABLE == ON
1503 # endif ; FLASH_B_AVAILABLE == ON
1506 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1507 #endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP2_16MHZ)
1509 #if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP1_16MHZ_CLKP2_16MHZ)
1510 # if ((SERIES == MB96340) && (DEVICE < 3))
1511 # error Setting prohibited due to 16FXFL0014
1517 # if FLASH_B_AVAILABLE == ON
1520 # endif ; FLASH_B_AVAILABLE == ON
1523 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1524 #endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP1_16MHZ_CLKP2_16MHZ)
1526 #if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP1_16MHZ_CLKP2_16MHZ)
1527 # if ((SERIES == MB96340) && (DEVICE < 3))
1528 # error Setting prohibited due to 16FXFL0014
1534 # if FLASH_B_AVAILABLE == ON
1537 # endif ; FLASH_B_AVAILABLE == ON
1540 # endif ; ((SERIES == MB96340) && (DEVICE < 3))
1541 #endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_32MHZ_CLKP1_16MHZ_CLKP2_16MHZ)
1543 #if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_48MHZ_CLKP2_16MHZ)
1548 # if FLASH_B_AVAILABLE == ON
1551 # endif ; FLASH_B_AVAILABLE == ON
1554 #endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_48MHZ_CLKP2_16MHZ)
1556 #if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_48MHZ_CLKP2_16MHZ)
1561 # if FLASH_B_AVAILABLE == ON
1564 # endif ; FLASH_B_AVAILABLE == ON
1567 #endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_48MHZ_CLKP2_16MHZ)
1569 #if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_48MHZ_CLKP1_32MHZ_CLKP2_16MHZ)
1574 # if FLASH_B_AVAILABLE == ON
1577 # endif ; FLASH_B_AVAILABLE == ON
1580 #endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_48MHZ_CLKP1_32MHZ_CLKP2_16MHZ)
1582 #if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_48MHZ_CLKP1_32MHZ_CLKP2_16MHZ)
1587 # if FLASH_B_AVAILABLE == ON
1590 # endif ; FLASH_B_AVAILABLE == ON
1593 #endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_48MHZ_CLKP1_32MHZ_CLKP2_16MHZ)
1595 #if (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_56MHZ_CLKP2_14MHZ)
1600 # if FLASH_B_AVAILABLE == ON
1603 # endif ; FLASH_B_AVAILABLE == ON
1606 #endif ; (CRYSTAL == FREQ_4MHZ) && (CLOCK_SPEED == CPU_56MHZ_CLKP2_14MHZ)
1608 #if (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_56MHZ_CLKP2_14MHZ)
1613 # if FLASH_B_AVAILABLE == ON
1616 # endif ; FLASH_B_AVAILABLE == ON
1619 #endif ; (CRYSTAL == FREQ_8MHZ) && (CLOCK_SPEED == CPU_56MHZ_CLKP2_14MHZ)
1622 ;====================================================================
1623 ; 6.6 Set external bus configuaration
1624 ;====================================================================
1626 #if BUSMODE != SINGLE_CHIP ; ext bus used
1627 MOV EBCF, #((HOLD_REQ << 7) | (EXT_READY << 6) | (EXT_CLOCK_ENABLE << 5) | (EXT_CLOCK_INVERT << 4) | (EXT_CLOCK_SUSPEND << 3) | EXT_CLOCK_DIVISION)
1628 MOV EBAE0,#ADDR_PINS_7_0
1629 MOV EBAE1,#ADDR_PINS_15_8
1630 MOV EBAE2,#ADDR_PINS_23_16
1631 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)
1632 MOVW EACL0,#CS0_CONFIG
1633 MOVW EACL1,#CS1_CONFIG
1634 MOVW EACL2,#CS2_CONFIG
1635 MOVW EACL3,#CS3_CONFIG
1636 MOVW EACL4,#CS4_CONFIG
1637 MOVW EACL5,#CS5_CONFIG
1638 MOV EAS2, #CS2_START
1639 MOV EAS3, #CS3_START
1640 MOV EAS4, #CS4_START
1641 MOV EAS5, #CS5_START
1642 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
1644 # if SERIES == MB96320 || SERIES == MB96330 || SERIES == MB96340 || SERIES == MB96350
1646 # 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
1652 # if EXT_READY == ON
1656 # else if SERIES == MB96370 || SERIES == MB96380
1658 # 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
1664 # if EXT_READY == ON
1671 #if BUSMODE == INTROM_EXTBUS ; EXTBUS and INTROM/EXTROM
1672 # if ROMMIRROR == OFF && CONSTDATA == ROMCONST
1673 # error Mirror function must be ON to mirror internal ROM
1677 ROMM_CONFIG .EQU ((MIRROR_BANK << 4) | (MIRROR_SIZE << 1) | (ROMMIRROR))
1678 MOV ROMM, #ROMM_CONFIG
1681 ;====================================================================
1682 ; 6.7 Prepare stacks and set the default stack type
1683 ;====================================================================
1685 AND CCR,#H'DF ; clear system stack flag
1686 MOVL A, #(__userstack_top) & ~1
1687 MOVW SP,A ; load offset of stack top to pointer
1688 SWAPW ; swap higher word to AL
1689 MOV USB, A ; set bank
1691 #if STACK_FILL == ON ; preset the stack
1693 MOVW A, #USTACK ; load start stack address to AL
1694 MOVW A, #STACK_PATTERN ; AL -> AH, pattern in AL
1695 MOVW RW0, #SIZEOF(USTACK) / 2 ; get byte count
1696 FILSWI ADB ; write pattern to stack
1699 OR CCR,#H'20 ; set System stack flag
1700 MOVL A, #(__systemstack_top) & ~1
1701 MOVW SP,A ; load offset of stack top to pointer
1702 SWAPW ; swap higher word to AL
1703 MOV SSB, A ; set bank
1705 #if STACK_FILL == ON ; preset the stack
1707 MOVW A, #SSTACK ; load start stack address to AL
1708 MOVW A, #STACK_PATTERN ; AL -> AH, pattern in AL
1709 MOVW RW0, #SIZEOF(SSTACK) / 2; get byte count
1710 FILSWI ADB ; write pattern to stack
1713 #if STACKUSE == USRSTACK
1714 AND CCR,#H'DF ; clear system stack flag
1718 ; The following macro is needed because of the AUTOMODEL option. If the
1719 ; model is not known while assembling the module, one has to expect
1720 ; completion of streaminit() by RET or RETP. Because RET removes 2 bytes
1721 ; from stack and RETP removes 4 bytes from stack, SP is reloaded.
1725 #if STACKUSE == USRSTACK
1726 MOVW A, #(__userstack_top) & ~1
1728 MOVW A, #(__systemstack_top) & ~1
1734 ;====================================================================
1735 ; 6.8 Copy initial values to data areas.
1736 ;====================================================================
1738 ; Each C-module has its own __far INIT section. The names are generic.
1739 ; DCONST_module contains the initializers for the far data of the one
1740 ; module. INIT_module reserves the RAM area, which has to be loaded
1741 ; with the data from DCONST_module. ("module" is the name of the *.c
1743 ; All separated DCONST_module/INIT_module areas are described in
1744 ; DTRANS section by start addresses and length of each far section.
1745 ; 0000 1. source address (ROM)
1746 ; 0004 1. destination address (RAM)
1747 ; 0008 length of sections 1
1748 ; 000A 2. source address (ROM)
1749 ; 000E 2. destination address (RAM)
1750 ; 0012 length of sections 2
1751 ; 0014 3. source address ...
1752 ; In addition the start-up file adds the descriptors of the __near
1753 ; sections to this table. The order of the descriptors in this table
1754 ; depends on the linkage order.
1755 ;====================================================================
1756 MOV A, #BNKSEC DTRANS ; get bank of table
1757 MOV DTB, A ; store bank in DTB
1758 MOVW RW1, #DTRANS ; get start offset of table
1759 OR CCR, #H'20 ; System stack flag set (SSB used)
1760 BRA LABEL2 ; branch to loop condition
1762 MOVW A, @RW1+6 ; get bank of destination
1763 MOV SSB, A ; save dest bank in SSB
1764 MOVW A, @RW1+2 ; get source bank
1765 MOV ADB, A ; save source bank in ADB
1766 MOVW A, @RW1+4 ; move destination addr in AL
1767 MOVW A, @RW1 ; AL -> AH, src addr -> AL
1768 MOVW RW0, @RW1+8 ; number of bytes to copy -> RW0
1769 MOVSI SPB, ADB ; copy data
1770 MOVN A, #10 ; length of one table entry is 10
1771 ADDW RW1, A ; set pointer to next table entry
1773 MOVW A, RW1 ; get address of next block
1774 SUBW A, #DTRANS ; sub address of first block
1775 CMPW A, #SIZEOF (DTRANS) ; all blocks processed ?
1776 BNE LABEL1 ; if not, branch
1779 ;====================================================================
1780 ; 6.9 Clear uninitialized data areas to zero
1781 ;====================================================================
1783 ; Each C-module has its own __far DATA section. The names are generic.
1784 ; DATA_module contains the reserved area (RAM) to be cleared.
1785 ; ("module" is the name of the *.c file)
1786 ; All separated DATA_module areas are described in DCLEAR section by
1787 ; start addresses and length of all far section.
1788 ; 0000 1. section address (RAM)
1789 ; 0004 length of section 1
1790 ; 0006 2. section address (RAM)
1791 ; 000A length of section 2
1792 ; 000C 3. section address (RAM)
1793 ; 0010 length of section 3 ...
1794 ; In addition the start-up file adds the descriptors of the __near
1795 ; sections to this table. The order of the descriptors in this table
1796 ; depends on the linkage order.
1797 ;====================================================================
1798 MOV A, #BNKSEC DCLEAR ; get bank of table
1799 MOV DTB, A ; store bank in DTB
1800 MOVW RW1, #DCLEAR ; get start offset of table
1801 BRA LABEL4 ; branch to loop condition
1803 MOV A, @RW1+2 ; get section bank
1804 MOV ADB, A ; save section bank in ADB
1805 MOVW RW0, @RW1+4 ; number of bytes to copy -> RW0
1806 MOVW A, @RW1 ; move section addr in AL
1807 MOVN A, #0 ; AL -> AH, init value -> AL
1808 FILSI ADB ; write 0 to section
1809 MOVN A, #6 ; length of one table entry is 6
1810 ADDW RW1, A ; set pointer to next table entry
1812 MOVW A, RW1 ; get address of next block
1813 SUBW A, #DCLEAR ; sub address of first block
1814 CMPW A, #SIZEOF (DCLEAR) ; all blocks processed ?
1815 BNE LABEL3 ; if not, branch
1819 ;====================================================================
1820 ; 6.10 Set Data Bank Register (DTB) and Direct Page Register (DPR)
1821 ;====================================================================
1822 MOV A,#BNKSEC DATA ; User data bank offset
1825 MOV A,#PAGE DIRDATA_S ; User direct page
1828 ;====================================================================
1829 ; 6.11 ICU register initialization workaround
1830 ;====================================================================
1832 #if (UART_SCANNING == ON)
1833 # if (((SERIES == MB96320) && (DEVICE < 3)) || \
1834 ((SERIES == MB96350) && (DEVICE < 3)))
1843 # endif ; ((SERIES == 96350) && ...
1844 # if (((SERIES == MB96330) && (DEVICE < 2)) || \
1845 ((SERIES == MB96340) && (DEVICE < 27)) || \
1846 ((SERIES == MB96370) && (DEVICE < 3)) || \
1847 ((SERIES == MB96380) && (DEVICE < 13)))
1851 # endif ; (((SERIES == MB96330) && (DEVICE < 2)) || ...
1852 #endif ; (UART_SCANNING == ON)
1854 ;====================================================================
1855 ; 6.12 Wait for clocks to stabilize
1856 ;====================================================================
1858 #if (CLOCK_SPEED == CPU_4MHZ_MAIN_CLKP2_4MHZ) && (CLOCKWAIT == ON)
1860 BBC CKMR:5,no_MC_yet ; check MCM and wait for
1861 ; Main Clock to stabilize
1862 #endif ; wait for Main Clock
1864 #if (((CRYSTAL == FREQ_4MHZ) ||(CRYSTAL == FREQ_8MHZ)) && \
1865 ((CLOCK_SPEED == CPU_12MHZ_CLKP2_12MHZ) || \
1866 (CLOCK_SPEED == CPU_16MHZ_CLKP2_16MHZ) || \
1867 (CLOCK_SPEED == CPU_24MHZ_CLKP2_12MHZ)))
1869 BBC CKMR:6, no_PLL_0WS
1871 # if ! ((SERIES == MB96340) && (DEVICE < 3))
1873 # if FLASH_B_AVAILABLE == ON
1875 # endif ; FLASH_B_AVAILABLE == ON
1876 # endif ; ! ((SERIES == MB96340) && (DEVICE < 3))
1879 #if ((CRYSTAL == FREQ_4MHZ) || (CRYSTAL == FREQ_8MHZ)) && \
1880 ((CLOCK_SPEED == CPU_48MHZ_CLKP2_16MHZ) || \
1881 (CLOCK_SPEED == CPU_48MHZ_CLKP1_32MHZ_CLKP2_16MHZ)) && \
1882 ! ((SERIES == MB96340) && (DEVICE < 3))
1884 BBC CKMR:6, no_PLL_1WS
1887 # if FLASH_B_AVAILABLE == ON
1889 # endif ; FLASH_B_AVAILABLE == ON
1892 #if (CLOCKWAIT == ON) && \
1893 ((CLOCK_SPEED == CPU_4MHZ_PLL_CLKP2_4MHZ) || \
1894 (CLOCK_SPEED == CPU_8MHZ_CLKP2_8MHZ) || \
1895 (CLOCK_SPEED == CPU_56MHZ_CLKP2_14MHZ))
1897 BBC CKMR:6,no_PLL_yet ; check PCM and wait for
1899 #endif ; wait for PLL
1901 ;====================================================================
1902 ; 6.13 Initialise Low-Level Library Interface
1903 ;====================================================================
1905 ; Call lib init function and reload stack afterwards, if AUTOMODEL
1906 ;====================================================================
1908 # if MEMMODEL == SMALL || MEMMODEL == COMPACT
1909 CALL __stream_init ; initialise library IO
1910 # else ; MEDIUM, LARGE, AUTOMODEL
1911 CALLP __stream_init ; initialise library IO
1912 # if MEMMODEL == AUTOMODEL
1913 RELOAD_SP ; reload stack since stream_init was
1914 ; possibly left by RET (not RETP)
1916 # endif ; MEDIUM, LARGE, AUTOMODEL
1919 ;====================================================================
1920 ; 6.14 Call C-language main function
1921 ;====================================================================
1922 #if MEMMODEL == SMALL || MEMMODEL == COMPACT
1923 CALL _main ; Start main function
1924 #else ; MEDIUM, LARGE, AUTOMODEL
1925 CALLP _main ; Start main function
1926 ; ignore remaining word on stack,
1927 ; if main was completed by RET
1929 ;====================================================================
1930 ; 6.15 Shut down library
1931 ;====================================================================
1933 # if MEMMODEL == SMALL || MEMMODEL == COMPACT
1935 # else ; MEDIUM, LARGE, AUTOMODEL
1936 CALLP _exit ; ignore remaining word on stack,
1937 ; if main was completed by RET
1942 ;====================================================================
1943 ; 6.16 Program end loop
1944 ;====================================================================
1948 .END notresetyet ; define debugger start address
1951 ;====================================================================
1952 ; ----------------------- End of Start-up file ---------------------
1953 ;====================================================================