Mini-FAQ about AVR-GCC by Volker Oth 7/2000 Preface -use WinZip or another decompressor able to reconstruct long file names, else you will run into problems. Also remember to tell your decompressor to reconstruct the directory tree inside the zip file. -the make currently used is case sensitive, so please don't rename the example's makefiles to upper case and don't create your own makefile upper case. -before compiling the first time in a session, set the environment variables (e.g. call run.bat in the root dir) -to program motorola output files into your STK200, use ISP V2.4 or above (get it from the Atmel site "http://www.atmel.com"). -if there are smaller fixes available on my website (e.g. install fix), please use them! There are separate fixes as long as they're not included in the main archive! -if you have other versions of GCC installed on your machine, please don't use environment variables like GCC_EXEC_PREFIX globally. Have a look at run.bat in the AVR-GCC root directory to see how this can be handles in a clean way. 1) *Q*: I get the following warning when compiling: "Warning: Virtual symbol `__overflow0_' is assigned new value.". What does this mean? *A*: if you've defined an interrupt handler for a certain interrupt, the standard entry in the vector table is overwritten (reti). This is accompanied by the above message for each interrupt handler you defined. 2) *Q*: Which devices are supported? *A*: devices known to work are AT90S8515, AT90S8535, AT90S2313, Mega103 and Mega603. Devices most probably working are: 2323, 2343, 4414, 4434. Not supported is the 1200 (limited instruction set and very small memory). 3) *Q*: What has to be done to compile for a certain device ? *A*: you have to tell the compiler which device to include by using the option "-mmcu=at90s2313" (for the 2313). By using this parameter, "AVR_AT90S2313" is defined and thus, the right io header file (io2313.h) is included automatically from io.h. Secondly, you have to link the right runtime library to your program. For the 2313 e.g. it's "gcrt1-2313.o". If you're using my makefiles, all you have to do is change the "MCU = ..." line in the makefile. So setting "MCU = at90s2313" (the "-" is important) will all you have to do. 4) *Q*: Are floating point calculations supported? *A*: yes, by default. There is however a library called "libm.a", which is always included, however floating point comparisons have reported to be buggy! For a floating point example, look at gcctest6. If you don't use any float calculations, the library won't be linked! 5) *Q*: In which segment are variables defined as "CONST" stored? *A*: "CONST" is ignored,they are treated like variables in RAM by the linker. 6) *Q*: Is it possible to put constants into program memory? *A*: Yes, there are macros defined in "progmem.h". To define a string in flash rom, use char __attribute__ ((progmem)) my_great_string = "blah"; char __attribute__ ((progmem)) array[12]; To read a value from flash, you need to use y = PRG_RDB(&array[x]) if "array" is your table and "x" the index. You may have a look at my gcctest8 example which covers this. 7) *Q*: A global variable is changed in an interrupt routine, but in the main program, the changed value doesn't seem to be recognized. Is this a bug? *A*: You have to declare the global variable "volatile" (e.g. "volatile int flag;"). This hinders the compiler from optimizing too much. 8) *Q*: How can I get constants into the EEPROM segment? *A*: In avr-gcc you can write: int k[10] __attribute__ ((section (".eeprom"))) = {1,2,3,4,5,6,7,8,9}; This results in: seg eeprom.data public _k: dc.w (1) & 0xffff dc.w (2) & 0xffff dc.w (3) & 0xffff dc.w (4) & 0xffff dc.w (5) & 0xffff dc.w (6) & 0xffff dc.w (7) & 0xffff dc.w (8) & 0xffff dc.w (9) & 0xffff ds.b 2 Look at GccTest5 to see how to read from/write to the internal eeprom. 9) *Q*: Why do watches refuse to work when debugging in AVR-Studio? *A*: This happens because the symbolic debug info is not translated from the internal Gnu-format into the proprietary Atmel format. I'm not entirely sure if all the needed information is there in the gnu format and it's just a translation problem or if the info's just not there. However, only the line number is properly translated, but AVRStudio doesn't know anymore if register x is related to variable y. This is also true for global variables where the address x can't be identified to be the variable y. 10) *Q*: When I want do load an obj file into AVR-Studio, the following message appears: "Error one or more source files cannot be found". What's wrong? *A*: AVRStudio tries to locate all the source code used for this object file, also that of the libraries. To ensure this, the libraries need to contain the full path of their source code files on YOUR computer. This is done by compiling the libraries anew while installing. Therefore, you should use "install.exe" to install properly. If there is a separate version (install-fix) available, please use this version! 11) *Q*: How do I tell the compiler to use external SRAM? *A*: I you just want to access the external RAM with absolute pointers, you just need to access the SRE-Bit in the MCUCR-Register. However to use external RAM just like internal RAM you need to tell the linker how many RAM you have. This is done in the linker scripts which are located in avr/lib/ldscripts. The one resposible for the mega103 e.g. is named avrmega103.x. Instead of changing the original, you might copy in into your project directory and tell the linker to use it. This should be possible with the following parameter (LDFLAGS): -Wl,--script,MyOwnScript.x The line responsible for the data segment is data (rw!x) : ORIGIN = 0x60, LENGTH = 4K which you have to change to something like data (rw!x) : ORIGIN = 0x60, LENGTH = 64k or similair ... the 0x60 first Bytes are used for the registers by the way. 12) *Q*: AVR-GCC complains about accessing the special purpose register like this DDRB |= (1<