Startup Processing Library; Overview; Vector Tables; Stack Pointer Initial Values - Epson S5U1C17001C Manual

Cmos 16-bit single chip microcontroller (c compiler package for s1c17 family) (ver. 3.2)
Hide thumbs Also See for S5U1C17001C:
Table of Contents

Advertisement

5.2 Startup Processing Library

5.2.1

Overview

The crt0.o library provides the processing from when the target MCU is reset until the main function is called, together with the
vector tables. For information on the crt0.o processing details, refer to the source code utility/lib_src/crt0/crt0.c included in this
package.
5.2.2

Vector Tables

The vector tables are registered in crt0.o, as shown below:
void * const _vector[] = {
VECTOR(_start),
VECTOR(_vector01_handler),
VECTOR(_vector02_handler),
VECTOR(emu_copro_process),
VECTOR(_vector04_handler),
VECTOR(_vector05_handler),
VECTOR(_vector06_handler),
VECTOR(_vector07_handler),
VECTOR(_vector30_handler),
VECTOR(_vector31_handler),
};
crt0.o always uses the name _vectorXX_handler (where "XX" is a 2-digit base-10 vector number) for the interrupt handler function
registered in vector tables. Interrupt handler functions should be declared as shown below in accordance with "2.2 Grammar of C
Source".
Declaring an interrupt handler function for vector number 8
Example:
void _vector08_handler (void) __attribute__ ((interrupt_handler));
Use the following declaration to register an interrupt handler function defined with a different name to the crt0.o vector table:
Registering interrupt handler function sampleInterrupt to vector number 8
Example:
void sampleInterrupt (void) __attribute__ ((interrupt_handler));
void _vector08_handler(void) __attribute__((alias("sampleInterrupt")));
5.2.3

Stack Pointer Initial Values

crt0.o sets the symbol __START_stack to the stack pointer initial value immediately after the program starts. With this package
configuration, the __START_stack value is normally defined by the linker script.
To alter the stack pointer initial value, either change the linker script definition or set using a C source file or linker symbol file as
follows:
Example: To set the stack pointer initial value to 0x700 at a location on the C source file
asm (".global __START_stack");
asm (".set __START_stack, 0x700"); /* initial value of SP register */
Example: To set the stack pointer initial value to 0x700 using a linker symbol file
__START_stack = 0x700; /* initial value of SP register */
Set the stack pointer initial value to a value appropriate for the target model of the program. The linker script definition will be used
if this is not set. The default linker script definition will be used if no linker script is specified.
S5U1C17001C Manual
(Rev. 1.0)
Seiko Epson Corporation
5 Library
5-3

Advertisement

Table of Contents
loading

Table of Contents