ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 13.06.2025
Просмотров: 2197
Скачиваний: 0
CodeVisionAVR
For devices that allow self-programming the Program Type can be selected as:
•Application
•Boot Loader
If the Boot Loader program type was selected, a supplementary Boot Loader Debugging in AVR Studio option is available.
If this option is enabled, the compiler will generate supplementary code that allows the Boot Loader to be source level debugged in the AVR Studio simulator/emulator.
When programming the chip with the final Boot Loader code, the Boot Loader Debugging option must be disabled.
© 1998-2007 HP InfoTech S.R.L. |
Page 25 |
CodeVisionAVR
The (s)printf features option allows to select which versions of the printf and sprintf Standard C Input/Oputput Functions will be linked in your project:
•int - the following conversion type characters are supported: 'c', 's', 'p', 'i', 'd', 'u', 'x', 'X', '%', no width or precision specifiers are supported, only the '+' and ' ' flags are supported, no input size modifiers are supported
•int, width - the following conversion type characters are supported: 'c', 's', 'p', 'i', 'd', 'u', 'x', 'X', '%', the width specifier is supported, the precision specifier is not supported, only the '+', '-', '0' and ' ' flags are supported, no input size modifiers are supported
•long, width - the following conversion type characters are supported: 'c', 's', 'p', 'i', 'd', 'u', 'x', 'X', '%' the width specifier is supported, the precision specifier is not supported, only the '+', '-', '0' and ' ' flags are supported, only the 'l' input size modifier is supported
•long, width, precision - the following conversion type characters are supported: 'c', 's', 'p', 'i', 'd', 'u', 'x', 'X', '%', the width and precision specifiers are supported, only the '+', '-', '0' and ' ' flags are supported, only the 'l' input size modifier is supported
•float, width, precision - the following conversion type characters are supported: 'c', 's', 'p', 'i', 'd', 'u', 'e', 'E', 'f', 'x', 'X', '%', the width and precision specifiers are supported, only the '+', '-', '0' and ' ' flags are supported, only the 'l' input size modifier is supported.
The more features are selected, the larger is the code size generated for the printf and sprintf functions.
The (s)scanf features option allows to select which versions of the scanf and sscanf Standard C Input/Oputput Functions will be linked in your project:
•int, width - the following conversion type characters are supported: 'c', 's', 'i', 'd', 'u', 'x', '%', the width specifier is supported, no input size modifiers are supported
•long, width - the following conversion type characters are supported: 'c', 's', 'i', 'd', 'u', 'x', '%' the width specifier is supported, only the 'l' input size modifier is supported.
The more features are selected, the larger is the code size generated for the printf and sprintf functions.
The Data Stack Size must be also specified.
If the dynamic memory allocation functions from the Standard Library are to be used, the Heap size must be also specified.
It can be calculated using the following formulae:
heap _ size =(n +1) 4 +∑n block _ sizei
i=1
where: n is the number of memory blocks that will be allocated in the heap block _ sizei is the size of the memory block i
If the memory allocation functions will not be used, then the Heap size must be specified as zero.
Eventually you may also specify the External SRAM Size (in case the microcontroller have external SRAM memory connected).
The External SRAM Wait State option enables the insertion of wait states during access to the external SRAM. This is useful when using slow memory devices.
© 1998-2007 HP InfoTech S.R.L. |
Page 26 |
CodeVisionAVR
If an Atmel AT94K05, AT94K10, AT94K20 or AT94K40 FPSLIC device will be used, than there will be the possibility to specify the Program SRAM size in Kwords.
The maximum size of the global bit variables, which are placed in the GPIOR (if present) and registers R2 to R14, can be specified using the Bit Variables size list box.
The Use GPIOR >31 option, when checked, allows using GPIOR located at addresses above 31 for global bit variables.
Note that bit variables located in GPIOR above address 31 are accessed using the IN, OUT, OR , AND instructions, which leads to larger and slower code than for bit variables located in GPIOR with the address range 0…31, which use the SBI, CBI instructions. Also the access to bit variables located in GPIOR above address 31 is not atomic.
Therefore it is recommended to leave the Use GPIOR >31 option not checked if the number of global bit variables is small enough and no additional registers are needed for their storage.
Checking the Promote char to int check box enables the ANSI promotion of char operands to int. This option can also be specified using the #pragma promotechar compiler directive.
Promoting char to int leads to increased code size and lower speed for an 8 bit chip microcontroller like the AVR.
If the char is unsigned check box is checked, the compiler treats by default the char data type as an unsigned 8 bit in the range 0…255.
If the check box is not checked the char data type is by default a signed 8 bit in the range –128…127. This option can also be specified using the #pragma uchar compiler directive.
Treating char as unsigned leads to better code size and speed.
© 1998-2007 HP InfoTech S.R.L. |
Page 27 |
CodeVisionAVR
If the 8 bit enums check box is checked, the compiler treats the enumerations as being of 8 bit char data type, leading to improved code size and execution speed of the compiled program. If the check box is not checked the enumerations are considered as 16 bit int data type as required by ANSI.
The Enhanced Instructions check box allows enabling or disabling the generation of Enhanced Core instructions for the new ATmega and AT94K FPSLIC devices.
The Smart Register Allocation check box enables allocation of registers R2 to R14 (not used for bit variables) and R16 to R21 in such a way that 16bit variables will be preferably located in even register pairs, thus favouring the usage of the enhanced core MOVW instruction for their access. This option is effective only if the Enhanced Instructions check box is also checked.
If Smart Register Allocation is not enabled, the registers will be allocated in the order of variable declaration.
The Smart Register Allocation option should be disabled if the program was developed using CodeVisionAVR prior to V1.25.3 and it contains inline assembly code that accesses the variables located in registers R2 to R14 and R16 to R21.
The registers in the range R2 to R14, not used for bit variables, can be automatically allocated to char and int global variables and global pointers by checking the Automatic Register Allocation check box.
Checking the Word Align FLASH Struct Members option enables aligning of the members of structures located in FLASH memory to an even (word) address.
This option is present only for compatibility with projects created with CodeVisionAVR prior to V1.24.4a.
For new projects this option must be left unchecked, leading to smaller code size.
An external startup file can be used by checking the Compilation|Use an External Startup File check box.
For debugging purposes you have the option Stack End Markers. If you select it, the compiler will place the strings DSTACKEND, respectively HSTACKEND, at the end of the Data Stack, respectively
Hardware Stack areas.
When you debug the program with the AVR Studio debugger you may see if these strings are overwritten, and consequently modify the Data Stack Size.
When your program runs correctly you may disable the placement of the strings in order to reduce code size.
Using the File Output Format(s) list box you can select the following formats for the files generated by the compiler:
•COFF (required by the Atmel AVR Studio debugger), ROM, Intel HEX and EEP (required by the In-System Programmer) ;
•Atmel generic OBJ, ROM, Intel HEX and EEP (required by the In-System Programmer).
If the COFF file format is selected and the Use the Terminal I/O in AVR Studio 3 check box is checked, special debugging information is generated in order to use the AVR Studio 3 Terminal I/O window for communication with the simulated AVR chip’s UART.
AVR Studio 4 does not yet support this option.
If the Use the Terminal I/O in AVR Studio 3 option is enabled, the UART or USART code will not run correctly on the real AVR chip. This option is only for debugging purposes.
© 1998-2007 HP InfoTech S.R.L. |
Page 28 |
CodeVisionAVR
The Advanced tab, which is present only in the Professional version of the compiler, enables more detailed custom configuration like the number and jump type of the interrupt vectors and memory usage:
© 1998-2007 HP InfoTech S.R.L. |
Page 29 |
CodeVisionAVR
The Messages tab allows to individually enable or disable various compiler warnings:
The generation of warning messages during compilation can be globaly enabled or disabled by using the Enable Warnings check box.
© 1998-2007 HP InfoTech S.R.L. |
Page 30 |
CodeVisionAVR
The Globally #define tab allows to #define macros that will be visible in all the project files. For example:
will be equivalent with placing the definition:
#define ABC 1234
in each project file.
© 1998-2007 HP InfoTech S.R.L. |
Page 31 |
CodeVisionAVR
The Paths tabs allows to specify additional paths for #include and library files. These paths must be entered one per line in the appropriate edit controls.
Changes can be saved, respectively canceled, using the OK, respectively Cancel buttons.
© 1998-2007 HP InfoTech S.R.L. |
Page 32 |
CodeVisionAVR
2.2.4.3 Executing an User Specified Program before Make
This option is available if you select the Before Make tab in the Project Configure window.
If you check the Execute User’s Program option, then a program, that you have previously specified, will be executed before the compilation/assembly process.
The following parameters can be specified for the program to be executed:
•Program Directory and File Name
•Program Command Line Parameters
•Program Working Directory.
© 1998-2007 HP InfoTech S.R.L. |
Page 33 |
CodeVisionAVR
2.2.4.4 Transferring the Compiled Program to the AVR Chip after Make
This option is available if you select the After Make tab in the Project Configure window.
If you check the Program the Chip option, then after successful compilation/assembly your program will be automatically transferred to the AVR chip using the built-in Programmer software.
The following steps are executed automatically:
•Chip erasure
•FLASH and EEPROM blank check
•FLASH programming and verification
•EEPROM programming and verification
•Fuse and Lock Bits programming
© 1998-2007 HP InfoTech S.R.L. |
Page 34 |
CodeVisionAVR
The Merge data from a .ROM File for FLASH Programming option, if checked, will merge in the FLASH programming buffer the contents of the .ROM file, created by the compiler after Make, with the data from the .ROM file specified in .ROM File Path.
This is useful, for example, when adding a boot loader executable compiled in another project, to an application program that will be programmed in the FLASH memory.
The SCK clock frequency used for In-System Programming with the STK500, AVRISP or AVRISP MkII can be specified using the SCK Freq. listbox. This frequency must not exceed ¼ of the chip’s clock frequency.
If the chip you have selected has Fuse Bit(s) that may be programmed, then a supplementary Program Fuse Bit(s) check box will appear.
If it is checked, than the chip’s Fuse Bit(s) will be programmed after Make.
The Fuse Bit(s) can set various chip options, which are described in the Atmel data sheets.
If a Fuse Bit(s) check box is checked, then the corresponding fuse bit will be set to 0, the fuse being considered as programmed (as per the convention from the Atmel data sheets).
If a Fuse Bits(s) check box is not checked, then the corresponding fuse bit will be set to 1, the fuse being considered as not programmed.
If you wish to protect your program from copying, you must select the corresponding option using the
FLASH Lock Bits radio box.
If you wish to check the chip's signature before programming you must use the Check Signature option.
To speed up the programming process you can uncheck the Check Erasure check box. In this case there will be no verification of the correctness of the FLASH erasure.
The Preserve EEPROM checkbox allows preserving the contents of the EEPROM during chip erasure.
To speed up the programming process you can uncheck the Verify check box.
In this case there will be no verification of the correctness of the FLASH and EEPROM programming.
Changes can be saved, respectively canceled, using the OK, respectively Cancel buttons.
© 1998-2007 HP InfoTech S.R.L. |
Page 35 |
CodeVisionAVR
2.2.4.5 Executing an User Specified Program after Make
This option is available if you select the After Make tab in the Project Configure window.
If you check the Execute User’s Program option, then a program, that you have previously specified, will be executed after the compilation/assembly process.
© 1998-2007 HP InfoTech S.R.L. |
Page 36 |
CodeVisionAVR
Using the Program Settings button you can modify the:
•Program Directory and File Name
•Program Command Line Parameters
•Program Working Directory
Changes can be saved, respectively canceled, using the OK, respectively Cancel buttons.
© 1998-2007 HP InfoTech S.R.L. |
Page 37 |