liubeihua 发表于 2006-5-25 11:48:03

在ICCAVR中如何修改启动文件

在使用ICCAVR编程时如发生看门狗复位,ram区被清除,如何修改启动文件使ram区不被清除。

在使用ATmega16芯片时有几个相关的文件:area.s,crtatmega.s,init.s。修改那个文件,那个部位请指教。



回复邮箱:ymdz0706@sina.com

machao 发表于 2006-5-26 20:21:21

Startup File



The linker links in the startup file before your files, and links the standard library libcavr.a with your program. The startup file is one of the following depending on the target device:



crtavr.o                Normal startup file

        crtatmega.o                ATmega startup. Uses "jmp __start" as the reset vector

        crtavrram.o                Normal startup file that also initializes the external SRAM

        crtatmegaram.o        ATmega startup file that also initializes the external SRAM

        crtboot.o                Normal bootloader startup file. Differs from crtavr.o in that it relocates the interrupt vector.

        crtboothi.o                Same as crtboot.o but uses ELPM and initializes RAMPZ to 1.



You may create your own startup file if you wish. See Project->Options->Target->NonDefaultStartup The startup file defines a global symbol __start which is the starting point of your program. The startup file functions are:



1.        Initialize the hardware and software stack pointers.

2.        Copy the initialized data from the idata area to the data area.

3.        Initialize the bss area to zero.

4.        Call the user main routine.

5.        Define the entry point for exit, which is defined as an infinite loop. If main ever returns, it will enter exit and gets stuck there (so much for "exit").



The startup also defines the reset vector. You do not need to modify the startup file to use other interrupts, see Interrupt Handlers

. Compiling or assembling the startup file requires a special switch to the assembler (-n). You can still use the IDE to compile a Startup file, just use the File->CompilerFileTo...StartupFileToObject command.



To modify and use a new startup file:



cd \icc\libsrc.avr                ; or wherever you install the compiler



<edit crtavr.s>



<open crtavr.s using the IDE>        ;



<Choose "Compile File To->Object">        ;generate a new crtavr.o



copy crtavr.o ..\lib                ; copy to the library directory



Note that you must either specify the startup with an absolute pathname or it must be located in the directory specified by the Project Options Library path.
页: [1]
查看完整版本: 在ICCAVR中如何修改启动文件