Upload
thietdaucong
View
144
Download
0
Tags:
Embed Size (px)
Citation preview
UAVR-5
IAR Embedded Workbench IDE
User Guide
for Atmel CorporationsAVR Microcontrollers
UAVR-5
COPYRIGHT NOTICECopyright 19962009 IAR Systems AB.
No part of this document may be reproduced without the prior written consent of IAR Systems AB. The software described in this document is furnished under a license and may only be used or copied in accordance with the terms of such a license.
DISCLAIMERThe information in this document is subject to change without notice and does not represent a commitment on any part of IAR Systems. While the information contained herein is assumed to be accurate, IAR Systems assumes no responsibility for any errors or omissions.
In no event shall IAR Systems, its employees, its contractors, or the authors of this document be liable for special, direct, indirect, or consequential damage, losses, costs, charges, claims, demands, claim for lost profits, fees, or expenses of any nature or kind.
TRADEMARKSIAR Systems, IAR Embedded Workbench, C-SPY, visualSTATE, From Idea To Target, IAR KickStart Kit, IAR PowerPac, IAR YellowSuite, IAR Advanced Development Kit, IAR, and the IAR Systems logotype are trademarks or registered trademarks owned by IAR Systems AB. J-Link is a trademark licensed to IAR Systems AB.
Microsoft and Windows are registered trademarks of Microsoft Corporation.
Atmel and AVR are registered trademarks of Atmel Corporation.
Adobe and Acrobat Reader are registered trademarks of Adobe Systems Incorporated. CodeWright is a registered trademark of Starbase Corporation.
All other product names are trademarks or registered trademarks of their respective owners.
EDITION NOTICEFifth edition: May 2009
Part number: UAVR-5
This guide describes version 5.x of the IAR Embedded Workbench IDE for Atmel Corporations AVR microcontroller.
Internal reference: R8, 5.3, IMAE.
UAVR-5
iii
Brief contentsTables .................................................................................................................... xxv
Figures ................................................................................................................. xxix
Preface .............................................................................................................. xxxvii
Part 1. Product overview ............................................................. 1
Product introduction ........................................................................................ 3
Installed files ........................................................................................................ 17
Part 2. Tutorials .................................................................................... 25
Creating an application project ................................................................. 27
Debugging using the IAR C-SPY Debugger ..................................... 39
Mixing C and assembler modules ............................................................ 49
Using C++ ............................................................................................................ 53
Simulating an interrupt .................................................................................. 59
Creating and using libraries ......................................................................... 69
Part 3. Project management and building ............ 73
The development environment ................................................................. 75
Managing projects ............................................................................................. 81
Building ................................................................................................................... 91
Editing ..................................................................................................................... 99
Part 4. Debugging .............................................................................. 109
The IAR C-SPY Debugger ..................................................................... 111
UAVR-5
ivIAR Embedded Workbench IDEUser Guide
Executing your application ......................................................................... 121
Working with variables and expressions ............................................ 127
Using breakpoints ........................................................................................... 135
Monitoring memory and registers ........................................................ 143
Using the C-SPY macro system .......................................................... 149
Analyzing your application ......................................................................... 157
Part 5. The C-SPY Simulator ......................................... 163
Simulator-specific debugging ..................................................................... 165
Simulating interrupts ..................................................................................... 179
Part 6. C-SPY hardware debugger systems ...... 187
Introduction to C-SPY hardware debugger systems ................... 189
Hardware-specific debugging .................................................................... 199
Part 7. Reference information ........................................... 239
IAR Embedded Workbench IDE reference ................................... 241
C-SPY reference .......................................................................................... 321
General options .............................................................................................. 357
Compiler options ........................................................................................... 367
Assembler options ......................................................................................... 381
Custom build options ................................................................................... 389
Build actions options .................................................................................... 391
Linker options ................................................................................................. 393
Library builder options ................................................................................ 407
UAVR-5
Brief contents
v
Debugger options ........................................................................................... 409
The C-SPY Command Line Utilitycspybat ................................... 413
C-SPY macros reference ........................................................................ 429
Glossary .............................................................................................................. 459
Index ..................................................................................................................... 473
UAVR-5
viIAR Embedded Workbench IDEUser Guide
UAVR-5
vii
ContentsTables .................................................................................................................... xxv
Figures ................................................................................................................. xxix
Preface .............................................................................................................. xxxvii
Who should read this guide .........................................................xxxviiHow to use this guide .....................................................................xxxviiWhat this guide contains ..............................................................xxxviiiOther documentation ...........................................................................xliDocument conventions ........................................................................xli
Typographic conventions ..................................................................xliiNaming conventions .........................................................................xlii
Part 1. Product overview ............................................................. 1
Product introduction ........................................................................................ 3
The IAR Embedded Workbench IDE .............................................. 3An extensible and modular environment ............................................. 3Features ................................................................................................ 4Documentation ..................................................................................... 5
IAR C-SPY Debugger .............................................................................. 5The C-SPY driver ................................................................................. 6General C-SPY debugger features ....................................................... 6C-SPY plugin modules ......................................................................... 8Documentation ..................................................................................... 9
IAR C-SPY Debugger systems ............................................................ 9IAR C-SPY Simulator .......................................................................... 9C-SPY ICE200 driver ........................................................................ 10C-SPY JTAGICE driver ..................................................................... 10C-SPY JTAGICE mkII/AVR Dragon driver ..................................... 11C-SPY AVR ONE! driver .................................................................. 11C-SPY Crypto Controller ROM-monitor driver ............................... 12
UAVR-5
viiiIAR Embedded Workbench IDEUser Guide
IAR C/C++ Compiler ............................................................................. 12Features .............................................................................................. 12Runtime environment ......................................................................... 13Documentation ................................................................................... 13
IAR Assembler ......................................................................................... 13Features .............................................................................................. 14Documentation ................................................................................... 14
IAR XLINK Linker .................................................................................. 14Features .............................................................................................. 15Documentation ................................................................................... 15
IAR XAR Library Builder and IAR XLIB Librarian .................. 15Features .............................................................................................. 15Documentation ................................................................................... 16
Installed files ........................................................................................................ 17
Directory structure ................................................................................ 17Root directory .................................................................................... 17The AVR directory ............................................................................. 18The common directory ....................................................................... 19The install-info directory ................................................................... 20
File types ..................................................................................................... 20Files with non-default filename extensions ....................................... 22
Documentation ........................................................................................ 22The user and reference guides ............................................................ 23Online help ......................................................................................... 24IAR Systems on the web .................................................................... 24
Part 2. Tutorials .................................................................................... 25
Creating an application project ................................................................. 27
Setting up a new project ..................................................................... 27Creating a Workspace window .......................................................... 27Creating the new project .................................................................... 28Adding files to the project .................................................................. 30
UAVR-5
Contents
ix
Setting project options ....................................................................... 31Compiling and linking the application ........................................... 33
Compiling the source files ................................................................. 33Viewing the list file ............................................................................ 34Linking the application ...................................................................... 36Viewing the map file .......................................................................... 37
Debugging using the IAR C-SPY Debugger ..................................... 39
Debugging the application .................................................................. 39Starting the debugger ......................................................................... 39Organizing the windows .................................................................... 39Inspecting source statements .............................................................. 40Inspecting variables ........................................................................... 42Setting and monitoring breakpoints ................................................... 44Debugging in disassembly mode ...................................................... 45Monitoring memory ........................................................................... 45Viewing terminal I/O ......................................................................... 46Reaching program exit ....................................................................... 47
Mixing C and assembler modules ............................................................ 49
Examining the calling convention .................................................... 49Adding an assembler module to the project .............................. 50
Setting up the project ......................................................................... 50Using C++ ............................................................................................................ 53
Creating a C++ application ................................................................. 53Compiling and linking the C++ application ....................................... 53Setting a breakpoint and executing to it ............................................. 54Printing the Fibonacci numbers ......................................................... 56
Simulating an interrupt .................................................................................. 59
Adding an interrupt handler .............................................................. 59The applicationa brief description .................................................. 59Writing an interrupt handler ............................................................... 59Setting up the project ......................................................................... 60
UAVR-5
xIAR Embedded Workbench IDEUser Guide
Setting up the simulation environment ........................................ 60Defining a C-SPY setup macro file .................................................... 61Setting C-SPY options ....................................................................... 62Building the project ............................................................................ 63Starting the simulator ......................................................................... 63Specifying a simulated interrupt ....................................................... 63Setting an immediate breakpoint ........................................................ 65
Simulating the interrupt ...................................................................... 65Executing the application ................................................................... 65
Using macros for interrupts and breakpoints ............................ 67
Creating and using libraries ......................................................................... 69
Using libraries .......................................................................................... 69Creating a new project ....................................................................... 70Creating a library project ................................................................... 70Using the library in your application project ..................................... 71
Part 3. Project management and building ............ 73
The development environment ................................................................. 75
The IAR Embedded Workbench IDE ............................................ 75The tool chain ..................................................................................... 75Running the IDE ................................................................................ 76Exiting ................................................................................................ 77
Customizing the environment .......................................................... 77Organizing the windows on the screen .............................................. 77Customizing the IDE .......................................................................... 78Invoking external tools ....................................................................... 79
Managing projects ............................................................................................. 81
The project model .................................................................................. 81How projects are organized ................................................................ 81Creating and managing workspaces ................................................... 83
Navigating project files ........................................................................ 85Viewing the workspace ...................................................................... 86
UAVR-5
Contents
xi
Displaying browse information .......................................................... 87Source code control .............................................................................. 88
Interacting with source code control systems .................................... 88
Building ................................................................................................................... 91
Building your application ..................................................................... 91Setting options .................................................................................... 91Building a project ............................................................................... 93Building multiple configurations in a batch ....................................... 93Using pre- and post-build actions ...................................................... 94Correcting errors found during build ................................................. 94Building from the command line ....................................................... 95
Extending the tool chain ...................................................................... 95Tools that can be added to the tool chain ........................................... 96Adding an external tool ...................................................................... 96
Editing ..................................................................................................................... 99
Using the IAR Embedded Workbench editor ............................ 99Editing a file ....................................................................................... 99Using and adding code templates ..................................................... 103Navigating in and between files ....................................................... 105Searching .......................................................................................... 105
Customizing the editor environment .......................................... 105Using an external editor ................................................................... 106
Part 4. Debugging .............................................................................. 109
The IAR C-SPY Debugger ..................................................................... 111
Debugger concepts .............................................................................. 111C-SPY and target systems ................................................................ 111Debugger .......................................................................................... 112Target system ................................................................................... 112User application ............................................................................... 112C-SPY Debugger systems ................................................................ 112ROM-monitor program .................................................................... 113
UAVR-5
xiiIAR Embedded Workbench IDEUser Guide
Third-party debuggers ...................................................................... 113The C-SPY environment ................................................................... 113
An integrated environment ............................................................... 113Setting up C-SPY .................................................................................. 114
Choosing a debug driver .................................................................. 114Executing from reset ....................................................................... 115Using a setup macro file ................................................................... 115Selecting a device description file ................................................... 115Loading plugin modules ................................................................... 116
Starting C-SPY ..................................................................................... 117Executable files built outside of the IDE ......................................... 117Redirecting debugger output to a file ............................................... 117
Adapting C-SPY to target hardware ............................................ 118Device description file ..................................................................... 118
Executing your application ......................................................................... 121
Source and disassembly mode debugging ................................. 121Executing .................................................................................................. 121
Step ................................................................................................... 122Go ..................................................................................................... 124Run to Cursor ................................................................................... 124Highlighting ..................................................................................... 124Using breakpoints to stop ................................................................. 124Using the Break button to stop ......................................................... 125Stop at program exit ......................................................................... 125
Call stack information ........................................................................ 125Terminal input and output ............................................................... 126
Working with variables and expressions ............................................ 127
C-SPY expressions ............................................................................... 127C symbols ......................................................................................... 127Assembler symbols .......................................................................... 128Macro functions .............................................................................. 128Macro variables ................................................................................ 129
UAVR-5
Contents
xiii
Limitations on variable information ............................................. 129Effects of optimizations ................................................................... 129
Viewing variables and expressions ................................................ 131Working with the windows .............................................................. 131Using the trace system ..................................................................... 132Viewing assembler variables ........................................................... 133
Using breakpoints ........................................................................................... 135
The breakpoint system ...................................................................... 135Defining breakpoints ........................................................................... 135
Toggling a simple code breakpoint .................................................. 136Setting a breakpoint in the Memory window ................................... 137Defining breakpoints using the dialog box ...................................... 137Defining breakpoints using system macros ..................................... 139
Viewing all breakpoints ...................................................................... 139Using the Breakpoint Usage dialog box .......................................... 140
Monitoring memory and registers ........................................................ 143
Memory addressing .............................................................................. 143Windows for monitoring memory and registers .................... 144
Using the Memory window .............................................................. 145Using the Stack window .................................................................. 145Working with registers ..................................................................... 147
Using the C-SPY macro system .......................................................... 149
The macro system ................................................................................ 149The macro language ......................................................................... 150The macro file .................................................................................. 150Setup macro functions ...................................................................... 151
Using C-SPY macros ........................................................................... 151Using the Macro Configuration dialog box ..................................... 152Registering and executing using setup macros and setup files ........ 153Executing macros using Quick Watch ............................................ 154Executing a macro by connecting it to a breakpoint ........................ 155
UAVR-5
xivIAR Embedded Workbench IDEUser Guide
Analyzing your application ......................................................................... 157
Function-level profiling ...................................................................... 157Using the profiler ............................................................................. 158
Code coverage ....................................................................................... 160Using Code Coverage ...................................................................... 160
Part 5. The C-SPY Simulator ......................................... 163
Simulator-specific debugging ..................................................................... 165
The C-SPY Simulator introduction .............................................. 165Features ............................................................................................ 165Selecting the simulator driver .......................................................... 165
Simulator-specific menus .................................................................. 166Simulator menu ................................................................................ 166
Using the trace system in the simulator .................................... 167Trace window ................................................................................... 167Function Trace window ................................................................... 168Trace Expressions window .............................................................. 170Find In Trace window ...................................................................... 171Find in Trace dialog box .................................................................. 171
Using breakpoints in the simulator .............................................. 173Data breakpoints .............................................................................. 173Immediate breakpoints ..................................................................... 175Breakpoint Usage dialog box ........................................................... 177
Simulating interrupts ..................................................................................... 179
The C-SPY interrupt simulation system .................................... 179Interrupt characteristics .................................................................... 180
Using the interrupt simulation system ....................................... 181Target-adapting the interrupt simulation system ............................. 181Interrupts dialog box ........................................................................ 182C-SPY system macros for interrupts ................................................ 183
UAVR-5
Contents
xv
Simulating a simple interrupt ......................................................... 184
Part 6. C-SPY hardware debugger systems ...... 187
Introduction to C-SPY hardware debugger systems ................... 189
The IAR C-SPY hardware debugger systems .......................... 189Differences between the C-SPY drivers ......................................... 190
The C-SPY JTAGICE driver ............................................................. 191Hardware installation ....................................................................... 192
The C-SPY JTAGICE mkII driver .................................................. 192Hardware installation ....................................................................... 193
The C-SPY AVR ONE! driver .......................................................... 194Hardware installation ....................................................................... 195
The C-SPY ICE200 driver ................................................................. 195Supported devices ............................................................................ 196Hardware installation ....................................................................... 196Upgrading the firmware ................................................................... 197
The C-SPY CCR driver ..................................................................... 197
Hardware-specific debugging .................................................................... 199
C-SPY options for debugging using hardware systems ........ 199Serial Port page ................................................................................ 201Extra Options page ........................................................................... 202
JTAGICE-specific debugging ............................................................ 202JTAGICE 1 page .............................................................................. 203JTAGICE 2 page .............................................................................. 205The JTAGICE menu ........................................................................ 206
JTAGICE mkII- and AVR Dragon-specific debugging ........... 206JTAGICE mkII 1 page ..................................................................... 207JTAGICE mkII 2 page ..................................................................... 209The JTAGICE mkII menu ................................................................ 210Fuse Handler dialog box .................................................................. 210
AVR ONE!-specific debugging ......................................................... 213AVR ONE! 1 page ........................................................................... 213
UAVR-5
xviIAR Embedded Workbench IDEUser Guide
AVR ONE! 2 page ........................................................................... 215Communication ................................................................................ 216The AVR ONE! menu ...................................................................... 217Fuse Handler dialog box .................................................................. 218
ICE200-specific debugging ............................................................... 220ICE200 page ..................................................................................... 220The ICE200 menu ............................................................................ 222ICE200 Options dialog box .............................................................. 223
CCR-specific debugging ..................................................................... 225CCR page ......................................................................................... 226Troubleshooting ............................................................................... 227Using C-SPY macro for transparent commands .............................. 228
Using breakpoints ................................................................................. 229Available breakpoints ...................................................................... 229Data breakpoints dialog box ............................................................ 230Complex breakpoint dialog box ....................................................... 232Breakpoint Usage dialog box ........................................................... 235
Debugging using a third-party driver ........................................... 236Third-Party Driver options page ...................................................... 236
Part 7. Reference information ........................................... 239
IAR Embedded Workbench IDE reference ................................... 241
Windows ................................................................................................... 241IAR Embedded Workbench IDE window ....................................... 242Workspace window .......................................................................... 244Editor window .................................................................................. 252Source Browser window .................................................................. 258Breakpoints window ........................................................................ 260Build window ................................................................................... 266Find in Files window ........................................................................ 266Tool Output window ........................................................................ 267Debug Log window .......................................................................... 268
UAVR-5
Contents
xvii
Menus ......................................................................................................... 269File menu .......................................................................................... 269Edit menu ......................................................................................... 272View menu ....................................................................................... 280Project menu .................................................................................... 282Tools menu ....................................................................................... 291Common fonts options ..................................................................... 292Key Bindings options ....................................................................... 293Language options ............................................................................. 294Editor options ................................................................................... 295Configure Auto Indent dialog box ................................................... 297External Editor options .................................................................... 298Editor Setup Files options ................................................................ 300Editor Colors and Fonts options ....................................................... 301Messages options ............................................................................. 302Project options .................................................................................. 304Source Code Control options ........................................................... 305Debugger options ............................................................................. 306Stack options .................................................................................... 308Register Filter options ...................................................................... 310Terminal I/O options ........................................................................ 311Configure Tools dialog box ............................................................. 312Filename Extensions dialog box ...................................................... 314Filename Extension Overrides dialog box ....................................... 315Edit Filename Extensions dialog box ............................................... 315Configure Viewers dialog box ........................................................ 316Edit Viewer Extensions dialog box ................................................. 316Window menu .................................................................................. 317Help menu ........................................................................................ 318Embedded Workbench Startup dialog box ...................................... 318
C-SPY reference .......................................................................................... 321
C-SPY windows ...................................................................................... 321Editing in C-SPY windows .............................................................. 321
UAVR-5
xviiiIAR Embedded Workbench IDEUser Guide
C-SPY Debugger main window ....................................................... 322Disassembly window ....................................................................... 324Memory window .............................................................................. 326Fill dialog box .................................................................................. 329Memory Save dialog box ................................................................. 330Memory Restore dialog box ............................................................. 331Symbolic Memory window .............................................................. 332Register window .............................................................................. 334Watch window ................................................................................. 334Locals window ................................................................................. 336Auto window .................................................................................... 337Quick Watch window ....................................................................... 337Statics window ................................................................................. 338Select Statics dialog box .................................................................. 340Call Stack window ........................................................................... 341Terminal I/O window ....................................................................... 342Code Coverage window ................................................................... 343Profiling window .............................................................................. 345Stack window ................................................................................... 346Symbols window .............................................................................. 349
C-SPY menus .......................................................................................... 350Debug menu ..................................................................................... 351
General options .............................................................................................. 357
Target ........................................................................................................ 357Processor configuration ................................................................... 357Memory model ................................................................................. 358System configuration ...................................................................... 358
Output ....................................................................................................... 359Output file ........................................................................................ 359Output directories ............................................................................. 360
Library Configuration ......................................................................... 360Library .............................................................................................. 361Library file ....................................................................................... 361
UAVR-5
Contents
xix
Configuration file ............................................................................. 361Library Options ..................................................................................... 362
Printf formatter ................................................................................. 362Scanf formatter ................................................................................. 362
Heap Configuration ............................................................................. 363CLIB heap size ................................................................................. 363DLIB heap sizes ............................................................................... 363
System ....................................................................................................... 364Data stack (CSTACK)/Return address stack (RSTACK) ................ 364External memory configuration ...................................................... 364Initialize unused interrupt vectors with RETI instructions ............. 364Enable bit definitions in I/O-Include files ........................................ 364
MISRA C .................................................................................................. 365
Compiler options ........................................................................................... 367
Multi-file compilation .......................................................................... 367Language .................................................................................................. 368
Language .......................................................................................... 368Require prototypes ........................................................................... 369Language conformance .................................................................... 369Plain 'char' is ................................................................................... 369Enable multibyte support ................................................................. 370
Code ........................................................................................................... 370Memory utilization .......................................................................... 370Register utilization ........................................................................... 371
Optimizations ......................................................................................... 372Optimizations ................................................................................... 372
Output ....................................................................................................... 374Module type ..................................................................................... 374Object module name ........................................................................ 374Generate debug information ............................................................. 375No error messages in output ............................................................. 375
List ............................................................................................................... 375Output list file .................................................................................. 376
UAVR-5
xxIAR Embedded Workbench IDEUser Guide
Output assembler file ....................................................................... 376Preprocessor ........................................................................................... 376
Ignore standard include directories .................................................. 377Additional include directories .......................................................... 377Preinclude file .................................................................................. 377Defined symbols .............................................................................. 377Preprocessor output to file ............................................................... 378
Diagnostics .............................................................................................. 378Enable remarks ................................................................................. 378Suppress these diagnostics ............................................................... 378Treat these as remarks ...................................................................... 379Treat these as warnings .................................................................... 379Treat these as errors ........................................................................ 379Treat all warnings as errors .............................................................. 379
MISRA C .................................................................................................. 379Extra Options ......................................................................................... 380
Use command line options ............................................................... 380
Assembler options ......................................................................................... 381
Language .................................................................................................. 381User symbols are case sensitive ....................................................... 381Enable multibyte support ................................................................ 381Macro quote characters .................................................................... 382
Output ....................................................................................................... 382Generate debug information ............................................................. 383
List ............................................................................................................... 383Include header .................................................................................. 383Conditional listing of ....................................................................... 384cross-reference ................................................................................ 384List format ....................................................................................... 384
Preprocessor ........................................................................................... 385Ignore standard include directories .................................................. 385Additional include directories ......................................................... 385Defined symbols .............................................................................. 386
UAVR-5
Contents
xxi
Predefined symbols .......................................................................... 386Diagnostics .............................................................................................. 387
Max number of errors ...................................................................... 387Extra Options ......................................................................................... 388
Use command line options ............................................................... 388
Custom build options ................................................................................... 389
Custom Tool Configuration ............................................................. 389
Build actions options .................................................................................... 391
Build Actions Configuration ............................................................ 391Pre-build command line ................................................................... 391Post-build command line ................................................................. 391
Linker options ................................................................................................. 393
Output ....................................................................................................... 393Output file ....................................................................................... 393Format .............................................................................................. 394
Extra Output .......................................................................................... 396#define ....................................................................................................... 397
Define symbol ................................................................................. 397Diagnostics .............................................................................................. 398
Always generate output .................................................................... 398Segment overlap warnings ............................................................... 398No global type checking .................................................................. 398Range checks .................................................................................... 399Warnings/Errors ............................................................................... 399
List ............................................................................................................... 400Generate linker listing ...................................................................... 400
Config ......................................................................................................... 402Linker command file ....................................................................... 402Override default program entry ........................................................ 402Search paths ..................................................................................... 403Raw binary image ............................................................................ 403
UAVR-5
xxiiIAR Embedded Workbench IDEUser Guide
Processing ................................................................................................ 404Fill unused code memory ................................................................. 404The checksum calculation ................................................................ 405
Extra Options ......................................................................................... 406Use command line options ............................................................... 406
Library builder options ................................................................................ 407
Output ....................................................................................................... 407
Debugger options ........................................................................................... 409
Setup .......................................................................................................... 409Driver ............................................................................................... 409Run to .............................................................................................. 410Use UBROF reset vector ................................................................. 410Setup macros ................................................................................... 410Device description file .................................................................... 410
Plugins ....................................................................................................... 411
The C-SPY Command Line Utilitycspybat ................................... 413
Using C-SPY in batch mode ............................................................. 413Invocation syntax ............................................................................. 413Output ............................................................................................... 414Using an automatically generated batch file .................................... 414
C-SPY command line options ......................................................... 415General cspybat options ................................................................... 415Options available for all C-SPY drivers .......................................... 415Options available for all C-SPY hardware drivers .......................... 415Options available for the C-SPY ICE200 driver ............................. 416Options for the AVR ONE!, JTAGICE, and JTAGICE mkIIdrivers .............................................................................................. 416Options for the JTAGICE and JTAGICE mkII drivers ................... 416Options available for the C-SPY AVR ONE! driver ....................... 416Options available for the C-SPY AVR Dragon driver ..................... 416
UAVR-5
Contents
xxiii
Descriptions of C-SPY command line options ......................... 417
C-SPY macros reference ........................................................................ 429
The macro language ............................................................................ 429Macro functions ............................................................................... 429Predefined system macro functions ................................................. 429Macro variables ................................................................................ 430Macro statements ............................................................................. 431Formatted output .............................................................................. 432
Setup macro functions summary .................................................. 434C-SPY system macros summary ................................................... 434Description of C-SPY system macros .......................................... 436
Glossary .............................................................................................................. 459
Index ..................................................................................................................... 473
UAVR-5
xxivIAR Embedded Workbench IDEUser Guide
UAVR-5
xxv
Tables1: Typographic conventions used in this guide ........................................................ xlii2: Naming conventions used in this guide ............................................................... xlii3: File types ............................................................................................................... 204: General settings for project1 ................................................................................. 315: Compiler options for project1 ............................................................................... 326: Compiler options for project2 ............................................................................... 507: Project options for C++ tutorial ............................................................................ 548: Interrupts dialog box ............................................................................................. 639: Breakpoints dialog box ......................................................................................... 6510: General options for a library project ................................................................... 7011: Command shells .................................................................................................. 8012: iarbuild.exe command line options ..................................................................... 9513: C-SPY assembler symbols expressions ............................................................ 12814: Handling name conflicts between hardware registers and assembler labels ..... 12815: Project options for enabling profiling ............................................................... 15816: Project options for enabling code coverage ...................................................... 16017: Description of Simulator menu commands ....................................................... 16618: Trace toolbar commands ................................................................................... 16719: Trace window columns ..................................................................................... 16820: Function Trace window columns ...................................................................... 16921: Toolbar buttons in the Trace Expressions window ........................................... 17022: Trace Expressions window columns ................................................................. 17023: Memory Access types ....................................................................................... 17424: Breakpoint conditions ....................................................................................... 17525: Memory Access types ....................................................................................... 17626: Timer interrupt settings ..................................................................................... 18527: Driver differences .............................................................................................. 19028: Commands on the JTAGICE menu ................................................................... 20629: Commands on the JTAGICE mkII menu .......................................................... 21030: Commands on the AVR ONE! menu when the debugger is running ............... 21731: Commands on the AVR ONE! menu before the debugger is started ................ 218
UAVR-5
xxviIAR Embedded Workbench IDEUser Guide
32: Commands on the ICE200 menu ...................................................................... 22233: Available hardware breakpoints ........................................................................ 22934: Memory Access types ....................................................................................... 23135: Complex breakpoints: Breakpoint control options ........................................... 23336: Memory Access types ....................................................................................... 23337: Complex breakpoints: Complex data options ................................................... 23338: IDE menu bar .................................................................................................... 24239: Workspace window context menu commands .................................................. 24640: Description of source code control commands ................................................. 24741: Description of source code control states .......................................................... 24842: Description of commands on the editor window context menu ........................ 25443: Editor keyboard commands for insertion point navigation ............................... 25644: Editor keyboard commands for scrolling .......................................................... 25745: Editor keyboard commands for selecting text ................................................... 25746: Information in Source Browser window ........................................................... 25847: Source Browser window context menu commands .......................................... 25948: Breakpoints window context menu commands ................................................. 26149: Breakpoint conditions ....................................................................................... 26350: Log breakpoint conditions ................................................................................. 26451: Location types ................................................................................................... 26552: File menu commands ........................................................................................ 27053: Edit menu commands ........................................................................................ 27254: Find dialog box options ..................................................................................... 27555: Replace dialog box options ............................................................................... 27656: Incremental Search function buttons ................................................................. 27957: View menu commands ...................................................................................... 28058: Project menu commands ................................................................................... 28259: Argument variables ........................................................................................... 28460: Configurations for project dialog box options .................................................. 28561: New Configuration dialog box options ............................................................. 28662: Description of Create New Project dialog box ................................................. 28763: Project option categories ................................................................................... 28764: Description of the Batch Build dialog box ........................................................ 28965: Description of the Edit Batch Build dialog box ................................................ 290
UAVR-5
Tables
xxvii
66: Tools menu commands ..................................................................................... 29167: Project IDE options ........................................................................................... 30468: Register Filter options ....................................................................................... 31069: Configure Tools dialog box options .................................................................. 31270: Command shells ................................................................................................ 31471: Window menu commands ................................................................................. 31772: Editing in C-SPY windows ............................................................................... 32273: C-SPY menu ...................................................................................................... 32274: Disassembly window toolbar ............................................................................ 32475: Disassembly context menu commands ............................................................. 32576: Memory window operations ............................................................................. 32777: Commands on the memory window context menu ........................................... 32878: Fill dialog box options ...................................................................................... 32979: Memory fill operations ...................................................................................... 33080: Symbolic Memory window toolbar .................................................................. 33281: Symbolic memory window columns ................................................................. 33282: Commands on the Symbolic Memory window context menu .......................... 33383: Watch window context menu commands ......................................................... 33584: Effects of display format setting on different types of expressions .................. 33685: Symbolic memory window columns ................................................................. 33886: Statics window context menu commands ......................................................... 33987: Profiling window columns ................................................................................ 34688: Stack window columns ..................................................................................... 34889: Symbols window columns ................................................................................ 34990: Commands on the Symbols window context menu .......................................... 35091: Debug menu commands .................................................................................... 35192: Log file options ................................................................................................. 35493: Assembler list file options ................................................................................. 38494: XLINK range check options ............................................................................. 39995: XLINK list file options ..................................................................................... 40096: XLINK list file format options .......................................................................... 40197: XLINK checksum algorithms ........................................................................... 40598: C-SPY driver options ........................................................................................ 41099: cspybat parameters ............................................................................................ 413
UAVR-5
xxviiiIAR Embedded Workbench IDEUser Guide
100: Examples of C-SPY macro variables .............................................................. 430101: C-SPY setup macros ....................................................................................... 434102: Summary of system macros ............................................................................ 434103: __cancelInterrupt return values ....................................................................... 436104: __disableInterrupts return values .................................................................... 437105: __driverType return values ............................................................................. 438106: __enableInterrupts return values ..................................................................... 438107: __evaluate return values ................................................................................. 439108: __load Module return values .......................................................................... 440109: __openFile return values ................................................................................. 443110: __readFile return values ................................................................................. 445111: __setCodeBreak return values ........................................................................ 448112: __set Complex Break return values ................................................................ 450113: __setDataBreak return values ......................................................................... 451114: __setSimBreak return values .......................................................................... 452115: __source Position return values ...................................................................... 453
UAVR-5
xxix
Figures1: Directory structure ................................................................................................ 172: Create New Project dialog box ............................................................................. 283: Workspace window ............................................................................................... 294: New Workspace dialog box .................................................................................. 295: Adding files to project1 ......................................................................................... 306: Setting general options .......................................................................................... 317: Setting compiler options ....................................................................................... 328: Compilation message ............................................................................................ 339: Workspace window after compilation .................................................................. 3410: Setting the option Scan for Changed Files .......................................................... 3511: Linker options dialog box for project1 ................................................................ 3612: The C-SPY Debugger main window ................................................................... 4013: Stepping in C-SPY .............................................................................................. 4114: Using Step Into in C-SPY ................................................................................... 4215: Inspecting variables in the Auto window ............................................................ 4316: Watching variables in the Watch window .......................................................... 4317: Setting breakpoints .............................................................................................. 4418: Debugging in disassembly mode ........................................................................ 4519: Monitoring memory ............................................................................................ 4620: Displaying memory contents as 16-bit units ....................................................... 4621: Output from the I/O operations ........................................................................... 4722: Reaching program exit in C-SPY ........................................................................ 4723: Assembler settings for creating a list file ............................................................ 5124: Setting a breakpoint in CPPtutor.cpp .................................................................. 5525: Inspecting the function calls ................................................................................ 5626: Printing Fibonacci sequences .............................................................................. 5727: Specifying setup macro file ................................................................................. 6228: Inspecting the interrupt settings .......................................................................... 6429: Register window .................................................................................................. 6630: Printing the Fibonacci values in the Terminal I/O window ................................ 6731: IAR Embedded Workbench IDE window ........................................................... 76
UAVR-5
xxxIAR Embedded Workbench IDEUser Guide
32: Configure Tools dialog box ................................................................................ 7933: Customized Tools menu ...................................................................................... 8034: Examples of workspaces and projects ................................................................. 8235: Displaying a project in the Workspace window ................................................. 8636: Workspace windowan overview ..................................................................... 8737: General options ................................................................................................... 9238: Editor window ................................................................................................... 10039: Parentheses matching in editor window ............................................................ 10340: Editor window status bar ................................................................................... 10341: Editor window code template menu .................................................................. 10442: Specifying external command line editor ......................................................... 10643: External editor DDE settings ............................................................................ 10744: C-SPY and target systems ................................................................................. 11245: C-SPY highlighting source location .................................................................. 12446: Viewing assembler variables in the Watch window ......................................... 13347: Breakpoint icons ................................................................................................ 13648: Breakpoint Usage dialog box ............................................................................ 14049: Zones in C-SPY ................................................................................................. 14350: Memory window ............................................................................................... 14551: Stack window .................................................................................................... 14652: Register window ................................................................................................ 14753: Register Filter page ........................................................................................... 14854: Macro Configuration dialog box ....................................................................... 15355: Quick Watch window ........................................................................................ 15556: Profiling window ............................................................................................... 15857: Graphs in Profiling window .............................................................................. 15958: Function details window ................................................................................... 15959: Code Coverage window .................................................................................... 16160: Simulator menu ................................................................................................. 16661: Trace window .................................................................................................... 16762: Function Trace window ..................................................................................... 16963: Trace Expressions window ............................................................................... 17064: Find In Trace window ....................................................................................... 17165: Find in Trace dialog box ................................................................................... 172
UAVR-5
Figures
xxxi
66: Data breakpoints dialog box .............................................................................. 17467: Immediate breakpoints page ............................................................................. 17668: Breakpoint Usage dialog box ............................................................................ 17769: Simulated interrupt configuration ..................................................................... 18070: Interrupts dialog box ......................................................................................... 18271: C-SPY JTAGICE communication overview .................................................... 19172: C-SPY JTAGICE mkII communication overview ............................................ 19373: C-SPY AVR ONE! communication overview .................................................. 19474: ICE200 communication overview ..................................................................... 19675: Finishing the ICE200 firmware upgrade ........................................................... 19776: CCR driver communication overview .............................................................. 19877: Serial port options ............................................................................................. 20178: Extra Options page for C-SPY command line options ..................................... 20279: JTAGICE options, page 1 ................................................................................. 20380: JTAGICE options, page 2 ................................................................................. 20581: The JTAGICE menu ......................................................................................... 20682: JTAGICE mkII options, page 1 ........................................................................ 20783: JTAGICE mkII options, page 2 ........................................................................ 20984: The JTAGICE mkII menu ................................................................................. 21085: The JTAGICE mkII Fuse Handler dialog box .................................................. 21186: AVR ONE! options, page 1 .............................................................................. 21387: AVR ONE! options, page 2 .............................................................................. 21588: Communication options .................................................................................... 21689: The AVR ONE! menu before the debugger is started ...................................... 21790: The AVR ONE! menu when the debugger is running ...................................... 21791: The AVR ONE! Fuse Handler dialog box ........................................................ 21892: ICE200 driver options ....................................................................................... 22093: The ICE200 menu ............................................................................................. 22294: The ICE200 Options dialog box ....................................................................... 22395: CCR options ...................................................................................................... 22696: Data breakpoints dialog box .............................................................................. 23197: Complex breakpoints dialog box ...................................................................... 23298: Breakpoint Usage dialog box ............................................................................ 23599: C-SPY Third-Party Driver options .................................................................... 236
UAVR-5
xxxiiIAR Embedded Workbench IDEUser Guide
100: IAR Embedded Workbench IDE window ....................................................... 242101: IDE toolbar ...................................................................................................... 243102: IAR Embedded Workbench IDE window status bar ...................................... 244103: Workspace window ......................................................................................... 244104: Workspace window context menu .................................................................. 246105: Source Code Control menu ............................................................................. 247106: Select Source Code Control Provider dialog box ........................................... 249107: Check In Files dialog box ............................................................................... 250108: Check Out File dialog box .............................................................................. 251109: Editor window ................................................................................................. 252110: Editor window tab context menu .................................................................... 253111: Editor window context menu .......................................................................... 254112: Source Browser window ................................................................................. 258113: Source Browser window context menu ........................................................... 259114: Breakpoints window ........................................................................................ 260115: Breakpoints window context menu ................................................................. 260116: Code breakpoints page .................................................................................... 262117: Log breakpoints page ...................................................................................... 263118: Enter Location dialog box ............................................................................... 265119: Build window (message window) ................................................................... 266120: Build window context menu ........................................................................... 266121: Find in Files window (message window) ........................................................ 267122: Find in Files window context menu ................................................................ 267123: Tool Output window (message window) ........................................................ 268124: Tool Output window context menu ................................................................. 268125: Debug Log window (message window) .......................................................... 268126: Debug Log window context menu .................................................................. 269127: File menu ......................................................................................................... 270128: Edit menu ........................................................................................................ 272129: Find in Files dialog box ................................................................................... 277130: Incremental Search dialog box ........................................................................ 278131: Template dialog box ........................................................................................ 279132: View menu ...................................................................................................... 280133: Project menu .................................................................................................... 282
UAVR-5
Figures
xxxiii
134: Configurations for project dialog box ............................................................. 285135: New Configuration dialog box ........................................................................ 286136: Create New Project dialog box ....................................................................... 287137: Batch Build dialog box .................................................................................... 289138: Edit Batch Build dialog box ............................................................................ 290139: Tools menu ...................................................................................................... 291140: Common Fonts options ................................................................................... 292141: Key Bindings options ...................................................................................... 293142: Language options ............................................................................................ 294143: Editor options .................................................................................................. 295144: Configure Auto Indent dialog box .................................................................. 297145: External Editor options ................................................................................... 298146: Editor Setup Files options ............................................................................... 300147: Editor Colors and Fonts options ...................................................................... 301148: Messages option .............................................................................................. 302149: Message dialog box containing a Dont show again option ........................... 303150: Project options ................................................................................................. 304151: Source Code Control options .......................................................................... 305152: Debugger options ............................................................................................ 306153: Stack options ................................................................................................... 308154: Register Filter options ..................................................................................... 310155: Terminal I/O options ....................................................................................... 311156: Configure Tools dialog box ............................................................................ 312157: Customized Tools menu ......................