
M16C/62
A
PPLICATION
N
OTE
C Compiler Startup Files for the M16C/62 MCU
1. Abstract
The following article describes the Startup files for Mitsubishi’s NC30 C compiler. A set of customized
Startup files is given for the M30624 version of the M16C/62 microcontroller.
2. Introduction
The Mitsubishi M16C/62 is a 16-bit MCU, based on the M16C CPU core, with an impressive list of
features including 10-bit A/D, D/A, UARTS, timers, DMA, and so on, and up to 256k bytes of user flash.
The M16C series is ideally suited for programming using the C language.
C compilers for microcontrollers typically require some sort of assembler ‘startup’ file to set processor
modes, initialize variables, and so forth. For the NC30 compiler, the startup file also includes section
information so the linker knows where, in physical memory, to put variables, constants, code, and so on.
The default files included with the NC30 are “ncrt0.a30”, the startup file, and “sect30.inc”, which give
section information.
3. NCRT0.A30 Description
The NC30 compiler is shipped with a default startup file, “ncrt0.a30”. This file is a generic startup, which
was written for most of the M16C/60 and M16C/20 series microcontrollers. A customized startup file for
the M16C/62 is described in section 7.1.
After reset, execution begins with the code in this startup file. The stack pointer is set to point to a free
area in RAM, and the processor mode is set. C requires that all (global) un-initialized variables be set to
zero and initialize variables are copied from ROM into RAM.
4. SECT30.INC Description
The NC30 compiler is shipped with a default section definition file, “sect30.inc”. This file is a generic
section file for the M16C series and typically requires editing for the specific processor. A customized
section definition file for the M16C/62 is described in section 7.1.
The purpose of the section definition file is to set the location of the C language sections in the
microcontroller’s physical memory map. The information here is used by the linker to determine where to
put aligned variables (integers), non-aligned variables (characters), code (in ROM), interrupt vectors, and
so forth. Figure 1 is an example of a memory map for an M16C/62 program that used the customized
startup files. Note that the example program assumes the processor is operating in expanded mode with
external RAM at address 10000h and external ROM at 6000h.
AN-DECE-MCU-23-A
February 2002
1