Download AVR GCC Tutorial (WinAVR)
Transcript
available then in the entire project likewise under the designation F_CPU e.g. to derive (in order from it UART, MIRROR-IMAGE or ADC frequency settings). The indication has purely a “informative” character, which becomes actual clock rate over the external clock (e.g. quartz) and/or the attitude of the internal R/C oscillator determines. The use of F_CPU makes thus sense only if the indication agrees with the actual clock. Within avr libc starting from version the 1.2 (contained in WinAVR starting from 2/2005) the definition of the clock frequency (F_CPU) is used for the computation of the wait functions in avr/delay.h. These function correctly only if F_CPU agrees with the actual clock frequency. F_CPU must be defined in addition however not necessarily in Makefile. It is sufficient, will however with repeated application unclearly to insert UL before #include <avr/delay.h> a #define F_CPU [here clock in cycles per second]. See in addition the appropriate section of the documentation. Input files for simulation in AVR Studio With older AVR Studio versions one can simulate only on basis of so-called coff files. Newer versions of AVR Studio (starting from 4.10.356) support besides the more modern however still experimental dwarf-2-Format, which is produced starting from WinAVR 20040722 (avr GCC 3.4.1/Binutils inclusive Atmel add ons) “directly” by the compiler. Proceeding with dwarf-2 • in the Makefile with DEBUG: DEBUG=dwarf-2 • • • • make all (possibly before make clean) the produced elf-file (in the example above superprog.elf) into AVR Studio load AVR simulator and to simulating microcontrollers select, “finish” further see AVR Studio on-line assistance Proceeding with extcoff (Should be only used in exceptional cases) • in the Makefile with DEBUG: DEBUG=stabs • • • • make extcoff (possibly before make clean) the produced cof file (in the example above superprog.cof) into AVR Studio load AVR simulator and to simulating microcontrollers select, “finish” further see AVR Studio on-line assistance When simulating often “variables seem to be missing”. A cause for it is that the compiler assigns the “variables” directly to registers. This can be avoided, as the optimization is switched off (in Makefile). One simulated then however a program deviating strongly from the optimized code. Switching the optimization off is not recommended. Instead of the software simulator the AVR Studio can be also used, in order to debug with the ATMEL JTAGICE, a reproduction of it (Boot ICE, Evertool.) or the ATMEL JTAGICE MKII “in system”. In addition