HP CODEVision AVR User Manual

CodeVisionAVR
VERSION 1.23.9b
User Manual
CodeVisionAVR
CodeVisionAVR V1.23.9b User Manual Revision 20/11.2003 Copyright © 1998-2003 Pavel Haiduc and HP InfoTech S.R.L. All rights reserved. No part of this document may be reproduced in any form except by written permission of the author. All rights of translation reserved.
© 1998-2003 HP InfoTech S.R.L.
Page 1
CodeVisionAVR

Table of Contents

Table of Contents .................................................................................................................................. 2
1. Introduction........................................................................................................................................ 7
2. CodeVisionAVR Integrated Development Environment................................................................ 8
2.1 Working with Files ........................................................................................................................ 8
2.1.1 Creating a New File .............................................................................................................. 8
2.1.2 Opening an Existing File....................................................................................................... 9
2.1.3 Files History .......................................................................................................................... 9
2.1.4 Editing a File ....................................................................................................................... 10
2.1.5 Saving a File ....................................................................................................................... 11
2.1.6 Renaming a File.................................................................................................................. 11
2.1.7 Printing a File...................................................................................................................... 12
2.1.8 Closing a File ...................................................................................................................... 13
2.1.9 Using the Navigator ............................................................................................................ 14
2.2 Working with Projects ................................................................................................................. 15
2.2.1 Creating a New Project....................................................................................................... 15
2.2.2 Opening an Existing Project ...............................................................................................17
2.2.3 Adding Notes or Comments to the Project ......................................................................... 18
2.2.4 Configuring the Project ....................................................................................................... 19
2.2.5 Obtaining an Executable Program...................................................................................... 32
2.2.6 Closing a Project................................................................................................................. 38
2.3 Tools ........................................................................................................................................... 39
2.3.1 The AVR Studio Debugger ................................................................................................. 39
2.3.2 The AVR Chip Programmer................................................................................................ 40
2.3.3 The Serial Communication Terminal .................................................................................. 44
2.3.4 Executing User Programs...................................................................................................45
2.4 IDE Settings................................................................................................................................ 47
2.4.1 General Settings ................................................................................................................. 47
2.4.2 Configuring the Editor ......................................................................................................... 48
2.4.3 Configuring the Assembler .................................................................................................49
2.4.4 Setting the Debugger Path .................................................................................................50
2.4.5 AVR Chip Programmer Setup ............................................................................................ 51
© 1998-2003 HP InfoTech S.R.L.
Page 2
CodeVisionAVR
2.4.6 Serial Communication Terminal Setup ............................................................................... 53
2.5 Accessing the Help..................................................................................................................... 54
2.6 Transferring the License to another computer ........................................................................... 54
2.7 Connecting to HP InfoTech's Web Site ...................................................................................... 57
2.8 Contacting HP InfoTech by E-Mail ............................................................................................. 57
2.9 Quitting the CodeVisionAVR IDE ............................................................................................... 57
3. CodeVisionAVR C Compiler Reference ........................................................................................ 58
3.1 The Preprocessor ....................................................................................................................... 58
3.2 Comments .................................................................................................................................. 63
3.3 Reserved Keywords ................................................................................................................... 64
3.4 Identifiers .................................................................................................................................... 65
3.5 Data Types ................................................................................................................................. 65
3.6 Constants.................................................................................................................................... 66
3.7 Variables..................................................................................................................................... 67
3.7.1 Specifying the SRAM Storage Address for Global Variables............................................. 69
3.7.2 Bit Variables........................................................................................................................ 69
3.7.3 Allocation of Variables to Registers.................................................................................... 70
3.7.4 Structures ........................................................................................................................... 71
3.7.5 Unions................................................................................................................................. 74
3.7.6 Enumerations...................................................................................................................... 76
3.7.7 Global Variables Memory Map File .................................................................................... 77
3.8 Defining Data Types ................................................................................................................... 77
3.9 Type Conversions....................................................................................................................... 78
3.10 Operators.................................................................................................................................. 79
3.11 Functions .................................................................................................................................. 80
3.12 Pointers..................................................................................................................................... 81
3.13 Accessing the I/O Registers ..................................................................................................... 83
3.13.1 Bit level access to the I/O Registers................................................................................. 84
3.14 Accessing the EEPROM........................................................................................................... 85
3.15 Using Interrupts ........................................................................................................................ 86
3.16 SRAM Memory Organization.................................................................................................... 87
3.17 Using an External Startup File.................................................................................................. 89
3.18 Including Assembly Language in Your Program ...................................................................... 91
© 1998-2003 HP InfoTech S.R.L.
Page 3
CodeVisionAVR
3.18.1 Calling Assembly Functions from C.................................................................................. 92
3.19 Creating Libraries ..................................................................................................................... 93
3.20 Using the AVR Studio Debugger..............................................................................................96
3.20.1 Using the AVR Studio Debugger version 3 ...................................................................... 96
3.20.2 Using the AVR Studio Debugger version 4.06 or later ..................................................... 97
3.21 Hints.......................................................................................................................................... 98
3.22 Limitations................................................................................................................................. 98
4. Library Functions Reference.......................................................................................................... 99
4.1 Character Type Functions ........................................................................................................ 100
4.2 Standard C Input/Output Functions.......................................................................................... 101
4.3 Standard Library Functions ...................................................................................................... 105
4.4 Mathematical Functions............................................................................................................ 106
4.5 String Functions........................................................................................................................ 109
4.6 Variable Length Argument Lists Macros .................................................................................. 114
4.7 Non-local Jump Functions ........................................................................................................ 115
4.8 BCD Conversion Functions ...................................................................................................... 116
4.9 Gray Code Conversion Functions ............................................................................................ 116
4.10 Memory Access Functions ..................................................................................................... 117
4.11 LCD Functions........................................................................................................................ 118
4.11.1 LCD Functions for displays with up to 2x40 characters ................................................. 118
4.11.2 LCD Functions for displays with 4x40 characters .......................................................... 121
4.11.3 LCD Functions for displays connected in 8 bit memory mapped mode......................... 123
4.12 I2C Bus Functions ................................................................................................................... 125
4.12.1 National Semiconductor LM75 Temperature Sensor Functions .................................... 127
4.12.2 Dallas Semiconductor DS1621 Thermometer/Thermostat Functions............................ 129
4.12.3 Philips PCF8563 Real Time Clock Functions................................................................. 132
4.12.4 Philips PCF8583 Real Time Clock Functions................................................................. 135
4.12.5 Dallas Semiconductor DS1307 Real Time Clock Functions .......................................... 138
4.13 Dallas Semiconductor DS1302 Real Time Clock Functions .................................................. 140
4.14 1 Wire Protocol Functions ...................................................................................................... 142
4.14.1 Dallas Semiconductor DS1820/DS18S20 Temperature Sensors Functions ................. 144
4.14.2 Dallas Semiconductor DS2430 EEPROM Functions ..................................................... 148
4.14.3 Dallas Semiconductor DS2433 EEPROM Functions ..................................................... 151
© 1998-2003 HP InfoTech S.R.L.
Page 4
CodeVisionAVR
4.15 SPI Functions ......................................................................................................................... 154
4.16 Power Management Functions............................................................................................... 157
4.17 Delay Functions...................................................................................................................... 158
5. CodeWizardAVR Automatic Program Generator ....................................................................... 159
5.1 Setting the AVR Chip Options .................................................................................................. 162
5.2 Setting the External SRAM....................................................................................................... 164
5.3 Setting the Input/Output Ports .................................................................................................. 166
5.4 Setting the External Interrupts .................................................................................................. 167
5.5 Setting the Timers/Counters..................................................................................................... 169
5.6 Setting the UART or USART .................................................................................................... 174
5.7 Setting the Analog Comparator ................................................................................................ 177
5.8 Setting the Analog-Digital Converter ........................................................................................ 178
5.9 Setting the SPI Interface........................................................................................................... 181
5.10 Setting the Universal Serial Interface - USI............................................................................ 182
5.11 Setting the I2C Bus ................................................................................................................. 184
5.11.1 Setting the LM75 devices ............................................................................................... 185
5.11.2 Setting the DS1621 devices ........................................................................................... 186
5.11.3 Setting the PCF8563 devices ......................................................................................... 187
5.11.4 Setting the PCF8583 devices ......................................................................................... 188
5.11.5 Setting the DS1307 devices ........................................................................................... 189
5.12 Setting the 1 Wire Bus............................................................................................................ 191
5.13 Setting the 2 Wire Bus............................................................................................................ 193
5.14 Setting the ATmega169 LCD Controller................................................................................. 194
5.15 Setting the LCD ...................................................................................................................... 195
5.16 Setting Bit-Banged Peripherals .............................................................................................. 196
5.17 Specifying the Project Information.......................................................................................... 197
6. License Agreement ....................................................................................................................... 198
6.1 Software License ...................................................................................................................... 198
6.2 Liability Disclaimer.................................................................................................................... 198
6.3 Restrictions ............................................................................................................................... 198
6.4 Operating License .................................................................................................................... 198
6.5 Back-up and Transfer ............................................................................................................... 198
6.6 Terms........................................................................................................................................ 199
© 1998-2003 HP InfoTech S.R.L.
Page 5
CodeVisionAVR
6.7 Other Rights and Restrictions................................................................................................... 199
7. Technical Support ......................................................................................................................... 200
8. Contact Information ...................................................................................................................... 201
© 1998-2003 HP InfoTech S.R.L.
Page 6
CodeVisionAVR

1. Introduction

CodeVisionAVR is a C cross-compiler, Integrated Development Environment and Automatic Program Generator designed for the Atmel AVR family of microcontrollers. The program is a native 32bit application that runs under the Windows 95, 98, NT 4, 2000 and XP operating systems. The C cross-compiler implements nearly all the elements of the ANSI C language, as allowed by the AVR architecture, with some features added to take advantage of specificity of the AVR architecture and the embedded system needs. The compiled COFF object files can be C source level debugged, with variable watching, using the Atmel AVR Studio debugger. The Integrated Development Environment (IDE) has built-in AVR Chip In-System Programmer software that enables the automatical transfer of the program to the microcontroller chip after successful compilation/assembly. The In-System Programmer software is designed to work in conjunction with the Atmel STK500/AVRISP/AVRProg (AVR910 application note), Kanda Systems STK200+/300, Dontronics DT006, Vogel Elektronik VTEC-ISP, Futurlec JRAVR and MicroTronics' ATCPU/Mega2000 development boards. For debugging embedded systems, which employ serial communication, the IDE has a built-in Terminal. Besides the standard C libraries, the CodeVisionAVR C compiler has dedicated libraries for:
Alphanumeric LCD modules
Philips I2C bus
National Semiconductor LM75 Temperature Sensor
Philips PCF8563, PCF8583, Dallas Semiconductor DS1302 and DS1307 Real Time Clocks
Dallas Semiconductor 1 Wire protocol
Dallas Semiconductor DS1820/DS18S20 Temperature Sensors
Dallas Semiconductor DS1621 Thermometer/Thermostat
Dallas Semiconductor DS2430 and DS2433 EEPROMs
SPI
Power management
Delays
Gray code conversion.
CodeVisionAVR also contains the CodeWizardAVR Automatic Program Generator, that allows you to write, in a matter of minutes, all the code needed for implementing the following functions:
External memory access setup
Chip reset source identification
Input/Output Port initialization
External Interrupts initialization
Timers/Counters initialization
Watchdog Timer initialization
UART initialization and interrupt driven buffered serial communication
Analog Comparator initialization
ADC initialization
SPI Interface initialization
2
C Bus, LM75 Temperature Sensor, DS1621 Thermometer/Thermostat and PCF8563, PCF8583,
I DS1302, DS1307 Real Time Clocks initialization
1 Wire Bus and DS1820/DS18S20 Temperature Sensors initialization
LCD module initialization.
This product is © Copyright 1998-2003 Pavel Haiduc and HP InfoTech S.R.L., all rights reserved. The author of the program wishes to thank Mr. Jack Tidwell for his great help in the implementation of floating point routines and to Mr. Yuri G. Salov for his excellent work in improving the Mathematical Functions Library and beta testing CodeVisionAVR.
© 1998-2003 HP InfoTech S.R.L.
Page 7
CodeVisionAVR

2. CodeVisionAVR Integrated Development Environment

2.1 Working with Files

Using the CodeVisionAVR IDE you can view and edit any text file used or produced by the C compiler or assembler.

2.1.1 Creating a New File

You can create a new source file using the File|New menu command or by pressing the Create new file button on the toolbar.
A dialog box appears, in which you must select File Type|Source and press the Ok button.
A new editor window appears for the newly created file. The new file has the name untitled.c. You can save this file under a new name using the File|Save
As menu command.
© 1998-2003 HP InfoTech S.R.L.
Page 8
CodeVisionAVR

2.1.2 Opening an Existing File

You can open an existing file using the File|Open menu command or by pressing the Open file button on the toolbar. An Open dialog window appears.
You must select the name and type of file you wish to open. By pressing the Open button you will open the file in a new editor window.

2.1.3 Files History

The CodeVisionAVR IDE keeps a history of the opened files. The most recent eight files that where used can be reopened using the File|Reopen menu command.
© 1998-2003 HP InfoTech S.R.L.
Page 9
CodeVisionAVR

2.1.4 Editing a File

A previously opened or a newly created file can be edited in the editor window by using the Tab, Arrows, Backspace and Delete keys.
Pressing the Home key moves the cursor to the start of the current text line. Pressing the End key moves the cursor to the end of the current text line. Pressing the Ctrl+Home keys moves the cursor to the start of the file. Pressing the Ctrl+End keys moves the cursor to the end of the file.
Portions of text can be selected by dragging with the mouse. You can copy the selected text to the clipboard by using the Edit|Copy menu command, by pressing the Ctrl+C keys or by pressing the Copy button on the toolbar. By using the Edit|Cut menu command, by pressing the Ctrl+X keys or by pressing the Cut button on the toolbar, you can copy the selected text to the clipboard and then delete it from the file. Text previously saved in the clipboard can be placed at the current cursor position by using the Edit|Paste menu command, by pressing the Ctrl+V keys or pressing the Paste button on the toolbar.
Clicking in the right margin of the editor window allows selection of a whole line of text. Selected text can be deleted using the Edit|Delete menu command or pressing the Ctrl+Delete keys. The Edit|Print Selection menu command allows the printing of the selected text. Dragging and dropping with the mouse can move portions of text.
Pressing the Ctrl+Y keys deletes the text line where the caret is currently positioned.
Selected portions of text can be indented, respectively unindented, using the Edit|Indent Block, respectively Edit|Unindent Block, menu commands or by pressing the Ctrl+I, respectively Ctrl+U keys.
You can find, respectively replace, portions of text in the edited file by using the Edit|Find, respectively Edit|Replace, menu commands, by pressing the Ctrl+F, respectively Ctrl+R keys, or by pressing the Find, respectively Replace buttons on the toolbar.
Changes in the edited text can be undone, respectively redone, by using the Edit|Undo, respectively Edit|Redo, menu commands, by pressing the Ctrl+Z, respectively Shift+Ctrl+Z keys, or by pressing the Undo, respectively Redo buttons on the toolbar.
You can go to a specific line number in the edited file, by using the Edit|Goto Line menu command or by pressing the Alt+G keys.
Bookmarks can be inserted or removed, at the line where the cursor is positioned, by using the Edit|Toggle Bookmark menu command or by pressing the Shift+Ctrl+0...9 keys. The Edit|Jump to Bookmark menu command or the Ctrl+0...9 keys will position the cursor at the start of the corresponding bookmarked text line.
If the cursor is positioned on an opening, respectively closing, brace then the Edit|Match Braces menu command or the Ctrl+M key will highlight, the portion of text until the corresponding matching closing, respectively opening brace. Pressing any key or clicking the mouse will hide the highlighting.
Clicking with the mouse right button opens a pop-up menu that also gives the user access to the above mentioned functions.
© 1998-2003 HP InfoTech S.R.L.
Page 10
CodeVisionAVR

2.1.5 Saving a File

The currently edited file can be saved by using the File|Save menu command, by pressing the Ctrl+S keys or by pressing the Save button on the toolbar. When saving, the Editor will create a backup file with an ~ character appended to the extension.
All currently opened files can be saved using the File|Save All menu command.

2.1.6 Renaming a File

The currently edited file can be saved under a new name by using the File|Save As menu command. A Save dialog window will open.
You will have the possibility to specify the new name and type of the file, and eventually its new location.
© 1998-2003 HP InfoTech S.R.L.
Page 11
CodeVisionAVR

2.1.7 Printing a File

You can print the current file using the File|Print menu command or by pressing the Print button on the toolbar. The contents of the file will be printed to the Windows default printer.
The paper margins used when printing can be set using the File|Page Setup menu command, which opens the Page Setup dialog window.
The units used when setting the paper margins are specified using the Units list box. The printer can be configured by pressing the Printer button in this dialog window. Changes can be saved, respectively canceled, using the OK, respectively Cancel buttons.
© 1998-2003 HP InfoTech S.R.L.
Page 12
CodeVisionAVR

2.1.8 Closing a File

You can quit editing the current file by using the File|Close menu command. If the file was modified, and wasn’t saved yet, you will be prompted if you want to do that.
Pressing Yes will save changes and close the file. Pressing No will close the file without saving the changes. Pressing Cancel will disable the file closing process.
All currently opened files can be closed using the File|Close All menu command.
© 1998-2003 HP InfoTech S.R.L.
Page 13
CodeVisionAVR

2.1.9 Using the Navigator

The Navigator window allows easy displaying or opening of source files. By clicking on the file name the appropriate file is maximized or opened.
After a Compile or Make process there is also displayed a list of #include –ed files, global variables and functions declared in each compiled C source file. By clicking on the variable’s, respective function’s, name the variable, respective function, declaration is highlighted in the appropriate C source file.
If during compilation there are errors or warnings, these are also displayed in the Navigator window. By clicking on the error or warning, the corresponding source line is highlighted in the appropriate file.
The Navigator tree branches can be expanded, respectively collapsed, by clicking on the +, respectively -, buttons.
By right clicking in the Navigator window you can open a pop-up menu with the following choices:
Open a file
Save the currently edited file
Save All opened files
Close Current File
Close Project
Close All opened files
Toggle on or off expanding the file branches
Toggle on or off expanding the Errors and Warnings branches for the file whose Editor window
has focus
© 1998-2003 HP InfoTech S.R.L.
Page 14
CodeVisionAVR

2.2 Working with Projects

The Project groups the source file(s) and compiler settings that you use for building a particular program.

2.2.1 Creating a New Project

You can create a new Project using the File|New menu command or by pressing the Create new file button on the toolbar. A dialog box appears, in which you must select File Type|Project and press the OK button.
A dialog will open asking you to confirm if you would like to use the CodeWizardAVR to create the new project.
If you select No then the Create New Project dialog window will open.
© 1998-2003 HP InfoTech S.R.L.
Page 15
CodeVisionAVR
You must specify the new Project file name and its location.
The Project file will have the .prj extension. You can configure the Project by using the Project|Configure menu command.
© 1998-2003 HP InfoTech S.R.L.
Page 16
CodeVisionAVR

2.2.2 Opening an Existing Project

You can open an existing Project file using the File|Open menu command or by pressing the Open file button on the toolbar.
An Open dialog window appears.
You must select the file name of the Project you wish to open. By pressing the Open button you will open the Project file and its source file(s). You can configure the Project by using the Project|Configure menu command.
© 1998-2003 HP InfoTech S.R.L.
Page 17
CodeVisionAVR

2.2.3 Adding Notes or Comments to the Project

With every Project the CodeVisionAVR IDE creates a text file where you can place notes and comments. You can access this file using the Project|Notes or Windows menu commands.
This file can be edited using the standard Editor commands. The file is automatically saved when you Close the Project or Quit the CodeVisionAVR program.
© 1998-2003 HP InfoTech S.R.L.
Page 18
CodeVisionAVR

2.2.4 Configuring the Project

The Project can be configured using the Project|Configure menu command or the Project Configure toolbar button.
2.2.4.1 Adding or removing a File from the Project
To add or remove a file from the currently opened project you must use the Project|Configure menu command. A Configure Project tabbed dialog window will open. You must select the Files tab.
By pressing the Add button you can add a source file to the project. The first file added to the project is the main project file. This file will always be Make -ed. The rest of the files added to the project will be automatically linked to the main project file on Make.
© 1998-2003 HP InfoTech S.R.L.
Page 19
CodeVisionAVR
Multiple files can be added by holding the Ctrl key when selecting in the Add File to Project dialog.
When the project is Open-ed all project files will be opened in the editor. By clicking on a file, and then pressing the Remove button, you will remove this file from the project.
Changes can be saved, respectively canceled, using the OK, respectively Cancel buttons.
When creating a project with multiple files the following rules must be preserved:
only .C files must be added to the project's Files list
there's no need to #include the .C files from the Files list as they will be automatically linked
data type definitions and function declarations must be placed in header .H files, that will be
#include -ed as necessary in the .C files
global variables declarations must be placed in the .C files where necessary
there's no need to declare global variables, that are not static, in header .H files, because if these
files will be #include -ed more than once, the compiler will issue errors about variable redeclarations.
© 1998-2003 HP InfoTech S.R.L.
Page 20
CodeVisionAVR
2.2.4.2 Setting the C Compiler Options
To set the C compiler options for the currently opened project you must use the Project|Configure menu command. A Configure Project tabbed dialog window will open. You must select the C Compiler and Code Generation tabs.
You can select the target AVR microcontroller chip by using the Chip combo box. You must also specify the CPU Clock Frequency in MHz, which is needed by the Delay Functions, 1 Wire Protocol Functions and Dallas Semiconductor DS1820/DS18S20 Temperature Sensors Functions.
The required memory model can be selected by using the Memory Model radio group box.
The compiled program can be optimized for minimum size, respectively maximum execution speed, using the Optimize for|Size, respectively Optimize for|Speed, settings.
© 1998-2003 HP InfoTech S.R.L.
Page 21
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.
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
© 1998-2003 HP InfoTech S.R.L.
Page 22
CodeVisionAVR
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. 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-2003 HP InfoTech S.R.L.
Page 23
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 size of the bit variables, which are placed in registers R2 to R14, can be specified using the Bit Variables size list box.
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.
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.
© 1998-2003 HP InfoTech S.R.L.
Page 24
CodeVisionAVR
The Enhanced Instructions check box allows enabling or disabling the generation of Enhanced Core instructions for the ATmega128, ATmega16, ATmega161, ATmega162, ATmega163, ATmega32, ATmega323, ATmega64, ATmega8 and AT94K FPSLIC devices.
The rest of the registers in the range R2 to R14, not used for bit variables, can be automatically allocated to char and int global variables by checking the Compilation|Automatic Register Allocation check box.
An external startup file can be used by checking the Compilation|Use an External Startup File check box.
The generation of warning messages during compilation can be enabled or disabled by using the Compilation|Enable Warnings 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 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. The Use the Terminal I/O in AVR Studio check box must not be checked does not support this feature. If the Use the Terminal I/O in AVR Studio option is enabled, the UART or USART code will not run correctly on the real AVR chip. This option is only for debugging purposes.
for AVR Studio 4, as it
© 1998-2003 HP InfoTech S.R.L.
Page 25
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-2003 HP InfoTech S.R.L.
Page 26
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-2003 HP InfoTech S.R.L.
Page 27
CodeVisionAVR
2.2.4.3 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
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.
© 1998-2003 HP InfoTech S.R.L.
Page 28
CodeVisionAVR
You can select the type of the chip you wish to program using the Chip combo box. If the chip you have selected has Fuse Bit(s) that may be programmed, then a supplementary Fuse Bit(s) check box will appear. Using this check box you can set various chip options, which are described in the Atmel data sheets. If a Fuse Bit(s) check box is checked 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.
, then the corresponding fuse bit will be set to 0, the fuse being
© 1998-2003 HP InfoTech S.R.L.
Page 29
Loading...
+ 172 hidden pages