Specifications

740 Family
Programming Guide <C Language>
REJ05B0468-0100Z /Rev.1.00 September 2004 Page 77 of 102
Setting up the stack page (“cstartup.s31”)
Set up the stack page. Make sure the value of each bit in the CPU mode register is set to suit
the operating environment. Where and how to write is shown below.
Registering the interrupt vector (“cstartup.s31”)
By altering the content of the INTVEC segment in the cstartup.s31 included with the ICC740,
register the interrupt processing functions as suitable for the microcomputer used. For this
purpose, rewrite the lines 352–372 as shown below.
If two or more interrupt sources are set at the same vector address, write them as one interrupt
source. Note also that there is no need to add a reset because the reset vector is set at the
bottom.
Declare the interrupt processing function to be externally referenced by using the directive
command EXTERN. If there is any undefined interrupt vector, we recommend setting init_C in
that vector as for a reset without leaving it blank, to prevent the program from running out of
control.
Write the beginning address of the INTVEC segment in the lnk740.xcl file.
;---------------------------------------------------------------;
; RCODE - where the execution actually begins ;
;---------------------------------------------------------------;
RSEG RCODE:ROOT
init_C
CLD ; set default mode
CLT
LDM #0CH, 3BH ; set stack page : 3803 Group
LDX #LOW (SFE(CSTACK)-1) ; set up stack pointer
TXS
Set up the stack page. By default, it is set in
page 1.
If it needs to be set in page 0, set up as
shown below (for the 3803 group’s case):
LDM #08H, 3BH
COMMON INTVEC
?CSTARTUP_INTVEC:
BLKB 0FFFEH - 0FFDCH -2 ; 3803 Group
#if 0
#if defined(MELPS_37600)
BLKB 40H - 6 ; FFFA ( FFC0 + 40 - 6) (-v2)
#elif defined(MELPS_MULDIV)
BLKB 20H - 4 ; FFFC
#else
BLKB 20H - 2 ; FFFE
#endif
#endif
?CSTARTUP_RESETVEC:
WORD init_C
ENDMOD init_C
EXTERN Int2, Timer1, Int0
COMMON INTVEC
?CSTARTUP_INTVEC:
WORD init_C ; +0x00 : BRK
WORD init_C ; +0x02 : AD_SIO3T
WORD init_C ; +0x04 : INT4_CNTR2
WORD init_C ; +0x06 : INT3
WORD Int2 ; +0x08 : INT2
WORD init_C ; +0x0a : SIO2_TimerZ
WORD init_C ; +0x0c : CNTR1_SIO3R
WORD init_C ; +0x0e : CNTR0
WORD init_C ; +0x10 : Timer2
WORD Timer1 ; +0x12 : Timer1
WORD init_C ; +0x14 : TimerY
WORD init_C ; +0x16 : TimerX
WORD init_C ; +0x18 : SIO1T
WORD init_C ; +0x1a : SIO1R
WORD init_C ; +0x1c : INT1
WORD Int0 ; +0x1e : INT0_TimerZ
?CSTARTUP_RESETVEC:
WORD init_C ; +0x20 : reset
ENDMOD init_C
Example
for the
3803 group
(varies with
each
microcomp
uter used)