Home
C Compiler Startup Files for the M16C/62 MCU
Contents
1. INTERRUPT VECTOR ADDRESS do not set within a flash memory block used by REU05B0006 0100Z June 2003 Page 6 of 12 M16C 62 E ZE N ESAS C Compiler Startup Files for the M16C 62 MCU the ROM Monitor VECTOR_ADR equ 0ef000h Initialize Macro declarations These macro s are used in the startup file ncrto a30 for initializing C variables Clears global variables sets intialized variables etc N_BZERO macro TOP SECT mov b 00H ROL mov w TOP_ amp OFFFFH Al mov w sizeof SECT R3 sisi rab endm N_BCOPY macro FROM_ TO_ SECT_ MOV W FROM _ amp OFFFFH A0O mov b FROM_ gt gt 16 R1H mov w TO_ Al mov w sizeof SECT R3 smovf b endm BZERO macro TOP_ SECT push w sizeof SI CT gt gt 16 CT amp Offffh m E m E push w sizeof SI pusha TOP_ gt gt 16 pusha TOP_ amp Offffh glb _bzero jsr a _bzero endm BCOPY macro FROM TO_ SECT ECT gt gt 16 CT amp Offffh push w sizeof SI m E m E push w sizeof SI pusha TO gt gt 16 pusha TO amp Offffh pusha FROM gt gt 16 pusha FROM_ amp Offffh glb _bcopy jsr a _bcopy Special page definition For defining routines or functions as special page macro define for special page r 7 Format F SPECIAL number SPECIAL macro NUM REU05B0006 0100Z June 2003 Page 7 of 12 M16C 62 E ZE N ESAS C Co
2. This assumes that when you installed the compiler the default directory c MTOOL was specified It is strongly recommended that you back up the default files first Also if you installed the development tools from a Starter Kit CD the custom startup files included with the kit will automatically be used REU05B0006 0100Z June 2003 Page 2 of 12 M16C 62 E ZE N ESAS C Compiler Startup Files for the M16C 62 MCU 6 0 Reference Renesas Technology Corporation Semiconductor Home Page http www renesas com E mail Support support _apl renesas com Data Sheets e M16C 62 datasheets 62aeds pdf User s Manual e C Language Programming Manual 6020EC PDF 7 0 Software Code 7 1 Customized Startup Files for the M16C 62 The following is a set of customized startup files for the M30624 MCU Except for adding entries into the interrupt vector tables these files should suffice as is for most applications If using different versions of the M16C 62 the ROM starting address will need to be modified PRR RR RKKK RK KR KK KKK KKK KK RK KEK K KKK KKK KK KK KR KK KKK KKK KK KKK KKK EK KERR KK KK KKEK KK KKK NC30 C COMPILER for M16C 60 Starter Kits Name ncrt0O 62askp a30 description Customized startup program for the M16C 62 M30624 microcontroller using the NC30 compiler Programs complied with this startup file will run under the MSV1632 ROM Monitor or stand alone Copyright 2003
3. glb _exit glb Sexit REU05B0006 0100Z June 2003 Page 5 of 12 M16C 62 E ZE N ESAS C Compiler Startup Files for the M16C 62 MCU _exit End program exit jmp _exit dummy interrupt function Used for all unassigned interrupts see end of sect30 inc dummy int reit end KKK KKK KK KK KK KK KKKK KK KK KK KK KK KK KK KK KK KK KK KK KK KK KK KKK K KK KKKKKKKKKKKKK KKK KKK K KK KKK r r sect30 62askp inc Customized section and macro definitions for the M30624 A M16C 62 microcontroller using the NC30 compiler Description This file is specific to the M30624 microcontroller and adapted for use with the MSV1632 Starter Kit UART1 interrupt vectors are used for the Starter Kit debugger Copyright 2003 RENESAS TECHNOLOGY CORPORATION 5 All Rights Reserved Id ekkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkkxkxkxkxkkxkxkxkkxkxkxkxkxkxkxkkkxxkx r HEAP SIZE definition Only used for memory allocate functions malloc realloc etc If not required and need this RAM for other usage reduce the value of HEAPSIZE STACK SIZE definition Unless the system is running an RTOS both interrupts and function calls should use the istack only default startup configuration If not required and need this RAM for other usage reduce the value of USTACKSIZE
4. data area For near const By definition Near ROM is all ROM below address 10000h org 06000H Example External ROM located at 6000h E ROMDATA rom NE ROMDATA ALIGN section rom N org 06000H Example External ROM located at 6000h rom NE top section rom NO ROMDATA rom NO top Far RAM data area For far int s char s etc By definition Far RAM is all RAM above address FFFFh section data_FE DATA Org 10000H Example External RAM located at 10000h data_FE top section bss_FE DATA ALIGN bss_FE top section data_FO DATA data_FO_ top section bss_FO DATA bss_FO top section rom FE ROMDATA Out of reset the C0000h flash block block6 is not visible until the pm13 bit is set see M30624 spec s Processor Mode Register 1 The ROM Monitor sets this bit but for consistent stand alone operation do not allow the reset vector to point to an address 7below DOOOOh REU05B0006 0100Z June 2003 Page 9 of 12 M16C 62 E ZE N ESAS C Compiler Startup Files for the M16C 62 MCU org 0d0000H rom_FE top section rom_FO ROMDATA rom_FO top Initial data of data section section data_SEI ROMDATA data SEI top section data_SOI ROMDATA data_SOI_top section data_NEI ROMDATA data NEI top Section data_NOI ROMDATA data NOI top section data_FEI ROMDATA data FEI top section data_
5. FOI ROMDATA data FOI top section switch_table ROMDATA section interrupt section program section program S special page code must be in the org 0f0000h address range of F0000h to FFFDCh variable vector section For proper interrupt operation replace dummy int with the assembler label or absolute address of the interrupt service routine section vector variable vector table org VECTOR ADR lword dummy_int BRK vector 0 REU05B0006 0100Z June 2003 Page 10 of 12 2rRENESAS M16C 62 C Compiler Startup Files for the M16C 62 MCU org VECTOR_ADR 16 lword dummy_int int3 for user vector 4 lword dummy_int timerB5 for user vector 5 lword dummy_int timerB4 for user vector 6 lword dummy_int timerB3 for user vector 7 lword dummy int si o4 int5 for user vector 8 lword dummy int si o3 int4 for user vector 9 lword dummy int Bus collision detection for user v10 lword dummy _int DMAO for user vector 11 lword dummy_int DMA1 for user vector 12 lword dummy int Key input interrupt for user vect 14 lword dummy _int A D for user vector 14 lword dummy int uart2 transmit for user vector 15 lword dummy int uart2 receive for user vector 16 lword dummy _int uartO transmit for user vector 17 lword dummy _int uart0 receive for user vector 18 lword OFF900h uartl transmit used by ROM Monitor vector 19 lwo
6. RENESAS APPLICATION NOTE M16C 62 C Compiler Startup Files for the M16C 62 MCU 1 0 Abstract The following article describes the Startup files for the NC30 C compiler A set of customized Startup files is given for the M30624 version of the M16C 62 microcontroller 2 0 Introduction The Renesas M16C 62 is a 16 bit MCU based on the M16C CPU core with features including 10 bit A D D A UARTS timers DMA 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 0 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 starter kits is described in section 7 1 and referred to as ncrt0_62askp a30 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 requi
7. RENESAS TECHNOLOGY CORPORATION All Rights Reserved Id PRR kkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkk kkk list OFF REU05B0006 0100Z June 2003 Page 3 of 12 M16C 62 E ZE N ESAS C Compiler Startup Files for the M16C 62 MCU include sect30 62askp inc list ON Interrupt section start insf start S 0 for stkviewer see Tool Manager and NC30 manuals glb start section interrupt protect equ Oah cm0 equ 06h cm1 equ 07h pml equ 05h after reset execution starts here Upon reset the processor clock bclk is divided by 8 f 8 The ROM Monitor on the Starter Kit sets bclk to f l For consistent stand alone operation bclk is set to f 1 here start ldc istack top isp set istack pointer mov b 03h protect need to set protect register to operate on clock mov b 08h cm0 mode and processor mode registers mov b 08h pml1 ROM Monitor sets this bit set here for stand alone operation allows use of all internal RAM amp ROM mov b 00h protect ldc 0000h flg ensure using register block 0 and use ISP if no RTOS ldc stack top sp set if using an RTOS has no effect otherwis idg data_SE_top sb set sb register for sb relative addressing ldintb VECTOR_ADR nop Delay before fset i enabling interrupts Variable area initialization This code uses macro s see sect30 inc for initializing C variables Clears global variab
8. SAS C Compiler Startup Files for the M16C 62 MCU Special page functions can be specified using pragma SPECIAL directive and the macro defined above Uncomment the proper line below to call the macro See NC30 manual for more information SPECIAL 255 SPECIAL 254 SPECIAL 253 etc SPECIAL 24 SPECIAL 23 SPECIAL 22 SPECIAL 21 SPECIAL 20 SPECIAL 19 SPECIAL 18 fixed vector section The 7 or ed values below commented out are for specifying the ID codes for serial I O flash programming highest 8 bits of the vectors See data sheets for more information Current setting all zeros by default The highest 8 bits of the reset vector is the parallel protection register Caution Setting these codes could result in loss of all flash programming See M30624 data sheets before operating on these values org Offfdch UDI lword dummy int O 000000h OVER_FLOW lword dummy int O 000000h BRKI lword dummy_int ADDRESS MATCH lword dummy_int O 000000h SINGLE_STEP lword dummy int O 000000h WDT lword dummy int O 000000h DBC lword dummy int O 000000h NMI lword dummy int O f 000000h RESET lword start O 000000h REU05B0006 0100Z June 2003 Page 12 of 12 Keep safety first in your circuit designs Renesas Technol
9. les sets initialized variables etc N_BZERO bss_SE top bss_SE N_BZERO bss_SO_top bss_SO N_BZERO bss NE top bss NE N_BZERO bss_ NO top bss_ NO REU05B0006 0100Z June 2003 Page 4 of 12 M16C 62 E ZE N ESAS C Compiler Startup Files for the M16C 62 MCU N_BCOPY data _ SEI _ top data_ SE top data_SE N_BCOPY data_SOI_top data_SO _top data_SO N_BCOPY data NEI top data_NE top data_NE N_BCOPY data_NOI_top data_NO top data_NO FAR area initialize BZERO bss FE top bss FE Copy edata_E 0 section from edata_EI OI section BCOPY data FEI top data_FE top data_FE BCOPY data FOI top data_FO top data_FO heap area initialize Can be removed if not using memory allocate functions glb mbase glb mnext glb __msize mov w heap top amp 0OFFFFH _ mbase mov w heap _top gt gt 16 _ mbase 2 mov w heap top amp OFFFFH mnext mov w heap top gt gt 16 _ mnext 2 mov w HEAPSIZESOFFFFH _ msize mov w HEAPSIZE gt gt 16 _ msizet2 Initialize standard I O do not use default init routine with SKP debugger since it uses UART1 zgib _ init jsr a init required if using I O stream serial port driver Call main function rde 0h fb for debugger on starter kit glb _main jsr a main exit function This function is used in case of accidental return from main or debugging code could be placed here
10. mpiler Startup Files for the M16C 62 MCU org OFFFFEH NUM 2 glb __SPECIAL_ NUM word SPECIAL NUM amp OFFFFH endm Section allocation The following declarations sets the location of the F sections in the physical memory map DO not change these settings without referring to the NC30 manual on startup files SBDATA area section sorg 400H data SE top glb SB section bss SE top section data _ SO top section bss_SO_top near RAM area section data NE top section bss NE top section data NO top section bss NO top SB declare sb section here bss_SE DATA ALIGN data_SO DATA bss_SO DATA data_NE DATA ALIGN bss _ N E DATA ALIGN data_NO DATA bss_NO DATA Stack area If the USP is not required and the RAM allocated to the USP is needed do not modify the declarations below Simply set the USTACKSIZE above to zero E section blkb STACKSIZE stack B DATA REU05B0006 0100Z June 2003 Page 8 of 12 M16C 62 E ZE N ESAS C Compiler Startup Files for the M16C 62 MCU stack top blkb ISTACKSIZE istack_top Heap section If the heap is not required and the RAM F allocated to the heap is needed do not modify the declarations below Simply set the HEAPSIZE above to zero section heap DATA heap _ top b1Lkb HEAPSIZE Near ROM
11. ogy Corporation puts the maximum effort into making semiconductor products better and more reliable but there is always the possibility that trouble may occur with them Trouble with semiconductors may lead to personal injury fire or property damage Remember to give due consideration to safety when making your circuit designs with appropriate measures such as i placement of substitutive auxiliary circuits ii use of nonflammable material or iii prevention against any malfunction or mishap Notes regarding these materials These materials are intended as a reference to assist our customers in the selection of the Renesas Technology Corporation product best suited to the customer s application they do not convey any license under any intellectual property rights or any other rights belonging to Renesas Technology Corporation or a third party Renesas Technology Corporation assumes no responsibility for any damage or infringement of any third party s rights originating in the use of any product data diagrams charts programs algorithms or circuit application examples contained in these materials All information contained in these materials including product data diagrams charts programs and algorithms represents information on products at the time of publication of these materials and are subject to change by Renesas Technology Corporation without notice due to product improvements or other reasons It is therefore recommended tha
12. portation vehicular medical aerospace nuclear or undersea repeater use The prior written approval of Renesas Technology Corporation is necessary to reprint or reproduce in whole or in part these materials If these products or technologies are subject to the Japanese export control restrictions they must be exported under a license from the Japanese government and cannot be imported into a country other than the approved destination Any diversion or reexport contrary to the export control laws and regulations of Japan and or the country of destination is prohibited Please contact Renesas Technology Corporation for further details on these materials or the products contained therein
13. rd OFF900h uartl receive used by ROM Monitor vector 20 lword dummy _int timer AO for user vector 21 lword dummy _int timer Al for user vector 22 lword dummy _int timer A2 for user vector 23 lword dummy _int timer A3 for user vector 24 lword dummy _int timer A4 for user vector 25 lword dummy int timer BO for user vector 26 lword dummy _int timer Bl for user vector 27 lword dummy _int timer B2 for user vector 28 lword dummy int intO for user vector 29 lword dummy _int intl for user vector 30 lword dummy _int int2 for user vector 31 lword dummy _int vector 32 for user or MR30 lword dummy _int vector 33 for user or MR30 lword dummy int vector 34 for user or MR30 lword dummy_int vector 35 for user or MR30 lword dummy _int vector 36 for user or MR30 lword dummy _int vector 37 for user or MR30 lword dummy _int vector 38 for user or MR30 lword dummy _int vector 39 for user or MR30 lword dummy int vector 40 for user or MR30 lword dummy_int vector 41 for user or MR30 lword dummy int vector 42 for user or MR30 lword dummy int vector 43 for user or MR30 lword dummy _int vector 44 for user or MR30 lword dummy _int vector 45 for user or MR30 lword dummy int vector 46 for user or MR30 lword dummy _int vector 47 for user or MR30 fixed vector section section fvector fixed vector table special page definition REU05B0006 0100Z June 2003 Page 11 of 12 M16C 62 E ZE N E
14. res that all global un initialized variables be set to zero and initialized variables are copied from ROM into RAM 4 0 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 starter kits is described in section 7 1 and referred to as sect30_62askp inc 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 nonaligned 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 map sets an external RAM section at address 10000h and an external ROM section at 6000h although the default configuration of the starter kit is in single chip mode with no external memory REU05B0006 0100Z June 2003 Page 1 of 12 M16C 62 C Compiler Startup Files for the M16C 62 MCU 2rRENESAS Address size Section 666606 660466 gt gt 666466 666612 initialized integers long integers 666412 666616 un initialized integers long integers 666422 666661 initialized characters 666423 666061 un initialized character
15. s 666424 6666 66 RAM allocated for stack 666a24 6603 66 RAM allocated for heap 666d24 6652dc 666 666 666662 constant near integers long integers 666 662 666661 lt __ constant near characters 666 663 GO9F Fd 616666 666662 far initialized integers long integers 616662 666662 far un initialized integers long integers 616664 666661 far initialized characters 616665 666661 far un initialized characters 616666 GbffFa Od 6668 660862 far default constant integers long integers 6d 6662 660061 far default constant characters 6d 6663 666612 i eee 846015 666881 This is the ROM area where initialized iables are held and copied to RAM by the 6d 6616 888882 vana 60018 900001 a Startup program Haki spr lt _ interrupt functions code stored here 6d 88F9 81e767 lt _ program code stored here i a etere lt variable vector table section OF OOOO OOFFdc Of fFdc 666024 lt fixed vector table section BFFFFF Figure 1 M16C 62 Memory Map of Startup Files 5 0 Automatic Installation When starting a new project using TOOL MANAGER Renesas development environment the project wizard will ask if you wish to have the default startup files copied into the project s working directory In order to have the project wizard copy the custom files instead replace the default files with the custom startup files in the directory c MTOOL SRC30 STARTUP
16. t customers contact Renesas Technology Corporation or an authorized Renesas Technology Corporation product distributor for the latest product information before purchasing a product listed herein The information described here may contain technical inaccuracies or typographical errors Renesas Technology Corporation assumes no responsibility for any damage liability or other loss rising from these inaccuracies or errors Please also pay attention to information published by Renesas Technology Corporation by various means including the Renesas Technology Corporation Semiconductor home page http www renesas com When using any or all of the information contained in these materials including product data diagrams charts programs and algorithms please be sure to evaluate all information as a total system before making a final decision on the applicability of the information and products Renesas Technology Corporation assumes no responsibility for any damage liability or other loss resulting from the information contained herein Renesas Technology Corporation semiconductors are not designed or manufactured for use in a device or system that is used under circumstances in which human life is potentially at stake Please contact Renesas Technology Corporation or an authorized Renesas Technology Corporation product distributor when considering the use of a product contained herein for any specific purposes such as apparatus or systems for trans
Download Pdf Manuals
Related Search
Related Contents
"user manual" Horizon User Guide Philips AZ 2048/00 User's Manual DeLOCK Displayport/mini Displayport USER`S MANUAL 170-543-0004 - Bison Gear and Engineering Sony SU-EF41 User's Manual Technical-Spotlight_vol12 Istruzioni - Fiorucciricambi Samsung AVXDSH022EE Instrukcja obsługi Copyright © All rights reserved.
Failed to retrieve file