EWAVR DebuggingGuide
EWAVR DebuggingGuide
UCSAVR-6b
COPYRIGHT NOTICE
© 2011–2017 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.
DISCLAIMER
The 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.
TRADEMARKS
IAR Systems, IAR Embedded Workbench, IAR Connect, C-SPY, C-RUN, C-STAT,
IAR Visual State, visualSTATE, IAR KickStart Kit, I-jet, I-jet Trace, I-scope, IAR
Academy, IAR, and the logotype of IAR Systems are trademarks or registered
trademarks owned by IAR Systems AB.
Microsoft and Windows are registered trademarks of Microsoft Corporation.
Atmel and AVR are registered trademarks of Microchip Technology.
Adobe and Acrobat Reader are registered trademarks of Adobe Systems Incorporated.
All other product names are trademarks or registered trademarks of their respective
owners.
EDITION NOTICE
Sixth edition: April 2017
Part number: UCSAVR-6b
This guide applies to version 7.x of IAR Embedded Workbench® for Microchip
Technology’s AVR microcontroller family.
Internal reference: M23, Mym8.0, IMAE.
AFE1_AFE2-1:1
Brief contents
Tables ..................................................................................................................... 19
Preface .................................................................................................................... 21
AFE1_AFE2-1:1
Part 4. Additional reference information ............. 335
AFE1_AFE2-1:1
Contents
Tables ..................................................................................................................... 19
Preface .................................................................................................................... 21
Who should read this guide ............................................................... 21
Required knowledge .......................................................................... 21
What this guide contains ..................................................................... 21
Part 1. Basic debugging ..................................................................... 21
Part 2. Analyzing your application .................................................... 22
Part 3. Advanced debugging .............................................................. 22
Part 4. Additional reference information ........................................... 22
Other documentation ........................................................................... 23
User and reference guides .................................................................. 23
The online help system ...................................................................... 24
Web sites ............................................................................................ 24
Document conventions ........................................................................ 24
Typographic conventions ................................................................... 25
Naming conventions .......................................................................... 25
AFE1_AFE2-1:1
Third-party debuggers ........................................................................ 34
C-SPY plugin modules ....................................................................... 34
C-SPY drivers overview ....................................................................... 35
Differences between the C-SPY drivers ........................................... 35
The IAR C-SPY Simulator .................................................................. 36
The C-SPY Atmel-ICE driver ............................................................ 37
Features .............................................................................................. 37
Communication overview .................................................................. 38
Hardware installation ......................................................................... 38
The C-SPY Power Debugger driver ............................................... 39
Features .............................................................................................. 39
Communication overview .................................................................. 39
Hardware installation ......................................................................... 40
The C-SPY JTAGICE3 driver ............................................................ 41
Features .............................................................................................. 41
Communication overview .................................................................. 42
Hardware installation ......................................................................... 42
The C-SPY JTAGICE mkII/Dragon driver ................................... 43
Features .............................................................................................. 43
Communication overview .................................................................. 44
Hardware installation ......................................................................... 44
The C-SPY AVR ONE! driver ............................................................ 45
Features .............................................................................................. 45
Communication overview .................................................................. 46
Hardware installation ......................................................................... 46
AFE1_AFE2-1:1
Contents
AFE1_AFE2-1:1
Cores window .................................................................................... 82
AFE1_AFE2-1:1
Contents
AFE1_AFE2-1:1
Part 2. Analyzing your application ................................ 159
Trace ..................................................................................................................... 161
AFE1_AFE2-1:1
Contents
11
AFE1_AFE2-1:1
Finding conflicting hardware setups ................................................ 216
Analog interference .......................................................................... 216
Debugging in the power domain .................................................... 217
Displaying a power profile and analyzing the result ........................ 217
Detecting unexpected power usage during application execution ... 219
Changing the graph resolution ......................................................... 219
Reference information on power debugging ............................ 219
Power Log Setup window ................................................................ 220
Power Debugging Settings ............................................................... 222
Timeline window—Power graph ..................................................... 223
Power Log window .......................................................................... 226
State Log Setup window ................................................................. 229
State Log window ............................................................................ 231
State Log Summary window ............................................................ 233
Timeline window—State Log graph ............................................... 235
AFE1_AFE2-1:1
Contents
13
AFE1_AFE2-1:1
__evaluate ........................................................................................ 271
__fillMemory8 ................................................................................ 272
__fillMemory16 .............................................................................. 272
__fillMemory32 .............................................................................. 273
__getCycleCounter .......................................................................... 274
__isBatchMode ................................................................................ 275
__loadImage .................................................................................... 275
__memoryRestore ............................................................................ 276
__memoryRestoreFromFile ............................................................. 277
__memorySave ................................................................................ 277
__memorySaveToFile ...................................................................... 278
__messageBoxYesCancel ................................................................ 279
__messageBoxYesNo ...................................................................... 279
__openFile ....................................................................................... 280
__orderInterrupt ............................................................................... 281
__readFile ........................................................................................ 282
__readFileByte ................................................................................. 283
__readMemory8, __readMemoryByte ............................................ 283
__readMemory16 ............................................................................. 284
__readMemory32 ............................................................................. 284
__registerMacroFile ......................................................................... 285
__resetFile ........................................................................................ 285
__setCodeBreak ............................................................................... 286
__setComplexBreak ......................................................................... 287
__setDataBreak ................................................................................ 289
__setLogBreak ................................................................................. 291
__setSimBreak ................................................................................. 292
__setTraceStartBreak ....................................................................... 293
__setTraceStopBreak ....................................................................... 294
__sourcePosition .............................................................................. 295
__strFind .......................................................................................... 295
__subString ...................................................................................... 296
__targetDebuggerVersion ................................................................ 296
__toLower ........................................................................................ 297
AFE1_AFE2-1:1
Contents
15
AFE1_AFE2-1:1
Options available for the C-SPY Atmel-ICE driver, The C-SPY Power
Debugger driver, the C-SPY JTAGICE3 driver, and the C-SPY AVR
ONE! driver ...................................................................................... 314
Options available for the C-SPY JTAGICE mkII driver and the C-SPY
Dragon driver ................................................................................... 314
Options available for the C-SPY Dragon driver .............................. 315
Reference information on C-SPY command line options ... 315
--64bit_doubles ................................................................................ 315
--64k_flash ....................................................................................... 315
--attach_to_running_target ............................................................... 315
--avrone_jtag_clock ......................................................................... 316
--backend .......................................................................................... 316
--code_coverage_file ........................................................................ 317
--cpu ................................................................................................. 317
--cycles ............................................................................................. 318
--debugfile ........................................................................................ 318
--disable_internal_eeprom ............................................................... 319
--disable_interrupts .......................................................................... 319
--download_only .............................................................................. 319
--drv_communication ....................................................................... 319
--drv_communication_log ................................................................ 320
--drv_debug_port ............................................................................. 320
--drv_download_data ....................................................................... 321
--drv_dragon ..................................................................................... 321
--drv_power debugger ...................................................................... 322
--drv_preserve_app_section ............................................................. 322
--drv_preserve_boot_section ............................................................ 322
--drv_set_exit_breakpoint ................................................................ 323
--drv_set_getchar_breakpoint .......................................................... 323
--drv_set_putchar_breakpoint .......................................................... 324
--drv_suppress_download ................................................................ 324
--drv_use_PDI .................................................................................. 325
--drv_verify_download .................................................................... 325
--eeprom_size ................................................................................... 325
AFE1_AFE2-1:1
Contents
17
AFE1_AFE2-1:1
AVR ONE! 2 .................................................................................... 350
JTAGICE3 1 .................................................................................... 351
JTAGICE3 2 .................................................................................... 353
JTAGICE mkII 1 .............................................................................. 354
JTAGICE mkII 2 .............................................................................. 357
Serial Port ......................................................................................... 358
Dragon 1 ........................................................................................... 359
Dragon 2 ........................................................................................... 361
Power Debugger 1 ............................................................................ 362
Power Debugger 2 ............................................................................ 364
Third-Party Driver options ............................................................... 365
AFE1_AFE2-1:1
Tables
1: Typographic conventions used in this guide ......................................................... 25
2: Naming conventions used in this guide ................................................................ 25
3: Driver differences .................................................................................................. 35
4: C-SPY assembler symbols expressions ................................................................ 87
5: Handling name conflicts between hardware registers and assembler labels ......... 87
6: Available breakpoints in C-SPY hardware debugger drivers ............................. 109
7: C-SPY macros for breakpoints ............................................................................ 114
8: Support for timeline information ........................................................................ 177
9: Project options for enabling the profiler ............................................................. 199
10: Project options for enabling code coverage ...................................................... 208
11: Timer interrupt settings ..................................................................................... 247
12: Examples of C-SPY macro variables ................................................................ 259
13: Summary of system macros .............................................................................. 265
14: __cancelInterrupt return values ......................................................................... 268
15: __disableInterrupts return values ...................................................................... 270
16: __driverType return values ............................................................................... 270
17: __enableInterrupts return values ....................................................................... 271
18: __evaluate return values ................................................................................... 271
19: __isBatchMode return values ........................................................................... 275
20: __loadImage return values ................................................................................ 275
21: __messageBoxYesCancel return values ........................................................... 279
22: __messageBoxYesNo return values ................................................................. 279
23: __openFile return values ................................................................................... 280
24: __readFile return values ................................................................................... 282
25: __setCodeBreak return values .......................................................................... 286
26: __set Complex Break return values .................................................................. 289
27: __setDataBreak return values ........................................................................... 290
28: __setLogBreak return values ............................................................................ 291
29: __setSimBreak return values ............................................................................ 292
30: __setTraceStartBreak return values .................................................................. 293
31: __setTraceStopBreak return values .................................................................. 294
19
AFE1_AFE2-1:1
32: __sourcePosition return values ......................................................................... 295
33: __unloadImage return values ............................................................................ 299
34: cspybat parameters ............................................................................................ 310
35: Options specific to the C-SPY drivers you are using ........................................ 337
AFE1_AFE2-1:1
Preface
Welcome to the C-SPY® Debugging Guide . The purpose of this guide is to help
you fully use the features in the IAR C-SPY® Debugger for debugging your
application based on the AVR microcontroller.
REQUIRED KNOWLEDGE
To use the tools in IAR Embedded Workbench, you should have working knowledge of:
● The architecture and instruction set of the Microchip AVR microcontroller (refer to
the chip manufacturer's documentation)
● The C or C++ programming language
● Application development for embedded systems
● The operating system of your host computer.
For more information about the other development tools incorporated in the IDE, refer
to their respective documentation, see Other documentation, page 23.
21
AFE1_AFE2-1:1
What this guide contains
AFE1_AFE2-1:1
Preface
Other documentation
User documentation is available as hypertext PDFs and as a context-sensitive online
help system in HTML format. You can access the documentation from the Information
Center or from the Help menu in the IAR Embedded Workbench IDE. The online help
system is also available via the F1 key.
23
AFE1_AFE2-1:1
Document conventions
WEB SITES
Recommended web sites:
● The Microchip Technology web site, www.microchip.com, that contains
information and news about the Microchip AVR microcontrollers.
● The IAR Systems web site, www.iar.com, that holds application notes and other
product information.
● The web site of the C standardization working group,
www.open-std.org/jtc1/sc22/wg14.
● The web site of the C++ Standards Committee, www.open-std.org/jtc1/sc22/wg21.
● The C++ programming language web site, isocpp.org.
This web site also has a list of recommended books about C++ programming.
● The C and C++ reference web site, en.cppreference.com.
Document conventions
When, in the IAR Systems documentation, we refer to the programming language C, the
text also applies to C++, unless otherwise stated.
When referring to a directory in your product installation, for example avr\doc, the full
path to the location is assumed, for example c:\Program Files\IAR
Systems\Embedded Workbench N.n\avr\doc, where the initial digit of the version
number reflects the initial digit of the version number of the IAR Embedded Workbench
shared components.
AFE1_AFE2-1:1
Preface
TYPOGRAPHIC CONVENTIONS
The IAR Systems documentation set uses the following typographic conventions:
Style Used for
computer • Source code examples and file paths.
• Text on the command line.
• Binary, hexadecimal, and octal numbers.
parameter A placeholder for an actual value used as a parameter, for example
filename.h where filename represents the name of the file.
[option] An optional part of a directive, where [ and ] are not part of the actual
directive, but any [, ], {, or } are part of the directive syntax.
{option} A mandatory part of a directive, where { and } are not part of the
actual directive, but any [, ], {, or } are part of the directive syntax.
[option] An optional part of a command.
[a|b|c] An optional part of a command with alternatives.
{a|b|c} A mandatory part of a command with alternatives.
bold Names of menus, menu commands, buttons, and dialog boxes that
appear on the screen.
italic • A cross-reference within this guide or to another guide.
• Emphasis.
… An ellipsis indicates that the previous item can be repeated an arbitrary
number of times.
Identifies instructions specific to the IAR Embedded Workbench® IDE
interface.
Identifies instructions specific to the command line interface.
Identifies helpful tips and programming hints.
Identifies warnings.
NAMING CONVENTIONS
The following naming conventions are used for the products and tools from IAR
Systems®, when referred to in the documentation:
Brand name Generic term
IAR Embedded Workbench® for AVR IAR Embedded Workbench®
Table 2: Naming conventions used in this guide
25
AFE1_AFE2-1:1
Document conventions
AFE1_AFE2-1:1
Part 1. Basic debugging
This part of the C-SPY® Debugging Guide for AVR includes these chapters:
● Breakpoints
27
28
The IAR C-SPY Debugger
● Introduction to C-SPY
● Debugger concepts
Introduction to C-SPY
These topics are covered:
● An integrated environment
● General C-SPY debugger features
● RTOS awareness
AN INTEGRATED ENVIRONMENT
C-SPY is a high-level-language debugger for embedded applications. It is designed for
use with the IAR Systems compilers and assemblers, and is completely integrated in the
IDE, providing development and debugging within the same application. This will give
you possibilities such as:
● Editing while debugging. During a debug session, you can make corrections directly
in the same source code window that is used for controlling the debugging. Changes
will be included in the next project rebuild.
● Setting breakpoints at any point during the development cycle. You can inspect and
modify breakpoint definitions also when the debugger is not running, and
breakpoint definitions flow with the text as you edit. Your debug settings, such as
29
AFE1_AFE2-1:1
Introduction to C-SPY
watch properties, window layouts, and register groups will be preserved between
your debug sessions.
All windows that are open in the Embedded Workbench workspace will stay open when
you start the C-SPY Debugger. In addition, a set of C-SPY-specific windows are opened.
AFE1_AFE2-1:1
The IAR C-SPY Debugger
program counter is. You can select any function in the call stack, and for each
function you get valid information for local variables and available registers.
● Powerful macro system
C-SPY includes a powerful internal macro system, to allow you to define complex
sets of actions to be performed. C-SPY macros can be used on their own or in
conjunction with complex breakpoints and—if you are using the simulator—the
interrupt simulation system to perform a wide variety of tasks.
RTOS AWARENESS
C-SPY supports RTOS-aware debugging.
These operating systems are currently supported:
● Micrium uC/OS-II
● OSEK Run Time Interface (ORTI)
RTOS plugin modules can be provided by IAR Systems, and by third-party suppliers.
Contact your software distributor or IAR Systems representative, alternatively visit the
IAR Systems web site, for information about supported RTOS modules.
A C-SPY RTOS awareness plugin module gives you a high level of control and visibility
over an application built on top of an RTOS. It displays RTOS-specific items like task
lists, queues, semaphores, mailboxes, and various RTOS system variables. Task-specific
breakpoints and task-specific stepping make it easier to debug tasks.
A loaded plugin will add its own menu, set of windows, and buttons when a debug
session is started (provided that the RTOS is linked with the application). For
31
AFE1_AFE2-1:1
Debugger concepts
information about other RTOS awareness plugin modules, refer to the manufacturer of
the plugin module.
Debugger concepts
This section introduces some of the concepts and terms that are related to debugging in
general and to C-SPY in particular. This section does not contain specific information
related to C-SPY features. Instead, you will find such information in the other chapters
of this documentation. The IAR Systems user documentation uses the terms described
in this section when referring to these concepts.
These topics are covered:
● C-SPY and target systems
● The debugger
● The target system
● The application
● C-SPY debugger systems
● The ROM-monitor program
● Third-party debuggers
● C-SPY plugin modules
AFE1_AFE2-1:1
The IAR C-SPY Debugger
THE DEBUGGER
The debugger, for instance C-SPY, is the program that you use for debugging your
applications on a target system.
THE APPLICATION
A user application is the software you have developed and which you want to debug
using C-SPY.
33
AFE1_AFE2-1:1
Debugger concepts
interface—menus, windows, and dialog boxes—to the functions provided by the target
system, for instance, special breakpoints. Typically, there are three main types of C-SPY
drivers:
● Simulator driver
● ROM-monitor driver
● Emulator driver.
C-SPY is available with a simulator driver, and depending on your product package,
optional drivers for hardware debugger systems. For an overview of available C-SPY
drivers and the functionality of each driver, see C-SPY drivers overview, page 35.
THIRD-PARTY DEBUGGERS
You can use a third-party debugger together with the IAR Systems toolchain as long as
the third-party debugger can read any of the output formats provided by XLINK, such
as UBROF, ELF/DWARF, COFF, Intel-extended, Motorola, or any other available
format. For information about which format to use with a third-party debugger, see the
user documentation supplied with that tool.
AFE1_AFE2-1:1
The IAR C-SPY Debugger
35
AFE1_AFE2-1:1
The IAR C-SPY Simulator
1 With specific requirements or restrictions, see the respective chapter in this guide.
AFE1_AFE2-1:1
The IAR C-SPY Debugger
FEATURES
In addition to the general features of C-SPY, the Atmel-ICE driver also provides:
● Execution in real time with full access to the microcontroller
● Use of the available hardware breakpoints on the target device and unlimited use of
software breakpoints
● Zero memory footprint on the target system
● Built-in flash loader
● Communication via USB
● Fuse handler.
37
AFE1_AFE2-1:1
The C-SPY Atmel-ICE driver
COMMUNICATION OVERVIEW
The C-SPY Atmel-ICE driver uses the USB port to communicate with Atmel-ICE.
Atmel-ICE communicates with the hardware interface—for example JTAG, PDI,
debugWIRE, ISP, TPI, or UPDI—on the microcontroller.
HARDWARE INSTALLATION
For information about the hardware installation, see the Atmel-ICE User Guide from
Microchip Technology. This power-up sequence is recommended to ensure proper
communication between the target board, Atmel-ICE, and C-SPY:
1 Power up the target board.
2 Power up Atmel-ICE.
3 Start the C-SPY debug session.
To enable the hardware interface on the microcontroller, the JTAG and OCD fuse bits
must be enabled. Use the Fuse Handler dialog box available in the IAR Embedded
AFE1_AFE2-1:1
The IAR C-SPY Debugger
Workbench IDE or a similar tool capable of programming the fuses to check and
program these bits. For more information, see the Fuse Handler dialog box, page 375.
FEATURES
In addition to the general features of C-SPY, the Power Debugger driver also provides:
● Execution in real time with full access to the microcontroller
● Use of the available hardware breakpoints on the target device and unlimited use of
software breakpoints
● Zero memory footprint on the target system
● Built-in flash loader
● Communication via USB
● Fuse handler.
COMMUNICATION OVERVIEW
The C-SPY Power Debugger driver uses the USB port to communicate with the Atmel
Power Debugger. The Atmel Power Debugger communicates with the hardware
39
AFE1_AFE2-1:1
The C-SPY Power Debugger driver
HARDWARE INSTALLATION
For information about the hardware installation, see the Microchip Technology web site
www.microchip.com. This power-up sequence is recommended to ensure proper
communication between the target board, the Atmel Power Debugger, and C-SPY:
1 Power up the target board.
2 Power up the Atmel Power Debugger.
3 Start the C-SPY debug session.
To enable the hardware interface on the microcontroller, the JTAG and OCD fuse bits
must be enabled. Use the Fuse Handler dialog box available in the IAR Embedded
Workbench IDE or a similar tool capable of programming the fuses to check and
program these bits. For more information, see the Fuse Handler dialog box, page 375.
AFE1_AFE2-1:1
The IAR C-SPY Debugger
FEATURES
In addition to the general features of C-SPY, the JTAGICE3 driver also provides:
● Execution in real time with full access to the microcontroller
● Use of the available hardware breakpoints on the target device and unlimited use of
software breakpoints
● Zero memory footprint on the target system
● Built-in flash loader
● Communication via USB
● Fuse handler.
41
AFE1_AFE2-1:1
The C-SPY JTAGICE3 driver
COMMUNICATION OVERVIEW
The C-SPY JTAGICE3 driver uses the USB port to communicate with Atmel
JTAGICE3. JTAGICE3 communicates with the hardware interface—for example JTAG,
PDI, debugWIRE, or ISP—on the microcontroller.
HARDWARE INSTALLATION
For information about the hardware installation, see the JTAGICE3 User Guide from
Microchip Technology. This power-up sequence is recommended to ensure proper
communication between the target board, JTAGICE3, and C-SPY:
1 Power up the target board.
2 Power up JTAGICE3.
3 Start the C-SPY debug session.
To enable the hardware interface on the microcontroller, the JTAG and OCD fuse bits
must be enabled. Use the Fuse Handler dialog box available in the IAR Embedded
AFE1_AFE2-1:1
The IAR C-SPY Debugger
Workbench IDE or a similar tool capable of programming the fuses to check and
program these bits. For more information, see the Fuse Handler dialog box, page 375.
FEATURES
In addition to the general features of C-SPY, the JTAGICE mkII driver also provides:
● Execution in real time with full access to the microcontroller
● Use of the available hardware breakpoints on the target device and unlimited use of
software breakpoints, for devices that support software breakpoints
● Zero memory footprint on the target system
● Built-in flash loader
● Communication via the serial port or USB
● Fuse handler.
43
AFE1_AFE2-1:1
The C-SPY JTAGICE mkII/Dragon driver
COMMUNICATION OVERVIEW
The C-SPY JTAGICE mkII driver uses the serial port to communicate with Atmel AVR
JTAGICE mkII. JTAGICE mkII communicates with the JTAG, the PDI, or the
debugWIRE interface on the microcontroller.
HARDWARE INSTALLATION
For information about the hardware installation, see the AVR® JTAGICE mkII User
Guide from Microchip Technology. The following power-up sequence is recommended
to ensure proper communication between the target board, JTAGICE mkII, and C-SPY:
1 Power up the target board.
2 Power up JTAGICE mkII.
3 Start the C-SPY debug session.
To enable the JTAG interface on the microcontroller, the JTAG and OCD fuse bits must
be enabled. Use the Fuse Handler dialog box available in the IAR Embedded
AFE1_AFE2-1:1
The IAR C-SPY Debugger
Workbench IDE or a similar tool capable of programming the fuses to check and
program these bits. For more information, see the Fuse Handler dialog box, page 375.
FEATURES
In addition to the general features of C-SPY, the AVR ONE! driver also provides:
● Execution in real time with full access to the microcontroller
● Use of the available hardware breakpoints on the target device and unlimited use of
software breakpoints
● Zero memory footprint on the target system
● Built-in flash loader
● Communication via USB
● Fuse handler.
45
AFE1_AFE2-1:1
The C-SPY AVR ONE! driver
COMMUNICATION OVERVIEW
The C-SPY AVR ONE! driver uses the USB port to communicate with Atmel AVR
ONE!. AVR ONE! communicates with the hardware interface—for example JTAG,
PDI, debugWIRE, or ISP—on the microcontroller.
HARDWARE INSTALLATION
For information about the hardware installation, see the AVR ONE! User Guide from
Microchip Technology. This power-up sequence is recommended to ensure proper
communication between the target board, AVR ONE!, and C-SPY:
1 Power up the target board.
2 Power up AVR ONE!.
3 Start the C-SPY debug session.
To enable the hardware interface on the microcontroller, the JTAG and OCD fuse bits
must be enabled. Use the Fuse Handler dialog box available in the IAR Embedded
AFE1_AFE2-1:1
The IAR C-SPY Debugger
Workbench IDE or a similar tool capable of programming the fuses to check and
program these bits. For more information, see the Fuse Handler dialog box, page 377.
47
AFE1_AFE2-1:1
The C-SPY AVR ONE! driver
AFE1_AFE2-1:1
Getting started using
C-SPY
● Setting up C-SPY
● Starting C-SPY
Setting up C-SPY
These tasks are covered:
● Setting up for debugging
● Executing from reset
● Using a setup macro file
● Selecting a device description file
● Loading plugin modules
49
AFE1_AFE2-1:1
Setting up C-SPY
AFE1_AFE2-1:1
Getting started using C-SPY
Starting C-SPY
When you have set up the debugger, you are ready to start a debug session.
These tasks are covered:
● Starting a debug session
● Loading executable files built outside of the IDE
● Starting a debug session with source files missing
● Loading multiple images
● Editing in C-SPY windows
51
AFE1_AFE2-1:1
Starting C-SPY
AFE1_AFE2-1:1
Getting started using C-SPY
However, if C-SPY cannot automatically find the source files, for example if the
application was built on another computer, the Get Alternative File dialog box is
displayed:
53
AFE1_AFE2-1:1
Starting C-SPY
In windows where you can edit the Expression field and in the Quick Watch window,
you can specify the number of elements to be displayed in the field by adding a
semicolon followed by an integer. For example, to display only the three first elements
of an array named myArray, or three elements in sequence starting with the element
pointed to by a pointer, write:
myArray;3
Optionally, add a comma and another integer that specifies which element to start with.
For example, to display elements 10–14, write:
myArray;5,10
Note: For pointers, there are no built-in limits on displayed element count, and no
validation of the pointer value.
AFE1_AFE2-1:1
Getting started using C-SPY
55
AFE1_AFE2-1:1
Reference information on starting C-SPY
For example, a macro that enables external SDRAM could look like this:
/* Your macro function. */
enableExternalSDRAM()
{
__message "Enabling external SDRAM\n";
__writeMemory32(...);
}
AFE1_AFE2-1:1
Getting started using C-SPY
Menu bar
These menus are available during a debug session:
Debug
Provides commands for executing and debugging the source application. Most
of the commands are also available as icon buttons on the debug toolbar.
C-SPY driver menu
Provides commands specific to a C-SPY driver. The driver-specific menu is only
available when the driver is used. For information about the driver-specific
menu commands, see Reference information on C-SPY driver menus, page 367.
Debug menu
The Debug menu is available during a debug session. The Debug menu provides
commands for executing and debugging the source application. Most of the commands
are also available as icon buttons on the debug toolbar.
57
AFE1_AFE2-1:1
Reference information on starting C-SPY
Break
Stops the application execution.
Reset
Resets the target processor. Click the drop-down button to access a menu with
additional commands.
Enable Run to 'label', where label typically is main. Enables and disables
the project option Run to without exiting the debug session. This menu
command is only available if you have selected Run to in the Options dialog
box.
Reset strategies, which contains a list of reset strategies supported by the C-SPY
driver you are using. This means that you can choose a different reset strategy
than the one used initially without exiting the debug session. Reset strategies are
only available if the C-SPY driver you are using supports alternate reset
strategies.
Stop Debugging (Ctrl+Shift+D)
Stops the debugging session and returns you to the project manager.
Step Over (F10)
Executes the next statement, function call, or instruction, without entering C or
C++ functions or assembler subroutines.
Step Into (F11)
Executes the next statement or instruction, or function call, entering C or C++
functions or assembler subroutines.
Step Out (Shift+F11)
Executes from the current statement up to the statement after the call to the
current function.
Next Statement
Executes directly to the next statement without stopping at individual function
calls.
Run to Cursor
Executes from the current statement or instruction up to a selected statement or
instruction.
Autostep
Displays a dialog box where you can customize and perform autostepping, see
Autostep settings dialog box, page 82.
AFE1_AFE2-1:1
Getting started using C-SPY
C-SPY windows
Depending on the C-SPY driver you are using, these windows specific to C-SPY are
available during a debug session:
● C-SPY Debugger main window
● Disassembly window
● Memory window
59
AFE1_AFE2-1:1
Reference information on starting C-SPY
Images window
The Images window is available from the View menu.
AFE1_AFE2-1:1
Getting started using C-SPY
Requirements
None; this window is always available.
Display area
C-SPY can either use debug information from all of the loaded images simultaneously,
or from one image at a time. Double-click on a row to show information only for that
image. The current choice is highlighted.
This area lists the loaded images in these columns:
Name
The name of the loaded image.
Path
The path to the loaded image.
Context menu
This context menu is available:
Related information
For related information, see:
● Loading multiple images, page 53
● Images, page 340
● __loadImage, page 275.
61
AFE1_AFE2-1:1
Reference information on starting C-SPY
See also Starting a debug session with source files missing, page 52.
Suggested alternative
Specify an alternative file.
Skip
C-SPY will assume that the source file is not available for this debug session.
Related information
For related information, see Starting a debug session with source files missing, page 52.
AFE1_AFE2-1:1
Executing your application
● Introduction to application execution
63
AFE1_AFE2-1:1
Introduction to application execution
Disassembly mode debugging lets you focus on the critical sections of your application,
and provides you with precise control of the application code. You can open a
disassembly window which displays a mnemonic assembler listing of your application
based on actual memory contents rather than source code, and lets you execute the
application exactly one machine instruction at a time.
Regardless of which mode you are debugging in, you can display registers and memory,
and change their contents.
SINGLE STEPPING
C-SPY allows more stepping precision than most other debuggers because it is not
line-oriented but statement-oriented. The compiler generates detailed stepping
information in the form of step points at each statement, and at each function call. That
is, source code locations where you might consider whether to execute a step into or a
step over command. Because the step points are located not only at each statement but
also at each function call, the step functionality allows a finer granularity than just
stepping on statements.
There are several factors that can slow down the stepping speed. If you find it too slow,
see Troubleshooting slow stepping speed, page 66 for some tips.
AFE1_AFE2-1:1
Executing your application
Consider this example and assume that the previous step has taken you to the f(i)
function call (highlighted):
extern int g(int);
int f(int n)
{
value = g(n-1) + g(n-2) + g(n-3);
return value;
}
int main()
{
...
f(i);
value ++;
}
Step Into
While stepping, you typically consider whether to step into a function and continue
stepping inside the function or subroutine. The Step Into command takes you to the first
step point within the subroutine g(n-1):
extern int g(int);
int f(int n)
{
value = g(n-1) + g(n-2) + g(n-3);
return value;
}
The Step Into command executes to the next step point in the normal flow of control,
regardless of whether it is in the same or another function.
Step Over
The Step Over command executes to the next step point in the same function, without
stopping inside called functions. The command would take you to the g(n-2) function
call, which is not a statement on its own but part of the same statement as g(n-1). Thus,
you can skip uninteresting calls which are parts of statements and instead focus on
critical parts:
extern int g(int);
int f(int n)
{
value = g(n-1) + g(n-2) + g(n-3);
return value;
}
65
AFE1_AFE2-1:1
Introduction to application execution
Next Statement
The Next Statement command executes directly to the next statement, in this case
return value, allowing faster stepping:
Step Out
When inside the function, you can—if you wish—use the Step Out command to step
out of it before it reaches the exit. This will take you directly to the statement
immediately after the function call:
extern int g(int);
int f(int n)
{
value = g(n-1) + g(n-2) g(n-3);
return value;
}
int main()
{
...
f(i);
value ++;
}
The possibility of stepping into an individual function that is part of a more complex
statement is particularly useful when you use C code containing many nested function
calls. It is also very useful for C++, which tends to have many implicit function calls,
such as constructors, destructors, assignment operators, and other user-defined
operators.
This detailed stepping can in some circumstances be either invaluable or unnecessarily
slow. For this reason, you can also step only on statements, which means faster stepping.
AFE1_AFE2-1:1
Executing your application
Go
The Go command continues execution from the current position until a breakpoint or
program exit is reached.
67
AFE1_AFE2-1:1
Introduction to application execution
Run to Cursor
The Run to Cursor command executes to the position in the source code where you
have placed the cursor. The Run to Cursor command also works in the Disassembly
window and in the Call Stack window.
HIGHLIGHTING
At each stop, C-SPY highlights the corresponding C or C++ source or instruction with
a green color, in the editor and the Disassembly window respectively. In addition, a
green arrow appears in the editor window when you step on C or C++ source level, and
in the Disassembly window when you step on disassembly level. This is determined by
which of the windows is the active window. If none of the windows are active, it is
determined by which of the windows was last active.
For simple statements without function calls, the whole statement is typically
highlighted. When stopping at a statement with function calls, C-SPY highlights the first
call because this illustrates more clearly what Step Into and Step Over would mean at
that time.
Occasionally, you will notice that a statement in the source window is highlighted using
a pale variant of the normal highlight color. This happens when the program counter is
at an assembler instruction which is part of a source statement but not exactly at a step
point. This is often the case when stepping in the Disassembly window. Only when the
program counter is at the first instruction of the source statement, the ordinary highlight
color is used.
AFE1_AFE2-1:1
Executing your application
are updated to display the state of that particular call frame. This includes the editor,
Locals, Register, Watch, and Disassembly windows. A function would normally not
make use of all registers, so these registers might have undefined states and be displayed
as dashes (---).
In the editor and Disassembly windows, a green highlight indicates the topmost, or
current, call frame; a yellow highlight is used when inspecting other frames.
For your convenience, it is possible to select a function in the call stack and click the
Run to Cursor command to execute to that function.
Assembler source code does not automatically contain any call frame information. To
see the call chain also for your assembler modules, you can add the appropriate CFI
assembler directives to the assembler source code. For more information, see the AVR®
IAR Assembler Reference Guide.
DEBUG LOGGING
The Debug Log window displays debugger output, such as diagnostic messages,
macro-generated output, and information about trace.
It can sometimes be convenient to log the information to a file where you can easily
inspect it, see Log File dialog box, page 80. The two main advantages are:
● The file can be opened in another tool, for instance an editor, so you can navigate
and search within the file for particularly interesting parts
● The file provides history about how you have controlled the execution, for instance,
which breakpoints that have been triggered etc.
69
AFE1_AFE2-1:1
Reference information on application execution
AFE1_AFE2-1:1
Executing your application
Disassembly window
The C-SPY Disassembly window is available from the View menu.
This window shows the application being debugged as disassembled application code.
To change the default color of the source code in the Disassembly window:
1 Choose Tools>Options>Debugger.
2 Set the default color using the Source code coloring in disassembly window option.
To view the corresponding assembler code for a function, you can select it in the editor
window and drag it to the Disassembly window.
See also Source and disassembly mode debugging, page 63.
Requirements
None; this window is always available.
71
AFE1_AFE2-1:1
Reference information on application execution
Toolbar
The toolbar contains:
Go to
The memory location or symbol you want to view.
Zone
Selects a memory zone, see C-SPY memory zones, page 134.
Toggle Mixed-Mode
Toggles between displaying only disassembled code or disassembled code
together with the corresponding source code. Source code requires that the
corresponding source file has been compiled with debug information
Display area
The display area shows the disassembled application code.
This area contains these graphic elements:
Green highlight Indicates the current position, that is the next assembler
instruction to be executed. To move the cursor to any line in
the Disassembly window, click the line. Alternatively, move
the cursor using the navigation keys.
Yellow highlight Indicates a position other than the current position, such as
when navigating between frames in the Call Stack window
or between items in the Trace window.
Red dot Indicates a breakpoint. Double-click in the gray left-side
margin of the window to set a breakpoint. For more
information, see Breakpoints, page 105.
Green diamond Indicates code that has been executed—that is, code
coverage.
If instruction profiling has been enabled from the context menu, an extra column in the
left-side margin appears with information about how many times each instruction has
been executed.
AFE1_AFE2-1:1
Executing your application
Context menu
This context menu is available:
Note: The contents of this menu are dynamic, which means that the commands on the
menu might depend on your product package.
These commands are available:
Move to PC
Displays code at the current program counter location.
Run to Cursor
Executes the application from the current position up to the line containing the
cursor.
Code Coverage
Displays a submenu that provides commands for controlling code coverage.
This command is only enabled if the driver you are using supports it.
73
AFE1_AFE2-1:1
Reference information on application execution
Instruction Profiling
Displays a submenu that provides commands for controlling instruction
profiling. This command is only enabled if the driver you are using supports it.
AFE1_AFE2-1:1
Executing your application
This window displays the C function call stack with the current function at the top. To
inspect a function call, double-click it. C-SPY now focuses on that call frame instead.
If the next Step Into command would step to a function call, the name of the function is
displayed in the gray bar at the top of the window. This is especially useful for implicit
function calls, such as C++ constructors, destructors, and operators.
See also Viewing the call stack, page 68.
Requirements
None; this window is always available.
75
AFE1_AFE2-1:1
Reference information on application execution
Display area
Each entry in the display area is formatted in one of these ways:
Context menu
This context menu is available:
AFE1_AFE2-1:1
Executing your application
Use this window to enter input to your application, and display output from it.
To use this window, you must:
1 Link your application with the option With I/O emulation modules.
C-SPY will then direct stdin, stdout and stderr to this window. If the Terminal I/O
window is closed, C-SPY will open it automatically when input is required, but not for
output.
See also Terminal input and output, page 69.
Requirements
None; this window is always available.
77
AFE1_AFE2-1:1
Reference information on application execution
Input
Type the text that you want to input to your application.
Ctrl codes
Opens a menu for input of special characters, such as EOF (end of file) and NUL.
Options
Opens the IDE Options dialog box where you can set options for terminal I/O. For
reference information about the options available in this dialog box, see Terminal I/O
options in IDE Project Management and Building Guide for AVR.
Use this dialog box to select a destination log file for terminal I/O from C-SPY.
See also Terminal input and output, page 69.
Requirements
None; this dialog box is always available.
AFE1_AFE2-1:1
Executing your application
See also Debug logging, page 69 and Log File dialog box, page 80.
Requirements
None; this window is always available.
Context menu
This context menu is available:
79
AFE1_AFE2-1:1
Reference information on application execution
Messages
Shows all C-SPY messages.
Warnings
Shows warnings and errors.
Errors
Shows errors only.
Copy
Copies the contents of the window.
Select All
Selects the contents of the window.
Clear All
Clears the contents of the window.
Requirements
None; this dialog box is always available.
Include
The information printed in the file is, by default, the same as the information listed in
the Log window. Use the browse button, to override the default file and location of the
AFE1_AFE2-1:1
Executing your application
log file (the default filename extension is log). To change the information logged,
choose between:
Errors
C-SPY has failed to perform an operation.
Warnings
An error or omission of concern.
Info
Progress information about actions C-SPY has performed.
User
Messages from C-SPY macros, that is, your messages using the __message
statement.
Abort
The application stops executing and the runtime library function abort, which is part
of your application on the target system, will be called. This means that the application
itself terminates its execution.
Debug
C-SPY stops the execution of the application and returns control to you.
Ignore
The assertion is ignored and the application continues to execute.
81
AFE1_AFE2-1:1
Reference information on application execution
Requirements
None; this dialog box is always available.
Delay
Specify the delay between each step in milliseconds.
Cores window
The Cores window is available from the View menu.
This window displays information about the executing core, such as its execution state.
This information is primarily useful for IAR Embedded Workbench products that
support multi-core debugging.
Requirements
None; this window is always available.
Display area
A row in this area shows information about a core, in these columns:
Execution state
Displays one of these icons to indicate the execution state of the core.
AFE1_AFE2-1:1
Executing your application
Core
The name of the core.
Status
The status of the execution, which can be one of Stopped, Running, or
Sleeping.
PC
The value of the program counter.
Cycles | Time
The value of the cycle counter or the execution time since the start of the
execution, depending on the debugger driver you are using.
83
AFE1_AFE2-1:1
Reference information on application execution
AFE1_AFE2-1:1
Variables and expressions
● Introduction to working with variables and expressions
85
AFE1_AFE2-1:1
Introduction to working with variables and expressions
● The Symbols window displays all symbols with a static location, that is, C/C++
functions, assembler labels, and variables with static storage duration, including
symbols from the runtime library.
These additional methods for looking at variables are suitable for more advanced
analysis:
● The Data Log window and the Data Log Summary window display logs of
accesses to up to four different memory locations you choose by setting data log
breakpoints. Data logging can help you locate frequently accessed data. You can
then consider whether you should place that data in more efficient memory.
For more information about these windows, see The application timeline, page 175.
C-SPY EXPRESSIONS
C-SPY expressions can include any type of C expression, except for calls to functions.
The following types of symbols can be used in expressions:
● C/C++ symbols
● Assembler symbols (register names and assembler labels)
● C-SPY macro functions
● C-SPY macro variables.
Expressions that are built with these types of symbols are called C-SPY expressions and
there are several methods for monitoring these in C-SPY. Examples of valid C-SPY
expressions are:
i + j
i = 42
myVar = cVar
cVar = myVar + 2
#asm_label
#R2
#PC
my_macro_func(19)
If you have a static variable with the same name declared in several different functions,
use the notation function::variable to specify which variable to monitor.
C/C++ symbols
C symbols are symbols that you have defined in the C source code of your application,
for instance variables, constants, and functions—functions can be used as symbols but
cannot be executed. C symbols can be referenced by their names.
Note: C++ symbols might implicitly contain function calls which are not allowed in
C-SPY symbols and expressions.
AFE1_AFE2-1:1
Variables and expressions
Note: Some attributes available in C/C++, like volatile, are not fully supported by
C-SPY. For example, this line will not be accepted by C-SPY:
sizeof(unsigned char volatile __memattr *)
Assembler symbols
Assembler symbols can be assembler labels or registers, for example the program
counter, the stack pointer, or other CPU registers. If a device description file is used, all
memory-mapped peripheral units, such as I/O ports, can also be used as assembler
symbols in the same way as the CPU registers. See Modifying a device description file,
page 55.
Assembler symbols can be used in C-SPY expressions if they are prefixed by #.
Example What it does
#PC++ Increments the value of the program counter.
myVar = #SP Assigns the current value of the stack pointer register to your
C-SPY variable.
myVar = #label Sets myVar to the value of an integer at the address of label.
myptr = &#label7 Sets myptr to an int * pointer pointing at label7.
Table 4: C-SPY assembler symbols expressions
In case of a name conflict between a hardware register and an assembler label, hardware
registers have a higher precedence. To refer to an assembler label in such a case, you
must enclose the label in back quotes ` (ASCII character 0x60). For example:
Example What it does
#PC Refers to the program counter.
#`PC` Refers to the assembler label PC.
Table 5: Handling name conflicts between hardware registers and assembler labels
Which processor-specific symbols are available by default can be seen in the Registers
window, using the CPU Registers register group. See Registers window, page 153.
87
AFE1_AFE2-1:1
Introduction to working with variables and expressions
Using sizeof
According to standard C, there are two syntactical forms of sizeof:
sizeof(type)
sizeof expr
Effects of optimizations
The compiler is free to optimize the application software as much as possible, as long
as the expected behavior remains. The optimization can affect the code so that
debugging might be more difficult because it will be less clear how the generated code
relates to the source code. Typically, using a high optimization level can affect the code
in a way that will not allow you to view a value of a variable as expected.
Consider this example:
myFunction()
{
int i = 42;
...
x = computer(i); /* Here, the value of i is known to C-SPY */
...
}
AFE1_AFE2-1:1
Variables and expressions
From the point where the variable i is declared until it is actually used, the compiler
does not need to waste stack or register space on it. The compiler can optimize the code,
which means that C-SPY will not be able to display the value until it is actually used. If
you try to view the value of a variable that is temporarily unavailable, C-SPY will
display the text:
Unavailable
If you need full information about values of variables during your debugging session,
you should make sure to use the lowest optimization level during compilation, that is,
None.
89
AFE1_AFE2-1:1
Reference information on working with variables and expressions
variables of type int. However, in the Watch, and Quick Watch windows, you can
select a different interpretation to better suit the declaration of the variables.
In this figure, you can see four variables in the Watch window and their corresponding
declarations in the assembler source file to the left:
Note that asmvar4 is displayed as an int, although the original assembler declaration
probably intended for it to be a single byte quantity. From the context menu you can
make C-SPY display the variable as, for example, an 8-bit unsigned variable. This has
already been specified for the asmvar3 variable.
AFE1_AFE2-1:1
Variables and expressions
Auto window
The Auto window is available from the View menu.
This window displays a useful selection of variables and expressions in, or near, the
current statement. Every time execution in C-SPY stops, the values in the Auto window
are recalculated. Values that have changed since the last stop are highlighted in red.
See also Editing in C-SPY windows, page 54.
Requirements
None; this window is always available.
Context menu
This context menu is available:
Note: The contents of this menu are dynamic and depend on which features that your
combination of software and hardware supports. However, the list of menu commands
below is complete and covers all possible commands.
91
AFE1_AFE2-1:1
Reference information on working with variables and expressions
Variables The display setting affects only the selected variable, not
other variables.
Array elements The display setting affects the complete array, that is, the
same display format is used for each array element.
Structure fields All elements with the same definition—the same field
name and C declaration type—are affected by the
display setting.
Show As
Displays a submenu that provides commands for changing the default type
interpretation of variables. The commands on this submenu are mainly useful
for assembler variables—data at assembler labels—because these are, by
default, displayed as integers. For more information, see Viewing assembler
variables, page 89.
AFE1_AFE2-1:1
Variables and expressions
Locals window
The Locals window is available from the View menu.
This window displays the local variables and parameters for the current function. Every
time execution in C-SPY stops, the values in the window are recalculated. Values that
have changed since the last stop are highlighted in red.
See also Editing in C-SPY windows, page 54.
Requirements
None; this window is always available.
Context menu
This context menu is available:
Note: The contents of this menu are dynamic and depend on which features that your
combination of software and hardware supports. However, the list of menu commands
below is complete and covers all possible commands.
These commands are available:
Remove
Removes the selected expression from the window.
Remove All
Removes all expressions listed in the window.
93
AFE1_AFE2-1:1
Reference information on working with variables and expressions
Default Format,
Binary Format,
Octal Format,
Decimal Format,
Hexadecimal Format,
Char Format
Changes the display format of expressions. The display format setting affects
different types of expressions in different ways. Your selection of display format
is saved between debug sessions. These commands are available if a selected
line in the window contains a variable.
The display format setting affects different types of expressions in these ways:
Variables The display setting affects only the selected variable, not
other variables.
Array elements The display setting affects the complete array, that is, the
same display format is used for each array element.
Structure fields All elements with the same definition—the same field
name and C declaration type—are affected by the
display setting.
Show As
Displays a submenu that provides commands for changing the default type
interpretation of variables. The commands on this submenu are mainly useful
for assembler variables—data at assembler labels—because these are, by
default, displayed as integers. For more information, see Viewing assembler
variables, page 89.
AFE1_AFE2-1:1
Variables and expressions
Watch window
The Watch window is available from the View menu.
Use this window to monitor the values of C-SPY expressions or variables. You can open
up to four instances of this window, where you can view, add, modify, and remove
expressions. Tree structures of arrays, structs, and unions are expandable, which means
that you can study each item of these.
Every time execution in C-SPY stops, the values in the Watch window are recalculated.
Values that have changed since the last stop are highlighted in red.
Be aware that expanding very huge arrays can cause an out-of-memory crash. To avoid
this, expansion is automatically performed in steps of 5000 elements.
See also Editing in C-SPY windows, page 54.
Requirements
None; this window is always available.
95
AFE1_AFE2-1:1
Reference information on working with variables and expressions
Context menu
This context menu is available:
Note: The contents of this menu are dynamic and depend on which features that your
combination of software and hardware supports. However, the list of menu commands
below is complete and covers all possible commands.
These commands are available:
Remove
Removes the selected expression from the window.
Remove All
Removes all expressions listed in the window.
Default Format,
Binary Format,
Octal Format,
Decimal Format,
Hexadecimal Format,
Char Format
Changes the display format of expressions. The display format setting affects
different types of expressions in different ways. Your selection of display format
is saved between debug sessions. These commands are available if a selected
line in the window contains a variable.
The display format setting affects different types of expressions in these ways:
Variables The display setting affects only the selected variable, not
other variables.
Array elements The display setting affects the complete array, that is, the
same display format is used for each array element.
Structure fields All elements with the same definition—the same field
name and C declaration type—are affected by the
display setting.
AFE1_AFE2-1:1
Variables and expressions
Show As
Displays a submenu that provides commands for changing the default type
interpretation of variables. The commands on this submenu are mainly useful
for assembler variables—data at assembler labels—because these are, by
default, displayed as integers. For more information, see Viewing assembler
variables, page 89.
Statics window
The Statics window is available from the View menu.
This window displays the values of variables with static storage duration that you have
selected. Typically, that is variables with file scope but it can also be static variables in
functions and classes. Note that volatile declared variables with static storage
duration will not be displayed.
Every time execution in C-SPY stops, the values in the Statics window are recalculated.
Values that have changed since the last stop are highlighted in red.
Click any column header (except for Value) to sort on that column.
See also Editing in C-SPY windows, page 54.
To select variables to monitor:
1 In the window, right-click and choose Select statics from the context menu. The
window now lists all variables with static storage duration.
2 Either individually select the variables you want to display, or choose one of the Select
commands from the context menu.
3 When you have made your selections, choose Select statics from the context menu to
toggle back to normal display mode.
Requirements
None; this window is always available.
97
AFE1_AFE2-1:1
Reference information on working with variables and expressions
Display area
This area contains these columns:
Expression
The name of the variable. The base name of the variable is followed by the full
name, which includes module, class, or function scope. This column is not
editable.
Value
The value of the variable. Values that have changed are highlighted in red.
Dragging text or a variable from another window and dropping it on the Value
column will assign a new value to the variable in that row.
This column is editable.
Location
The location in memory where this variable is stored.
Type
The data type of the variable.
Module
The module of the variable.
AFE1_AFE2-1:1
Variables and expressions
Context menu
This context menu is available:
Variables The display setting affects only the selected variable, not
other variables.
Array elements The display setting affects the complete array, that is, the
same display format is used for each array element.
Structure fields All elements with the same definition—the same field
name and C declaration type—are affected by the
display setting.
Save to File
Saves the content of the Statics window to a log file.
99
AFE1_AFE2-1:1
Reference information on working with variables and expressions
Select Statics
Selects all variables with static storage duration; this command also enables all
Select commands below. Select the variables you want to monitor. When you
have made your selections, select this menu command again to toggle back to
normal display mode.
Select All
Selects all variables.
Select None
Deselects all variables.
Select All in module
Selects all variables in the selected module.
Select None in module
Deselects all variables in the selected module.
Use this window to watch the value of a variable or expression and evaluate expressions
at a specific point in time.
In contrast to the Watch window, the Quick Watch window gives you precise control
over when to evaluate the expression. For single variables this might not be necessary,
but for expressions with possible side effects, such as assignments and C-SPY macro
functions, it allows you to perform evaluations under controlled conditions.
See also Editing in C-SPY windows, page 54.
To evaluate an expression:
1 In the editor window, right-click on the expression you want to examine and choose
Quick Watch from the context menu that appears.
2 The expression will automatically appear in the Quick Watch window.
AFE1_AFE2-1:1
Variables and expressions
Alternatively:
3 In the Quick Watch window, type the expression you want to examine in the
Expressions text box.
4 Click the Recalculate button to calculate the value of the expression.
For an example, see Using C-SPY macros, page 253.
Requirements
None; this window is always available.
Context menu
This context menu is available:
Note: The contents of this menu are dynamic and depend on which features that your
combination of software and hardware supports. However, the list of menu commands
below is complete and covers all possible commands.
These commands are available:
Remove
Removes the selected expression from the window.
Remove All
Removes all expressions listed in the window.
Default Format,
Binary Format,
Octal Format,
Decimal Format,
Hexadecimal Format,
Char Format
Changes the display format of expressions. The display format setting affects
different types of expressions in different ways. Your selection of display format
is saved between debug sessions. These commands are available if a selected
line in the window contains a variable.
101
AFE1_AFE2-1:1
Reference information on working with variables and expressions
The display format setting affects different types of expressions in these ways:
Variables The display setting affects only the selected variable, not
other variables.
Array elements The display setting affects the complete array, that is, the
same display format is used for each array element.
Structure fields All elements with the same definition—the same field
name and C declaration type—are affected by the
display setting.
Show As
Displays a submenu that provides commands for changing the default type
interpretation of variables. The commands on this submenu are mainly useful
for assembler variables—data at assembler labels—because these are, by
default, displayed as integers. For more information, see Viewing assembler
variables, page 89.
Symbols window
The Symbols window is available from the View menu after you have enabled the
Symbols plugin module.
This window displays all symbols with a static location, that is, C/C++ functions,
assembler labels, and variables with static storage duration, including symbols from the
runtime library.
To enable the Symbols plugin module, choose Project>Options>Debugger>Select
plugins to load>Symbols.
Requirements
None; this window is always available.
AFE1_AFE2-1:1
Variables and expressions
Display area
This area contains these columns:
Symbol
The symbol name.
Location
The memory address.
Full name
The symbol name; often the same as the contents of the Symbol column but
differs for example for C++ member functions.
Click the column headers to sort the list by symbol name, location, or full name.
Context menu
This context menu is available:
103
AFE1_AFE2-1:1
Reference information on working with variables and expressions
Requirements
None; this window is always available.
Ambiguous symbol
Indicates which symbol that is ambiguous.
AFE1_AFE2-1:1
Breakpoints
● Introduction to setting and using breakpoints
● Setting breakpoints
105
AFE1_AFE2-1:1
Introduction to setting and using breakpoints
appear in the Breakpoints window. From this window you can conveniently view all
breakpoints, enable and disable breakpoints, and open a dialog box for defining new
breakpoints. The Breakpoint Usage window also lists all internally used breakpoints,
see Breakpoint consumers, page 110.
Breakpoints are set with a higher precision than single lines, using the same mechanism
as when stepping; for more information about precision, see Single stepping, page 64.
You can set breakpoints while you edit your code even if no debug session is active. The
breakpoints will then be validated when the debug session starts. Breakpoints are
preserved between debug sessions.
Note: For most hardware debugger systems it is only possible to set breakpoints when
the application is not executing.
BREAKPOINT TYPES
Depending on the C-SPY driver you are using, C-SPY supports different types of
breakpoints.
Code breakpoints
Code breakpoints are used for code locations to investigate whether your program logic
is correct or to get trace printouts. Code breakpoints are triggered when an instruction is
fetched from the specified location. If you have set the breakpoint on a specific machine
instruction, the breakpoint will be triggered and the execution will stop, before the
instruction is executed.
Log breakpoints
Log breakpoints provide a convenient way to add trace printouts without having to add
any code to your application source code. Log breakpoints are triggered when an
instruction is fetched from the specified location. If you have set the breakpoint on a
specific machine instruction, the breakpoint will be triggered and the execution will
temporarily stop and print the specified message in the C-SPY Debug Log window.
Data breakpoints
Data breakpoints are primarily useful for variables that have a fixed address in memory.
If you set a breakpoint on an accessible local variable, the breakpoint is set on the
corresponding memory location. The validity of this location is only guaranteed for
small parts of the code. Data breakpoints are triggered when data is accessed at the
AFE1_AFE2-1:1
Breakpoints
specified location. The execution will usually stop directly after the instruction that
accessed the data has been executed.
Immediate breakpoints
The C-SPY Simulator lets you set immediate breakpoints, which will halt instruction
execution only temporarily. This allows a C-SPY macro function to be called when the
simulated processor is about to read data from a location or immediately after it has
written data. Instruction execution will resume after the action.
This type of breakpoint is useful for simulating memory-mapped devices of various
kinds (for instance serial ports and timers). When the simulated processor reads from a
memory-mapped location, a C-SPY macro function can intervene and supply
appropriate data. Conversely, when the simulated processor writes to a memory-mapped
location, a C-SPY macro function can act on the value that was written.
Complex breakpoints
The C-SPY Atmel-ICE driver, the C-SPY Power Debugger driver, the C-SPY AVR
ONE! driver, and the C-SPY JTAGICE3 driver support complex breakpoints. Complex
breakpoints use the functionality of the firmware and are faster than data breakpoints
and code breakpoints. Using complex breakpoints, you can specify special conditions
for when the breakpoint should trigger.
107
AFE1_AFE2-1:1
Introduction to setting and using breakpoints
BREAKPOINT ICONS
A breakpoint is marked with an icon in the left margin of the editor window, and the icon
varies with the type of breakpoint:
If the breakpoint icon does not appear, make sure the option Show bookmarks is
selected, see Editor options in the IDE Project Management and Building Guide for
AVR.
Just point at the breakpoint icon with the mouse pointer to get detailed tooltip
information about all breakpoints set on the same location. The first row gives user
breakpoint information, the following rows describe the physical breakpoints used for
implementing the user breakpoint. The latter information can also be seen in the
Breakpoint Usage window.
Note: The breakpoint icons might look different for the C-SPY driver you are using.
AFE1_AFE2-1:1
Breakpoints
This table summarizes the characteristics of breakpoints for the different target systems:
C-SPY hardware debugger driver Code breakpoints Data breakpoints
JTAGICE
using hardware breakpoints8 41 21
using software breakpoints Unlimited 21
JTAGICE mkII
using hardware breakpoints3,8 41,2 21,4
using software breakpoints Unlimited 21,4
Atmel-ICE
using hardware breakpoints3,5,7, 8 41,2 26
using software breakpoints Unlimited 26
Power Debugger
using hardware breakpoints3,5,7, 8 41,2 26
using software breakpoints Unlimited 26
JTAGICE3
using hardware breakpoints3,5,7, 8 41,2 26
using software breakpoints Unlimited 26
AVR ONE!
using hardware breakpoints3,5,7, 8 41,2 26
using software breakpoints Unlimited 26
Table 6: Available breakpoints in C-SPY hardware debugger drivers
1
The sum of code and data breakpoints can never exceed 4—the number of available
hardware breakpoints. This means that for every data breakpoint in use, one less code
breakpoint is available, and that no data breakpoints are available if you use four code
breakpoints.
2 If software breakpoints are enabled, the number of code breakpoints is unlimited.
3
When the number of available hardware breakpoints is exceeded, software breakpoints
will be used if enabled.
4
Data breakpoints are not available when the debugWIRE interface is used.
5 If data breakpoints and complex breakpoints have not been used, hardware breakpoints
will be used until exhausted. After that, software breakpoints will be used.
6
If complex breakpoints are used, data breakpoints are not available, and vice versa.
7
Note that a complex breakpoint uses all available hardware breakpoints.
109
AFE1_AFE2-1:1
Introduction to setting and using breakpoints
8
The number of available hardware breakpoints depends on the target system you are
using.
For Atmel-ICE, Power Debugger, JTAGICE3, JTAGICE mkII, AVR ONE!, and Dragon,
the number and types of breakpoints available depend on whether the device is using the
JTAG or the debugWIRE interface. The information in this guide reflects the JTAG
interface. When a device with debugWIRE is used, data breakpoints are not available
and the debugger will use software code breakpoints.
If the driver and the device support software breakpoints and they are enabled, the
debugger will first use any available hardware breakpoints before using software
breakpoints. Exceeding the number of available hardware breakpoints, when software
breakpoints are not enabled, causes the debugger to single step. This will significantly
reduce the execution speed. For this reason you must be aware of the different
breakpoint consumers.
BREAKPOINT CONSUMERS
A debugger system includes several consumers of breakpoints.
User breakpoints
The breakpoints you define in the breakpoint dialog box or by toggling breakpoints in
the editor window often consume one physical breakpoint each, but this can vary greatly.
Some user breakpoints consume several physical breakpoints and conversely, several
user breakpoints can share one physical breakpoint. User breakpoints are displayed in
the same way both in the Breakpoint Usage window and in the Breakpoints window,
for example Data @[R] callCount.
C-SPY itself
C-SPY itself also consumes breakpoints. C-SPY will set a breakpoint if:
● The debugger option Run to has been selected, and any step command is used.
These are temporary breakpoints which are only set during a debug session. This
means that they are not visible in the Breakpoints window.
● The linker option With I/O emulation modules has been selected.
In the DLIB runtime environment, C-SPY will set a system breakpoint on the
__DebugBreak label.
In the CLIB runtime environment, C-SPY will set a breakpoint if:
● the library functions putchar and getchar are used (low-level routines used by
functions like printf and scanf)
● the application has an exit label.
AFE1_AFE2-1:1
Breakpoints
You can disable the setting of system breakpoints on the putchar and getchar
functions and on the exit label.
For more information about the option System breakpoints on:
● For AVRONE!, see AVR ONE! 2, page 350.
● For Atmel-ICE, see Atmel-ICE 2, page 345.
● For JTAGICE3, see JTAGICE3 2, page 353.
● For JTAGICE mkII, see JTAGICE mkII 2, page 357.
● For Dragon, see Dragon 2, page 361.
● For Power Debugger, see Power Debugger 2, page 364.
These types of breakpoint consumers are displayed in the Breakpoint Usage window,
for example, C-SPY Terminal I/O & libsupport module.
Setting breakpoints
These tasks are covered:
● Various ways to set a breakpoint
● Toggling a simple code breakpoint
● Setting breakpoints using the dialog box
● Setting a data breakpoint in the Memory window
● Setting breakpoints using system macros
● Useful breakpoint hints.
111
AFE1_AFE2-1:1
Setting breakpoints
AFE1_AFE2-1:1
Breakpoints
4 In the breakpoint dialog box that appears, specify the breakpoint settings and click OK.
The breakpoint is displayed in the Breakpoints window.
To modify an existing breakpoint:
1 In the Breakpoints window, editor window, or in the Disassembly window, select the
breakpoint you want to modify and right-click to open the context menu.
If there are several breakpoints on the same source code line, the breakpoints will be
listed on a submenu.
2 On the context menu, choose the appropriate command.
3 In the breakpoint dialog box that appears, specify the breakpoint settings and click OK.
The breakpoint is displayed in the Breakpoints window.
113
AFE1_AFE2-1:1
Setting breakpoints
write accesses. All breakpoints defined in this window are preserved between debug
sessions.
Note: Setting breakpoints directly in the Memory window is only possible if the driver
you use supports this.
For information about each breakpoint macro, see Reference information on C-SPY
system macros, page 265.
AFE1_AFE2-1:1
Breakpoints
115
AFE1_AFE2-1:1
Reference information on breakpoints
count()
{
my_counter += 1;
return 0;
}
To use this function as a condition for the breakpoint, type count() in the Expression
text box under Conditions. The task will then be performed when the breakpoint is
triggered. Because the macro function count returns 0, the condition is false and the
execution of the program will resume automatically, without any stop.
AFE1_AFE2-1:1
Breakpoints
See also:
● Reference information on C-SPY system macros, page 265
● Reference information on trace, page 164.
Breakpoints window
The Breakpoints window is available from the View menu.
Requirements
None; this window is always available.
Display area
This area lists all breakpoints you define. For each breakpoint, information about the
breakpoint type, source file, source line, and source column is provided.
117
AFE1_AFE2-1:1
Reference information on breakpoints
Context menu
This context menu is available:
AFE1_AFE2-1:1
Breakpoints
This window lists all breakpoints currently set in the target system, both the ones you
have defined and the ones used internally by C-SPY. The format of the items in this
window depends on the C-SPY driver you are using.
The window gives a low-level view of all breakpoints, related but not identical to the list
of breakpoints displayed in the Breakpoints window.
C-SPY uses breakpoints when stepping. Use the Breakpoint Usage window for:
● Identifying all breakpoint consumers
● Checking that the number of active breakpoints is supported by the target system
● Configuring the debugger to use the available breakpoints in a better way, if
possible.
For more information, see Breakpoints in the C-SPY hardware debugger drivers, page
108.
Requirements
None; this window is always available.
Display area
For each breakpoint in the list, the address and access type are displayed. Each
breakpoint in the list can also be expanded to show its originator.
119
AFE1_AFE2-1:1
Reference information on breakpoints
Requirements
None; this dialog box is always available.
Break At
Specify the code location of the breakpoint in the text box. Alternatively, click the Edit
button to open the Enter Location dialog box, see Enter Location dialog box, page 130.
Size
Determines whether there should be a size—in practice, a range—of locations where the
breakpoint will trigger. Each fetch access to the specified memory range will trigger the
breakpoint. Select how to specify the size:
Auto
The size will be set automatically, typically to 1.
Manual
Specify the size of the breakpoint range in the text box.
AFE1_AFE2-1:1
Breakpoints
Action
Specify a valid C-SPY expression, which is evaluated when the breakpoint is triggered
and the condition is true. For more information, see Useful breakpoint hints, page 115.
Conditions
Specify simple or complex conditions:
Expression
Specify a valid C-SPY expression, see C-SPY expressions, page 86.
Condition true
The breakpoint is triggered if the value of the expression is true.
Condition changed
The breakpoint is triggered if the value of the expression has changed since it
was last evaluated.
Skip count
The number of times that the breakpoint condition must be fulfilled before the
breakpoint starts triggering. After that, the breakpoint will trigger every time the
condition is fulfilled.
121
AFE1_AFE2-1:1
Reference information on breakpoints
Requirements
None; this dialog box is always available.
Trigger at
Specify the code location of the breakpoint. Alternatively, click the Edit button to open
the Enter Location dialog box, see Enter Location dialog box, page 130.
Message
Specify the message you want to be displayed in the C-SPY Debug Log window. The
message can either be plain text, or—if you also select the option C-SPY macro
"__message" style—a comma-separated list of arguments.
Conditions
Specify simple or complex conditions:
Expression
Specify a valid C-SPY expression, see C-SPY expressions, page 86.
Condition true
The breakpoint is triggered if the value of the expression is true.
Condition changed
The breakpoint is triggered if the value of the expression has changed since it
was last evaluated.
AFE1_AFE2-1:1
Breakpoints
Requirements
One of these alternatives:
● The C-SPY simulator
● The C-SPY Atmel-ICE driver
● The C-SPY Power Debugger driver
● The C-SPY JTAGICE3 driver
● The C-SPY AVR ONE! driver
● The C-SPY JTAGICE mkII driver, unless the debugWIRE interface is used
● The C-SPY Dragon driver.
Break At
Specify the data location of the breakpoint in the text box. Alternatively, click the Edit
button to open the Enter Location dialog box, see Enter Location dialog box, page 130.
123
AFE1_AFE2-1:1
Reference information on breakpoints
Access Type
Selects the type of memory access that triggers the breakpoint:
Read/Write
Reads from or writes to location.
Read
Reads from location.
Write
Writes to location.
Size
Determines whether there should be a size—in practice, a range—of locations where the
breakpoint will trigger. Each fetch access to the specified memory range will trigger the
breakpoint. Select how to specify the size:
Auto
The size will automatically be based on the type of expression the breakpoint is
set on. For example, if you set the breakpoint on a 12-byte structure, the size of
the breakpoint will be 12 bytes.
Manual
Specify the size of the breakpoint range in the text box.
For data breakpoints, this can be useful if you want the breakpoint to be triggered on
accesses to data structures, such as arrays, structs, and unions.
Action
Specify a valid C-SPY expression, which is evaluated when the breakpoint is triggered
and the condition is true. For more information, see Useful breakpoint hints, page 115.
Conditions
Specify simple or complex conditions:
Expression
Specify a valid C-SPY expression, see C-SPY expressions, page 86.
Condition true
The breakpoint is triggered if the value of the expression is true.
Condition changed
The breakpoint is triggered if the value of the expression has changed since it
was last evaluated.
AFE1_AFE2-1:1
Breakpoints
Skip count
The number of times that the breakpoint condition must be fulfilled before the
breakpoint starts triggering. After that, the breakpoint will trigger every time the
condition is fulfilled.
Requirements
The C-SPY simulator.
Trigger at
Specify the data location of the breakpoint. Alternatively, click the Edit button to open
the Enter Location dialog box, see Enter Location dialog box, page 130.
Access Type
Selects the type of memory access that triggers the breakpoint:
Read/Write
Reads from or writes to location.
Read
Reads from location.
125
AFE1_AFE2-1:1
Reference information on breakpoints
Write
Writes to location.
In the C-SPY simulator, use the Immediate breakpoints dialog box to set an immediate
breakpoint, see Setting breakpoints using the dialog box, page 112. Immediate
breakpoints do not stop execution at all; they only suspend it temporarily.
Requirements
The C-SPY simulator.
Trigger at
Specify the data location of the breakpoint. Alternatively, click the Edit button to open
the Enter Location dialog box, see Enter Location dialog box, page 130.
Access Type
Selects the type of memory access that triggers the breakpoint:
Read
Reads from location.
Write
Writes to location.
AFE1_AFE2-1:1
Breakpoints
Action
Specify a valid C-SPY expression, which is evaluated when the breakpoint is triggered
and the condition is true. For more information, see Useful breakpoint hints, page 115.
Use this dialog box to set a complex breakpoint. Alternatively, to modify an existing
breakpoint, select a breakpoint in the Breakpoint window and choose Edit on the
context menu.
Complex breakpoints use the functionality of the firmware and are faster than data
breakpoints and code breakpoints.
Note: A complex breakpoint uses all available hardware breakpoints.
Requirements
One of these alternatives:
127
AFE1_AFE2-1:1
Reference information on breakpoints
Breakpoint control
Controls what access type at the specified address that causes a break. Choose between:
Address A/B
Specify the code or data addresses where you want to set a breakpoint.
Access type
Selects the memory space, Code or Data, for the addresses in Address A and Address
B. Note that both addresses must have the same access type.
Complex data
Enable complex data enables the data compare functionality.
AFE1_AFE2-1:1
Breakpoints
Value C/D
Specify 1-byte numbers for the compare functionality.
C/D compare
Specify the relationship between Value C or Value D and the contents of data memory
at Address A and Address B.
Action
Specify an expression, for instance a C-SPY macro function, which is evaluated when
the breakpoint is triggered and the condition is true.
129
AFE1_AFE2-1:1
Reference information on breakpoints
Use the Enter Location dialog box to specify the location of the breakpoint.
Note: This dialog box looks different depending on the Type you select.
Type
Selects the type of location to be used for the breakpoint, choose between:
Expression
A C-SPY expression, whose value evaluates to a valid code or data location.
A code location, for example the function main, is typically used for code
breakpoints.
A data location is the name of a variable and is typically used for data
breakpoints. For example, my_var refers to the location of the variable my_var,
and arr[3] refers to the location of the fourth element of the array arr. For
static variables declared with the same name in several functions, use the syntax
my_func::my_static_variable to refer to a specific variable.
For more information about C-SPY expressions, see C-SPY expressions, page
86.
Absolute address
An absolute location on the form zone:hexaddress or simply hexaddress
(for example Memory:0x42). zone refers to C-SPY memory zones and
specifies in which memory the address belongs, see C-SPY memory zones, page
134.
Source location
A location in your C source code using the syntax:
{filename}.row.column.
AFE1_AFE2-1:1
Breakpoints
All
The breakpoint will be set on all listed locations.
Selected
The breakpoint will be set on the source locations that you have selected in the text box.
131
AFE1_AFE2-1:1
Reference information on breakpoints
Cancel
No location will be used.
AFE1_AFE2-1:1
Memory and registers
● Introduction to monitoring memory and registers
133
AFE1_AFE2-1:1
Introduction to monitoring memory and registers
0 0 0
Reg window
0x1F 0
Code
I/O I/O
EEPROM
nc 0x5F 0x3F
Data
ne
nd
Memory zones are used in several contexts, most importantly in the Memory and
Disassembly windows, and in C-SPY macros. In the windows, use the Zone box to
choose which memory zone to display.
AFE1_AFE2-1:1
Memory and registers
Device-specific zones
Memory information for device-specific zones is defined in the device description files.
When you load a device description file, additional zones that adhere to the specific
memory layout become available.
See the device description file for information about available memory zones.
If your hardware does not have the same memory layout as any of the predefined device
description files, you can define customized zones by adding them to the file.
For more information, see Selecting a device description file, page 51 and Modifying a
device description file, page 55.
135
AFE1_AFE2-1:1
Monitoring memory and registers
Right-clicking in the window displays a context menu with commands. For information
about these commands, see Register User Groups Setup window, page 156.
2 Click on <click to add group> and specify the name of your group, for example
My Timer Group and press Enter.
3 Underneath the group name, click on <click to add reg> and type the name of a
register, and press Enter. You can also drag a register name from another window in the
IDE. Repeat this for all registers that you want to add to your group.
4 As an optional step, right-click any registers for which you want to change the integer
base, and choose Format from the context menu to select a suitable base.
5 When you are done, your new group is now available in the Registers windows.
If you want to define more application-specific groups, repeat this procedure for each
group you want to define.
AFE1_AFE2-1:1
Memory and registers
2 Start C-SPY.
When your application is first loaded, and upon each reset, the memory for the stack area
is filled with the dedicated byte value 0xCD before the application starts executing.
3 Choose View>Stack>Stack 1 to open the Stack window.
Notice that you can open up to two Stack windows, each showing a different stack—if
several stacks are available—or the same stack with different display settings.
4 Start executing your application.
137
AFE1_AFE2-1:1
Monitoring memory and registers
Whenever execution stops, the stack memory is searched from the end of the stack until
a byte whose value is not 0xCD is found, which is assumed to be how far the stack has
been used. The light gray area of the stack bar represents the unused stack memory area,
whereas the dark gray area of the bar represents the used stack memory.
For this example, you can see that only 44% of the reserved memory address range was
used, which means that it could be worth considering decreasing the size of memory:
Note: Although this is a reasonably reliable way to track stack usage, there is no
guarantee that a stack overflow is detected. For example, a stack can incorrectly grow
outside its bounds, and even modify memory outside the stack area, without actually
modifying any of the bytes near the end of the stack range. Likewise, your application
might modify memory within the stack area by mistake.
To monitor the stack memory content:
1 Before you start monitoring stack memory, you might want to disable the option
Enable graphical stack display and stack usage tracking to improve performance
during debugging.
2 Start C-SPY.
3 Choose View>Stack>Stack 1 to open the Stack window.
Notice that you can access various context menus in the display area from where you
can change display format, etc.
4 Start executing your application.
AFE1_AFE2-1:1
Memory and registers
Whenever execution stops, you can monitor the stack memory, for example to see
function parameters that are passed on the stack:
139
AFE1_AFE2-1:1
Reference information on memory and registers
Memory window
The Memory window is available from the View menu.
Requirements
None; this window is always available.
Toolbar
The toolbar contains:
Go to
The memory location or symbol you want to view.
Zone
Selects a memory zone, see C-SPY memory zones, page 134.
Context menu button
Displays the context menu.
AFE1_AFE2-1:1
Memory and registers
Display area
The display area shows the addresses currently being viewed, the memory contents in
the format you have chosen, and—provided that the display mode is set to 1x Units—
the memory contents in ASCII format. You can edit the contents of the display area, both
in the hexadecimal part and the ASCII part of the area.
Data coverage is displayed with these colors:
Note: Data coverage is not supported by all C-SPY drivers. Data coverage is supported
by the C-SPY Simulator.
Context menu
This context menu is available:
141
AFE1_AFE2-1:1
Reference information on memory and registers
Zone
Selects a memory zone, see C-SPY memory zones, page 134.
1x Units
Displays the memory contents as single bytes.
2x Units
Displays the memory contents as 2-byte groups.
4x Units
Displays the memory contents as 4-byte groups.
8x Units
Displays the memory contents as 8-byte groups.
Little Endian
Displays the contents in little-endian byte order.
Big Endian
Displays the contents in big-endian byte order.
Data Coverage
Choose between:
Enable toggles data coverage on or off.
Show toggles between showing or hiding data coverage.
Clear clears all data coverage information.
These commands are only available if your C-SPY driver supports data
coverage.
Find
Displays a dialog box where you can search for text within the Memory
window; read about the Find dialog box in the IDE Project Management and
Building Guide for AVR.
Replace
Displays a dialog box where you can search for a specified string and replace
each occurrence with another string; read about the Replace dialog box in the
IDE Project Management and Building Guide for AVR.
Memory Fill
Displays a dialog box, where you can fill a specified area with a value, see Fill
dialog box, page 145.
AFE1_AFE2-1:1
Memory and registers
Memory Save
Displays a dialog box, where you can save the contents of a specified memory
area to a file, see Memory Save dialog box, page 143.
Memory Restore
Displays a dialog box, where you can load the contents of a file in Intel-hex or
Motorola s-record format to a specified memory zone, see Memory Restore
dialog box, page 144.
Set Data Breakpoint
Sets breakpoints directly in the Memory window. The breakpoint is not
highlighted; you can see, edit, and remove it in the Breakpoints dialog box. The
breakpoints you set in this window will be triggered for both read and write
access. For more information, see Setting a data breakpoint in the Memory
window, page 113.
Set Data Log Breakpoint
Sets a breakpoint on the start address of a memory selection directly in the
Memory window. The breakpoint is not highlighted; you can see, edit, and
remove it in the Breakpoints dialog box. The breakpoints you set in this
window will be triggered by both read and write accesses; to change this, use the
Breakpoints window. For more information, see Data Log breakpoints, page
107 and Getting started using data logging, page 179.
Use this dialog box to save the contents of a specified memory area to a file.
Requirements
None; this dialog box is always available.
143
AFE1_AFE2-1:1
Reference information on memory and registers
Zone
Selects a memory zone, see C-SPY memory zones, page 134.
Start address
Specify the start address of the memory range to be saved.
End address
Specify the end address of the memory range to be saved.
File format
Selects the file format to be used, which is Intel-extended by default.
Filename
Specify the destination file to be used; a browse button is available for your convenience.
Save
Saves the selected range of the memory zone to the specified file.
Use this dialog box to load the contents of a file in Intel-extended or Motorola S-record
format to a specified memory zone.
Requirements
None; this dialog box is always available.
Zone
Selects a memory zone, see C-SPY memory zones, page 134.
AFE1_AFE2-1:1
Memory and registers
Filename
Specify the file to be read; a browse button is available for your convenience.
Restore
Loads the contents of the specified file to the selected memory zone.
Use this dialog box to fill a specified area of memory with a value.
Requirements
None; this dialog box is always available.
Start address
Type the start address—in binary, octal, decimal, or hexadecimal notation.
Length
Type the length—in binary, octal, decimal, or hexadecimal notation.
Zone
Selects a memory zone, see C-SPY memory zones, page 134.
Value
Type the 8-bit value to be used for filling each memory location.
Operation
These are the available memory fill operations:
Copy
Value will be copied to the specified memory area.
145
AFE1_AFE2-1:1
Reference information on memory and registers
AND
An AND operation will be performed between Value and the existing contents of
memory before writing the result to memory.
XOR
An XOR operation will be performed between Value and the existing contents of
memory before writing the result to memory.
OR
An OR operation will be performed between Value and the existing contents of
memory before writing the result to memory.
This window displays how variables with static storage duration, typically variables
with file scope but also static variables in functions and classes, are laid out in memory.
This can be useful for better understanding memory usage or for investigating problems
caused by variables being overwritten, for example buffer overruns. Other areas of use
are spotting alignment holes or for understanding problems caused by buffers being
overwritten.
To view the memory corresponding to a variable, you can select it in the editor window
and drag it to the Symbolic Memory window.
See also Editing in C-SPY windows, page 54.
Requirements
None; this window is always available.
AFE1_AFE2-1:1
Memory and registers
Toolbar
The toolbar contains:
Go to
The memory location or symbol you want to view.
Zone
Selects a memory zone, see C-SPY memory zones, page 134.
Previous
Highlights the previous symbol in the display area.
Next
Highlights the next symbol in the display area.
Display area
This area contains these columns:
Location
The memory address.
Data
The memory contents in hexadecimal format. The data is grouped according to
the size of the symbol. This column is editable.
Variable
The variable name; requires that the variable has a fixed memory location. Local
variables are not displayed.
Value
The value of the variable. This column is editable.
Type
The type of the variable.
There are several different ways to navigate within the memory space:
● Text that is dropped in the window is interpreted as symbols
● The scroll bar at the right-side of the window
● The toolbar buttons Next and Previous
● The toolbar list box Go to can be used for locating specific locations or symbols.
Note: Rows are marked in red when the corresponding value has changed.
147
AFE1_AFE2-1:1
Reference information on memory and registers
Context menu
This context menu is available:
AFE1_AFE2-1:1
Memory and registers
Binary format
Displays the memory contents in binary format.
Octal format
Displays the memory contents in octal format.
Decimal format
Displays the memory contents in decimal format.
Hexadecimal format
Displays the memory contents in hexadecimal format.
Char format
Displays the memory contents in char format.
Stack window
The Stack window is available from the View menu.
This window is a memory window that displays the contents of the stack. The graphical
stack bar shows stack usage.
Note: By default, this window uses one physical breakpoint. For more information, see
Breakpoint consumers, page 110.
For information about options specific to the Stack window, see the IDE Project
Management and Building Guide for AVR.
Requirements
None; this window is always available.
149
AFE1_AFE2-1:1
Reference information on memory and registers
Toolbar
The toolbar contains:
Stack
Selects which stack to view. This applies to microcontrollers with multiple
stacks.
Display area
This area contains these columns:
Location
Displays the location in memory. The addresses are displayed in increasing
order. The address referenced by the stack pointer, in other words the top of the
stack, is highlighted in a green color.
Data
Displays the contents of the memory unit at the given location. From the Stack
window context menu, you can select how the data should be displayed; as a 1-,
2-, or 4-byte group of data.
Variable
Displays the name of a variable, if there is a local variable at the given location.
Variables are only displayed if they are declared locally in a function, and
located on the stack and not in registers.
Value
Displays the value of the variable.
Type
Displays the data type of the variable.
AFE1_AFE2-1:1
Memory and registers
Frame
Displays the name of the function that the call frame corresponds to.
Context menu
This context menu is available:
151
AFE1_AFE2-1:1
Reference information on memory and registers
Default Format,
Binary Format,
Octal Format,
Decimal Format,
Hexadecimal Format,
Char Format
Changes the display format of expressions. The display format setting affects
different types of expressions in different ways. Your selection of display format
is saved between debug sessions. These commands are available if a selected
line in the window contains a variable.
The display format setting affects different types of expressions in these ways:
Variables The display setting affects only the selected variable, not
other variables.
Array elements The display setting affects the complete array, that is, the
same display format is used for each array element.
Structure fields All elements with the same definition—the same field
name and C declaration type—are affected by the
display setting.
Options
Opens the IDE Options dialog box where you can set options specific to the
Stack window, see the IDE Project Management and Building Guide for AVR.
AFE1_AFE2-1:1
Memory and registers
Registers window
The Registers windows are available from the View menu.
These windows give an up-to-date display of the contents of the processor registers and
special function registers, and allows you to edit the content of some of the registers.
Optionally, you can choose to load either predefined register groups or your own
user-defined groups.
You can open up to four instances of this window, which is very convenient if you want
to keep track of different register groups.
See also Editing in C-SPY windows, page 54.
To enable predefined register groups:
1 Select a device description file that suits your device, see Selecting a device description
file, page 51.
2 Display the register groups that are defined in the device description file in the
Registers window by right-clicking in the window and choosing View Group from the
context menu.
For information about creating your own user-defined register groups, see Defining
application-specific register groups, page 136.
Requirements
None; this window is always available.
153
AFE1_AFE2-1:1
Reference information on memory and registers
Toolbar
The toolbar contains:
<find register>
Specify the name of a register that you want to find. Press the Enter key and the
first register group where this register is found is displayed. User-defined
register groups are not searched. The register search box has a history depth of
20 search entries.
Display area
Displays registers and their values. Some registers are expandable, which means that the
register contains interesting bits or subgroups of bits.
If you drag a numerical value, a valid expression, or a register name from another part
of the IDE to an editable value cell in a Registers window, the value will be changed to
that of what you dragged. If you drop a register name somewhere else in the window,
the window contents will change to display the first register group where this register is
found.
Register group name
The name of the register.
Value
The current value of the register. Every time C-SPY stops, a value that has
changed since the last stop is highlighted. Some of the registers are editable. To
edit the contents of an editable register, click it and modify its value. Press Esc
to cancel the change.
To change the display format of the value, right-click on the register and choose
Format from the context menu.
Access
The access type of the register. Some of the registers are read-only, some of the
registers are write-only.
AFE1_AFE2-1:1
Memory and registers
For the C-SPY Simulator, these additional support registers are available in the CPU
Registers group:
Context menu
This context menu is available:
155
AFE1_AFE2-1:1
Reference information on memory and registers
Use this window to define your own application-specific register groups. These register
groups can then be viewed in the Registers windows.
Defining application-specific register groups means that the Registers windows can
display just those registers that you need to watch for your current debugging task. This
makes debugging much easier.
Requirements
None; this window is always available.
Display area
This area contains these columns:
Group
The names of register groups and the registers they contain. Clicking on <click
to add group> or <click to add reg> and typing the name of a register
group or register, adds new groups and registers, respectively. You can also drag
a register name from another window in the IDE. Click a name to change it.
A dimmed register name indicates that it is not supported by the selected device.
AFE1_AFE2-1:1
Memory and registers
Format
Shows the display format for the register’s value. To change the display format
of the value, right-click on the register and choose Format from the context
menu. The selected format is used in all Registers windows.
Context menu
This context menu is available:
157
AFE1_AFE2-1:1
Reference information on memory and registers
AFE1_AFE2-1:1
Part 2. Analyzing your
application
This part of the C-SPY® Debugging Guide for AVR includes these chapters:
● Trace
● Profiling
● Code coverage
● Power debugging
159
160
Trace
● Introduction to using trace
161
AFE1_AFE2-1:1
Collecting and using trace data
AFE1_AFE2-1:1
Trace
For more information about these breakpoints, see Trace Start breakpoints dialog box,
page 168 and Trace Stop breakpoints dialog box, page 169, respectively.
163
AFE1_AFE2-1:1
Reference information on trace
Trace window
The Trace window is available from the C-SPY driver menu.
This window displays the collected trace data.
See also Collecting and using trace data, page 162.
Requirements
The C-SPY simulator.
Trace toolbar
The toolbar in the Trace window and in the Function Trace window contains:
Enable/Disable
Enables and disables collecting and viewing trace data in this window. This
button is not available in the Function Trace window.
Clear trace data
Clears the trace buffer. Both the Trace window and the Function Trace window
are cleared.
Toggle source
Toggles the Trace column between showing only disassembly or disassembly
together with the corresponding source code.
Browse
Toggles browse mode on or off for a selected item in the Trace window.
AFE1_AFE2-1:1
Trace
Find
Displays a dialog box where you can perform a search, see Find in Trace dialog
box, page 172.
Save
Displays a standard Save As dialog box where you can save the collected trace
data to a text file, with tab-separated columns.
Edit Settings
In the C-SPY simulator, this button is not enabled.
Edit Expressions (C-SPY simulator only)
Opens the Trace Expressions window, see Trace Expressions window, page
170.
Progress bar
When a large amount of trace data has been collected, there might be a delay
before all of it has been processed and can be displayed. The progress bar
reflects that processing.
Display area
This area displays a collected sequence of executed machine instructions. In addition,
the window can display trace data for expressions.
165
AFE1_AFE2-1:1
Reference information on trace
Trace
The collected sequence of executed machine instructions. Optionally, the
corresponding source code can also be displayed.
Expression
Each expression you have defined to be displayed appears in a separate column.
Each entry in the expression column displays the value after executing the
instruction on the same row. You specify the expressions for which you want to
collect trace data in the Trace Expressions window, see Trace Expressions
window, page 170.
A red-colored row indicates that the previous row and the red row are not consecutive.
This means that there is a gap in the collected trace data, for example because trace data
has been lost due to an overflow.
Context menu
This context menu is available:
Note: The contents of this menu are dynamic and depend on which features that your
combination of software and hardware supports. However, the list of menu commands
below is complete and covers all possible commands.
These commands are available:
Enable
Enables and disables collecting and viewing trace data in this window.
Clear
Clears the trace buffer. Both the Trace window and the Function Trace window
are cleared.
Embed source
Toggles the Trace column between showing only disassembly or disassembly
together with the corresponding source code.
Browse
Toggles browse mode on or off for a selected item in the Trace window.
AFE1_AFE2-1:1
Trace
Find All
Displays a dialog box where you can perform a search in the Trace window, see
Find in Trace dialog box, page 172. The search results are displayed in the Find
in Trace window—available by choosing the View>Messages command, see
Find in Trace window, page 173.
Save
Displays a standard Save As dialog box where you can save the collected trace
data to a text file, with tab-separated columns.
Open Trace Expressions Window
Opens the Trace Expressions window, see Trace Expressions window, page
170.
This window displays a subset of the trace data displayed in the Trace window. Instead
of displaying all rows, the Function Trace window shows:
● The functions called or returned to, instead of the traced instruction
● The corresponding trace data.
Requirements
The C-SPY simulator.
Toolbar
For information about the toolbar, see Trace window, page 164.
167
AFE1_AFE2-1:1
Reference information on trace
Display area
There are two sets of columns available, and which set is used in your debugging system
depends on the debug probe and which trace sources that are available:
Cycles
The number of cycles elapsed to this point according to the timestamp in the
debug probe.
Address
The address of the executed instruction.
Call/Return
The function that was called or returned to.
Use this dialog box to set a Trace Start breakpoint where you want to start collecting
trace data. If you want to collect trace data only for a specific range, you must also set a
Trace Stop breakpoint where you want to stop collecting data.
See also Trace Stop breakpoints dialog box, page 169 and Trace data collection using
breakpoints, page 162.
To set a Trace Start breakpoint:
1 In the editor or Disassembly window, right-click and choose Trace Start from the
context menu.
Alternatively, open the Breakpoints window by choosing View>Breakpoints.
2 In the Breakpoints window, right-click and choose New Breakpoint>Trace Start.
AFE1_AFE2-1:1
Trace
Requirements
The C-SPY simulator.
Trigger at
Specify the code location of the breakpoint. Alternatively, click the Edit button to open
the Enter Location dialog box, see Enter Location dialog box, page 130.
Use this dialog box to set a Trace Stop breakpoint where you want to stop collecting
trace data. If you want to collect trace data only for a specific range, you might also need
to set a Trace Start breakpoint where you want to start collecting data.
See also Trace Start breakpoints dialog box, page 168 and Trace data collection using
breakpoints, page 162.
To set a Trace Stop breakpoint:
1 In the editor or Disassembly window, right-click and choose Trace Stop from the
context menu.
Alternatively, open the Breakpoints window by choosing View>Breakpoints.
169
AFE1_AFE2-1:1
Reference information on trace
Requirements
The C-SPY simulator.
Trigger at
Specify the code location of the breakpoint. Alternatively, click the Edit button to open
the Enter Location dialog box, see Enter Location dialog box, page 130.
Use this window to specify, for example, a specific variable (or an expression) for which
you want to collect trace data.
Requirements
The C-SPY simulator.
Display area
Use the display area to specify expressions for which you want to collect trace data:
Expression
Specify any expression that you want to collect data from. You can specify any
expression that can be evaluated, such as variables and registers.
AFE1_AFE2-1:1
Trace
Format
Shows which display format that is used for each expression. Note that you can
change display format via the context menu.
Each row in this area will appear as an extra column in the Trace window.
Context menu
This context menu is available:
Variables The display setting affects only the selected variable, not
other variables.
171
AFE1_AFE2-1:1
Reference information on trace
Array elements The display setting affects the complete array, that is, the
same display format is used for each array element.
Structure fields All elements with the same definition—the same field
name and C declaration type—are affected by the
display setting.
Use this dialog box to specify the search criteria for advanced searches in the trace data.
The search results are displayed in the Find in Trace window—available by choosing
the View>Messages command, see Find in Trace window, page 173.
See also Searching in trace data, page 163.
Requirements
The C-SPY simulator.
Text search
Specify the string you want to search for. To specify the search criteria, choose between:
Match Case
Searches only for occurrences that exactly match the case of the specified text.
Otherwise int will also find INT, Int, and so on.
AFE1_AFE2-1:1
Trace
Address Range
Specify the address range you want to display or search. The trace data within the
address range is displayed. If you also have specified a text string in the Text search
field, the text string is searched for within the address range.
This window displays the result of searches in the trace data. Double-click an item in the
Find in Trace window to bring up the same item in the Trace window.
Before you can view any trace data, you must specify the search criteria in the Find in
Trace dialog box, see Find in Trace dialog box, page 172.
See also Searching in trace data, page 163.
Requirements
The C-SPY simulator.
Display area
The Find in Trace window looks like the Trace window and shows the same columns
and data, but only those rows that match the specified search criteria.
173
AFE1_AFE2-1:1
Reference information on trace
AFE1_AFE2-1:1
The application timeline
● Introduction to analyzing your application’s timeline
Call stack Can be represented in the Timeline window, as a graph that displays the
sequence of function calls and returns collected by the trace system. You
get timing information between the function invocations.
Note that there is also a related Call Stack window and a Function
Trace window, see Call Stack window, page 75 and Function Trace
window, page 167, respectively.
175
AFE1_AFE2-1:1
Introduction to analyzing your application’s timeline
Data logging Based on data logs collected by the trace system for up to four different
variables or address ranges, specified by means of Data Log
breakpoints. Choose to display the data logs:
● In the Timeline window, as a graph of how the values change over
time.
● In the Data Log window and the Data Log Summary window.
Power Based on logged power measurement samples generated by the debug
logging probe or associated hardware. Choose to display the power logs:
● In the Timeline window, as a graph of the power measurement
samples.
● In the Power Log window.
Power logs can be useful for finding peaks in the power consumption
and by double-clicking on a value you can see the corresponding source
code. The precision depends on the frequency of the samples, but there
is a good chance that you find the source code sequence that caused the
peak.
For more information, see the chapter Power debugging, page 211.
State logging Based on logged activity—state changes—for the GPIO input pins
generated by the debug probe or associated hardware. Choose to display
the state logs:
● In the Timeline window, as a graph of the state changes.
● In the State Log window and in the State Log Summary window.
The information is useful for tracing the activity on the target system.
For more information, see the chapter Power debugging, page 211.
AFE1_AFE2-1:1
The application timeline
For more information about requirements related to trace data, see Requirements for
using trace, page 162.
177
AFE1_AFE2-1:1
Analyzing your application’s timeline
4 In the Timeline window, right-click in the graph area and choose Enable from the
context menu to enable a specific graph.
5 For the Data Log graph, you must set a Data Log breakpoint for each variable you want
a graphical representation of in the Timeline window. See Data Log breakpoints
dialog box, page 125.
6 Click Go on the toolbar to start executing your application. The graphs that you have
enabled appear.
AFE1_AFE2-1:1
The application timeline
Note that if you have enabled several graphs, you can move the mouse pointer over the
different graphs to get graph-specific information.
4 Click in the graph and drag to select a time interval. Point in the graph with the mouse
pointer to get timing information for the selection.
179
AFE1_AFE2-1:1
Reference information on application timeline
● In the Memory window, select a memory area, right-click and choose Set Data Log
Breakpoint from the context menu. A breakpoint is set on the start address of the
selection.
● In the editor window, select a variable, right-click and choose Set Data Log
Breakpoint from the context menu. The breakpoint will be set on the part of the
variable that the microcontroller can access using one instruction.
You can set up to four data log breakpoints. For more information about data log
breakpoints, see Data Log breakpoints, page 107.
2 Choose C-SPY driver>Data Log to open the Data Log window. Optionally, you can
also choose:
● C-SPY driver>Data Log Summary to open the Data Log Summary window
● C-SPY driver>Timeline to open the Timeline window to view the Data Log graph.
3 From the context menu, available in the Data Log window, choose Enable to enable
the logging.
4 Start executing your application program to collect the log information.
5 To view the data log information, look in the Data Log window, the Data Log
Summary window, or the Data graph in the Timeline window.
6 If you want to save the log or summary to a file, choose Save to log file from the
context menu in the window in question.
7 To disable data logging, choose Disable from the context menu in each window where
you have enabled it.
AFE1_AFE2-1:1
The application timeline
This window displays trace data represented as different graphs, in relation to a shared
time axis.
The Call Stack graph displays the sequence of function calls and returns collected by the
trace system.
Note: There is a limit on the number of saved logs. When this limit is exceeded, the
oldest entries in the buffer are erased.
Requirements
The C-SPY simulator.
181
AFE1_AFE2-1:1
Reference information on application timeline
● Light green for functions known to the debugger only through an assembler label
● Medium yellow for normal interrupt handlers, with debug information
● Light yellow for interrupt handlers known to the debugger only through an
assembler label
The timing information represents the number of cycles spent in, or between, the
function invocations.
At the bottom of the window, there is a shared time axis that uses seconds or cycles as
the time unit.
Click in the graph to display the corresponding source code.
Context menu
This context menu is available:
Note: The contents of this menu are dynamic and depend on which features that your
combination of software and hardware supports. However, the list of menu commands
below is complete and covers all possible commands.
These commands are available:
Navigate
Commands for navigating the graph(s). Choose between:
Next moves the selection to the next relevant point in the graph. Shortcut key:
right arrow.
Previous moves the selection backward to the previous relevant point in the
graph. Shortcut key: left arrow.
First moves the selection to the first data entry in the graph. Shortcut key:
Home.
Last moves the selection to the last data entry in the graph. Shortcut key: End.
AFE1_AFE2-1:1
The application timeline
End moves the selection to the last data in any displayed graph, in other words
the end of the time axis. Shortcut key: Ctrl+End.
Auto Scroll
Toggles automatic scrolling on or off. When on, the most recently collected data
is automatically displayed when you choose Navigate>End.
Zoom
Commands for zooming the window, in other words, changing the time scale.
Choose between:
Zoom to Selection makes the current selection fit the window. Shortcut key:
Return.
Zoom In zooms in on the time scale. Shortcut key: +
Zoom Out zooms out on the time scale. Shortcut key: –
10ns, 100ns, 1us, etc makes an interval of 10 nanoseconds, 100 nanoseconds, 1
microsecond, respectively, fit the window.
1ms, 10ms, etc makes an interval of 1 millisecond or 10 milliseconds,
respectively, fit the window.
10m, 1h, etc makes an interval of 10 minutes or 1 hour, respectively, fit the
window.
Call Stack
A heading that shows that the Call stack-specific commands below are available.
Enable
Toggles the display of the graph on or off. If you disable a graph, that graph will
be indicated as OFF in the window. If no data has been collected for a graph, no
data will appear instead of the graph.
Show Timing
Toggles the display of the timing information on or off.
Go To Source
Displays the corresponding source code in an editor window, if applicable.
Save to File
Saves all contents (or the selected contents) of the Call Stack graph to a file. The
menu command is only available when C-SPY is not running.
Select Graphs
Selects which graphs to be displayed in the Timeline window.
183
AFE1_AFE2-1:1
Reference information on application timeline
This window displays trace data represented as different graphs, in relation to a shared
time axis.
The Data Log graph displays the data logs collected by the trace system, for up to four
different variables or address ranges specified as Data Log breakpoints.
Note: There is a limit on the number of saved logs. When this limit is exceeded, the
oldest entries in the buffer are erased.
Requirements
The C-SPY simulator.
AFE1_AFE2-1:1
The application timeline
Context menu
This context menu is available:
Note: The contents of this menu are dynamic and depend on which features that your
combination of software and hardware supports. However, the list of menu commands
below is complete and covers all possible commands.
185
AFE1_AFE2-1:1
Reference information on application timeline
AFE1_AFE2-1:1
The application timeline
Clear
Deletes the log information. Note that this will happen also when you reset the
debugger.
Variable
The name of the variable for which the Data Log-specific commands below
apply. This menu command is context-sensitive, which means it reflects the
Data Log graph you selected in the Timeline window (one of up to four).
Viewing Range
Displays a dialog box, see Viewing Range dialog box, page 194.
Size
Determines the vertical size of the graph; choose between Small, Medium, and
Large.
Solid Graph
Displays the graph as a color-filled solid graph instead of as a thin line.
Show Numerical Value
Shows the numerical value of the variable, in addition to the graph.
Hexadecimal
Toggles between displaying the selected value in decimal or hexadecimal
format. Note that this setting also affects the log window.
Go To Source
Displays the corresponding source code in an editor window, if applicable.
Select Graphs
Selects which graphs to be displayed in the Timeline window.
Time Axis Unit
Selects the unit used in the time axis; choose between Seconds and Cycles.
If Cycles is not available, the graphs are based on different clock sources. In that
case you can view cycle values as tooltip information by pointing at the graph
with your mouse pointer.
187
AFE1_AFE2-1:1
Reference information on application timeline
Use this window to log accesses to up to four different memory locations or areas.
Note: There is a limit on the number of saved logs. When this limit is exceeded, the
oldest entries in the buffer are erased.
See also Getting started using data logging, page 179.
Requirements
The C-SPY simulator.
Display area
Each row in the display area shows the time, the program counter, and, for every tracked
data object, its value and address. All information is cleared on reset. The information
is displayed in these columns:
Time
If the time is displayed in italics, the target system has not been able to collect a
correct time, but instead had to approximate it.
This column is available when you have selected Show time from the context
menu.
Cycles
The number of cycles from the start of the execution until the event.
AFE1_AFE2-1:1
The application timeline
If a cycle is displayed in italics, the target system has not been able to collect a
correct time, but instead had to approximate it.
This column is available when you have selected Show cycles from the context
menu.
Program Counter*
Displays one of these:
An address, which is the content of the PC, that is, the address of the instruction
that performed the memory access.
---, the target system failed to provide the debugger with any information.
Overflow in red, the communication channel failed to transmit all data from the
target system.
Value
Displays the access type and the value (using the access size) for the location or
area you want to log accesses to. For example, if zero is read using a byte access
it will be displayed as 0x00, and for a long access it will be displayed as
0x00000000.
To specify what data you want to log accesses to, use the Data Log breakpoint
dialog box. See Data Log breakpoints, page 107.
Address
The actual memory address that is accessed. For example, if only a byte of a
word is accessed, only the address of the byte is displayed. The address is
calculated as base address + offset, where the base address is retrieved from the
Data Log breakpoint dialog box and the offset is retrieved from the logs. If the
log from the target system does not provide the debugger with an offset, the
offset contains + ?.
* You can double-click a line in the display area. If the value of the PC for that line is
available in the source code, the editor window displays the corresponding source code
(this does not include library source code).
189
AFE1_AFE2-1:1
Reference information on application timeline
Context menu
This context menu is available:
AFE1_AFE2-1:1
The application timeline
This window displays a summary of data accesses to specific memory location or areas.
See also Getting started using data logging, page 179.
Requirements
The C-SPY simulator.
Display area
Each row in this area displays the type and the number of accesses to each memory
location or area in these columns. Summary information is listed at the bottom of the
display area.
Data
The name of the data object you have selected to log accesses to. To specify
what data object you want to log accesses to, use the Data Log breakpoint
dialog box. See Data Log breakpoints, page 107.
Total Accesses
The total number of accesses.
If the sum of read accesses and write accesses is less than the total accesses, the
target system for some reason did not provide valid access type information for
all accesses.
Read Accesses
The total number of read accesses.
Write Accesses
The total number of write accesses.
191
AFE1_AFE2-1:1
Reference information on application timeline
Unknown Accesses
The number of unknown accesses, in other words, accesses where the access
type is not known.
Approximative time count
The information displayed depends on the C-SPY driver you are using.
For some C-SPY drivers, this information is not displayed or the value is always
zero. In this case, all logs have an exact time stamp.
For other C-SPY drivers, a non-zero value is displayed. The value represents the
amount of logs with an approximative time stamp. This might happen if the
bandwidth in the communication channel is too low compared to the amount of
data packets generated by the CPU or if the CPU generated packets with an
approximative time stamp.
Overflow count
The information displayed depends on the C-SPY driver you are using.
For some C-SPY drivers, this information is not displayed or the value is always
zero.
For other C-SPY drivers, the number represents the amount of overflows in the
communication channel which can cause logs to be lost. If this happens, it
indicates that logs might be incomplete. To solve this, make sure not to use all
C-SPY log features simultaneously or check used bandwidth for the
communication channel.
Current time|cycles
The information displayed depends on the C-SPY driver you are using.
For some C-SPY drivers, the value is always zero or not visible at all.
For other C-SPY drivers, the number represents the current time or cycles—the
number of cycles or the execution time since the start of execution.
AFE1_AFE2-1:1
The application timeline
Context menu
This context menu is available:
193
AFE1_AFE2-1:1
Reference information on application timeline
Use this dialog box to specify the value range, that is, the range for the Y-axis for the
graph.
Scale
Selects the scale type of the Y-axis:
● Linear
AFE1_AFE2-1:1
The application timeline
● Logarithmic.
195
AFE1_AFE2-1:1
Reference information on application timeline
AFE1_AFE2-1:1
Profiling
● Introduction to the profiler
197
AFE1_AFE2-1:1
Using the profiler
Instruction profiling information is displayed in the Disassembly window, that is, the
number of times each instruction has been executed.
Profiling sources
The profiler can use different mechanisms, or sources, to collect profiling information.
Depending on the available trace source features, one or more of the sources can be used
for profiling:
● Trace (calls)
The full instruction trace is analyzed to determine all function calls and returns.
When the collected instruction sequence is incomplete or discontinuous, the
profiling information is less accurate.
● Trace (flat)
Each instruction in the full instruction trace or each PC Sample is assigned to a
corresponding function or code fragment, without regard to function calls or returns.
This is most useful when the application does not exhibit normal call/return
sequences, such as when you are using an RTOS, or when you are profiling code
which does not have full debug information.
Power sampling
Some debug probes support sampling of the power consumption of the development
board, or components on the board. Each sample is associated with a PC sample and
represents the power consumption (actually, the electrical current) for a small time
interval preceding the time of the sample. When the profiler is set to use Power
Sampling, additional columns are displayed in the Profiler window. Each power sample
is associated with a function or code fragment, just as with regular PC Sampling. Note
that this does not imply that all the energy corresponding to a sample can be attributed
to that function or code fragment. The time scales of power samples and instruction
execution are vastly different; during one power measurement, the CPU has typically
executed many thousands of instructions. Power Sampling is a statistics tool.
AFE1_AFE2-1:1
Profiling
Category Setting
C/C++ Compiler Output>Generate debug information
Linker Output>Format>Debug information for C-SPY
Table 9: Project options for enabling the profiler
2 When you have built your application and started C-SPY, choose C-SPY
driver>Function Profiler to open the Function Profiler window, and click the
Enable button to turn on the profiler. Alternatively, choose Enable from the context
menu that is available when you right-click in the Function Profiler window.
3 Start executing your application to collect the profiling information.
4 Profiling information is displayed in the Function Profiler window. To sort, click on
the relevant column header.
5 When you start a new sampling, you can click the Clear button—alternatively, use the
context menu—to clear the data.
199
AFE1_AFE2-1:1
Using the profiler
● Further down in the data, you can find the GetFib function separately and see all of
its subfunctions (in this case none).
The second figure shows the result of profiling using Source: Trace (flat). In this case,
the profiler does not follow the program flow, instead the profiler only detects whether
the PC address is within the function scope. For incomplete trace data, the data might
contain minor errors.
AFE1_AFE2-1:1
Profiling
For the InitFib function, Flat Time 231 is the time (number of hits) spent inside the
function itself.
To secure valid data when using a debug probe, make sure to use the maximum trace
buffer size and set a breakpoint in your code to stop the execution before the buffer is
full.
201
AFE1_AFE2-1:1
Reference information on the profiler
For each instruction, the number of times it has been executed is displayed.
AFE1_AFE2-1:1
Profiling
When Trace(flat) is selected, a checkbox appears on each line in the left-side margin of
the window. Use these checkboxes to include or exclude lines from the profiling.
Excluded lines are dimmed but not removed.
See also Using the profiler, page 198.
Requirements
The C-SPY simulator.
Toolbar
The toolbar contains:
Enable/Disable
Enables or disables the profiler.
Clear
Clears all profiling data.
Save
Opens a standard Save As dialog box where you can save the contents of the
window to a file, with tab-separated columns. Only non-expanded rows are
included in the list file.
Graphical view
Overlays the values in the percentage columns with a graphical bar.
Progress bar
Displays a backlog of profiling data that is still being processed. If the rate of
incoming data is higher than the rate of the profiler processing the data, a
backlog is accumulated. The progress bar indicates that the profiler is still
processing data, but also approximately how far the profiler has come in the
process. Note that because the profiler consumes data at a certain rate and the
target system supplies data at another rate, the amount of data remaining to be
processed can both increase and decrease. The progress bar can grow and shrink
accordingly.
Display area
The content in the display area depends on which source that is used for the profiling
information:
● For the Trace (calls) source, the display area contains one line for each function
compiled with debug information enabled. When some profiling information has
been collected, it is possible to expand rows of functions that have called other
203
AFE1_AFE2-1:1
Reference information on the profiler
functions. The child items for a given function list all the functions that have been
called by the parent function and the corresponding statistics.
● For the Trace (flat) source, the display area contains one line for each C function of
your application, but also lines for sections of code from the runtime library or from
other code without debug information, denoted only by the corresponding
assembler labels. Each executed PC address from trace data is treated as a separate
sample and is associated with the corresponding line in the Profiling window. Each
line contains a count of those samples.
For information about which views that are supported in the C-SPY driver you are using,
see Requirements for using the profiler, page 198.
More specifically, the display area provides information in these columns:
Function (All sources)
The name of the profiled C function.
Calls (Trace (calls))
The number of times the function has been called.
Flat time (Trace (calls))
The time expressed as the estimated number of cycles spent inside the function.
Flat time (%) (Trace (calls))
Flat time expressed as a percentage of the total time.
Acc. time (Trace (calls))
The time expressed as the estimated number of cycles spent inside the function
and everything called by the function.
Acc. time (%) (Trace (calls))
Accumulated time expressed as a percentage of the total time.
PC Samples (Trace (flat))
The number of PC samples associated with the function.
PC Samples (%) (Trace (flat))
The number of PC samples associated with the function as a percentage of the
total number of samples.
Power Samples (Power Sampling)
The number of power samples associated with that function.
Energy (%) (Power Sampling)
The accumulated value of all measurements associated with that function,
expressed as a percentage of all measurements.
AFE1_AFE2-1:1
Profiling
Context menu
This context menu is available:
The contents of this menu depend on the C-SPY driver you are using.
These commands are available:
Enable
Enables the profiler. The system will collect information also when the window
is closed.
Clear
Clears all profiling data.
Filtering
Selects which part of your code to profile. Choose between:
Check All—Excludes all lines from the profiling.
Uncheck All—Includes all lines in the profiling.
Load—Reads all excluded lines from a saved file.
Save—Saves all excluded lines to a file. Typically, this can be useful if you are
a group of engineers and want to share sets of exclusions.
These commands are only available when using Trace (flat).
205
AFE1_AFE2-1:1
Reference information on the profiler
Source*
Selects which source to be used for the profiling information. See also Profiling
sources, page 198. Choose between:
Trace (calls)—the instruction count for instruction profiling is only as complete
as the collected trace data.
Trace (flat)—the instruction count for instruction profiling is only as complete
as the collected trace data.
Power Sampling
Toggles power sampling information on or off.
Save to File
Saves all profiling data to a file.
Show Source
Opens the editor window (if not already opened) and highlights the selected
source line.
* The available sources depend on the C-SPY driver you are using.
AFE1_AFE2-1:1
Code coverage
● Introduction to code coverage
207
AFE1_AFE2-1:1
Reference information on code coverage
This window reports the status of the current code coverage analysis. For every program,
module, and function, the analysis shows the percentage of code that has been executed
since code coverage was turned on up to the point where the application has stopped. In
addition, all statements that have not been executed are listed. The analysis will continue
until turned off.
An asterisk (*) in the title bar indicates that C-SPY has continued to execute, and that
the Code Coverage window must be refreshed because the displayed information is no
longer up to date. To update the information, use the Refresh button.
To get started using code coverage:
1 Before using the code coverage functionality you must build your application using
these options:
Category Setting
C/C++ Compiler Output>Generate debug information
Linker Format>Debug information for C-SPY
Debugger Plugins>Code Coverage
Table 10: Project options for enabling code coverage
2 After you have built your application and started C-SPY, choose View>Code
Coverage to open the Code Coverage window.
3 Click the Activate button, alternatively choose Activate from the context menu, to
switch on code coverage.
AFE1_AFE2-1:1
Code coverage
4 Start the execution. When the execution stops, for instance because the program exit is
reached or a breakpoint is triggered, click the Refresh button to view the code
coverage information.
Requirements
The C-SPY simulator.
Display area
The code coverage information is displayed in a tree structure, showing the program,
module, function, and statement levels. The window displays only source code that was
compiled with debug information. Thus, startup code, exit code, and library code is not
displayed in the window. Furthermore, coverage information for statements in inlined
functions is not displayed. Only the statement containing the inlined function call is
marked as executed. The plus sign and minus sign icons allow you to expand and
collapse the structure.
These icons give you an overview of the current status on all levels:
The percentage displayed at the end of every program, module, and function line shows
the amount of statements that has been covered so far, that is, the number of executed
statements divided with the total number of statements.
For statements that have not been executed (yellow diamond), the information displayed
is the column number range and the row number of the statement in the source window,
followed by the address of the step point:
<column_start>-<column_end>:row address.
A statement is considered to be executed when one of its instructions has been executed.
When a statement has been executed, it is removed from the window and the percentage
is increased correspondingly.
Double-clicking a statement or a function in the Code Coverage window displays that
statement or function as the current position in the editor window, which becomes the
209
AFE1_AFE2-1:1
Reference information on code coverage
active window. Double-clicking a module on the program level expands or collapses the
tree structure.
Context menu
This context menu is available:
AFE1_AFE2-1:1
Power debugging
● Introduction to power debugging
211
AFE1_AFE2-1:1
Introduction to power debugging
then the starting time needs to be approximated. This means that you cannot expect the
same time accuracy when comparing a timestamp of a sample from within one
execution period (from a Go command to the next stop) with a timestamp from another
execution period. However, the accuracy of timestamps within an execution period is
very high.
AFE1_AFE2-1:1
Power debugging
SOFTWARE DELAYS
A software delay might be implemented as a for or while loop like for example:
i = 10000; /* A software delay */
do i--;
while (i != 0);
213
AFE1_AFE2-1:1
Optimizing your source code for power consumption
Such software delays will keep the CPU busy with executing instructions performing
nothing except to make the time go by. Time delays are much better implemented using
a hardware timer. The timer interrupt is set up and after that, the CPU goes down into a
low power mode until it is awakened by the interrupt.
CPU FREQUENCY
Power consumption in a CMOS MCU is theoretically given by the formula:
P = f * U2 * k
AFE1_AFE2-1:1
Power debugging
At t1, the system is activated whereby the current rises to I1 which is the system’s power
consumption in active mode when at least one peripheral device turned on, causing the
215
AFE1_AFE2-1:1
Optimizing your source code for power consumption
current to rise to I1. At t2, the execution becomes suspended by an interrupt which is
handled with high priority. Peripheral devices that were already active are not turned off,
although the task with higher priority is not using them. Instead, more peripheral devices
are activated by the new task, resulting in an increased current I2 between t2 and t3 where
control is handed back to the task with lower priority.
The functionality of the system could be excellent and it can be optimized in terms of
speed and code size. But also in the power domain, more optimizations can be made.
The shadowed area represents the energy that could have been saved if the peripheral
devices that are not used between t2 and t3 had been turned off, or if the priorities of the
two tasks had been changed.
If you use the Timeline window, you can make a closer examination and identify that
unused peripheral devices were activated and consumed power for a longer period than
necessary. Naturally, you must consider whether it is worth it to spend extra clock cycles
to turn peripheral devices on and off in a situation like in the example.
ANALOG INTERFERENCE
When mixing analog and digital circuits on the same board, the board layout and routing
can affect the analog noise levels. To ensure accurate sampling of low-level analog
signals, it is important to keep noise levels low. Obtaining a well-mixed signal design
AFE1_AFE2-1:1
Power debugging
requires careful hardware considerations. Your software design can also affect the
quality of the analog measurements.
Performing a lot of I/O activity at the same time as sampling analog signals causes many
digital lines to toggle state at the same time, which might introduce extra noise into the
AD converter.
Power debugging will help you investigate interference from digital and power supply
lines into the analog parts. Power spikes in the vicinity of AD conversions could be the
source of noise and should be investigated.
217
AFE1_AFE2-1:1
Debugging in the power domain
3 Choose C-SPY driver>Power Log Setup. In the Wanted text box, you can set an
upper limit for the sampling frequency. In the ID column, make sure to select the
alternatives for which you want to enable power logging.
4 Choose C-SPY driver>Timeline to open the Timeline window.
5 Right-click in the graph area and choose Enable from the context menu to enable the
power graph you want to view.
6 Choose C-SPY driver>Power Log to open the Power Log window.
7 Optionally, if you want to correlate power values to the status of the four GPIO input
pins, right-click in the State Log graph area, and choose Enable from the context
menu.
8 Optionally, before you start executing your application you can configure the viewing
range of the Y-axis for the power graph. See Viewing Range dialog box, page 194.
9 Click Go on the toolbar to start executing your application. In the Power Log window,
all power values are displayed. In the Timeline window, you will see a graphical
representation of the power values, and a graphical representation of the logged
activity—state changes—for the four GPIO input pins if you enabled the State Log
graph. For information about how to navigate on the graph, see Navigating in the
graphs, page 178.
AFE1_AFE2-1:1
Power debugging
219
AFE1_AFE2-1:1
Reference information on power debugging
Requirements
The C-SPY Power Debugger driver and the Power Debugger probe.
AFE1_AFE2-1:1
Power debugging
Display area
This area contains these columns:
ID
A unique string that identifies the measurement channel in the probe. Select the
check box to activate the channel. If the check box is deselected, logs will not
be generated for that channel.
Name
Specify a user-defined name.
Threshold
Specify a threshold value in the selected unit. The action you specify will be
executed when the threshold value is reached.
Unit
Displays the selected unit for power. You can choose a unit from the context
menu.
Action
Displays the selected action for the measurement channel. Choose between:
● Log All
● Log Above Threshold
● Log Below Threshold
● Log All and Halt CPU Above Threshold
● Log All and Halt CPU Below Threshold
Context menu
This context menu is available:
221
AFE1_AFE2-1:1
Reference information on power debugging
Log All
Logs all values.
Log Above Threshold
Logs all values above the threshold.
Log Below Threshold
Logs all values below the threshold.
Log All and Halt CPU Above Threshold
Logs all values. If a logged value exceeds the threshold, execution is stopped.
Log All and Halt CPU Below Threshold
Logs all values. If a logged value goes below the threshold, execution is stopped.
Requirements
The C-SPY Power Debugger driver and the Power Debugger probe.
Calibrate
Calibrates the power measurement interface. This is recommended to improve the
accuracy of the power measurements.
This option is only available in an active debug session.
AFE1_AFE2-1:1
Power debugging
The power graph displays a graphical view of power measurement samples generated
by the debug probe or associated hardware in relation to a common time axis.
Note: There is a limit on the number of saved logs. When this limit is exceeded, the
oldest entries in the buffer are erased.
For more information about the Timeline window, how to display a graph, and the other
supported graphs, see The application timeline, page 175.
See also Requirements and restrictions for power debugging, page 213.
Requirements
The C-SPY Power Debugger driver and the Power Debugger probe.
Display area
Where:
● The label area at the left end of the graph displays the name of the measurement
channel.
● The graph can be displayed as a thin line between consecutive logs, as a rectangle
for every log (optionally color-filled), or as columns.
● The resolution of the graph can be changed.
At the bottom of the window, there is a common time axis that uses seconds as the time
unit.
223
AFE1_AFE2-1:1
Reference information on power debugging
Context menu
This context menu is available:
Note: The exact contents of the context menu you see on the screen depends on which
features that your combination of software and hardware supports. However, the list of
menu commands below is complete and covers all possible commands.
These commands are available:
Navigate
Commands for navigating the graph(s). Choose between:
Next moves the selection to the next relevant point in the graph. Shortcut key:
right arrow.
Previous moves the selection backward to the previous relevant point in the
graph. Shortcut key: left arrow.
First moves the selection to the first data entry in the graph. Shortcut key:
Home.
Last moves the selection to the last data entry in the graph. Shortcut key: End.
End moves the selection to the last data in any displayed graph, in other words
the end of the time axis. Shortcut key: Ctrl+End.
Auto Scroll
Toggles automatic scrolling on or off. When on, the most recently collected data
is automatically displayed when you choose Navigate>End.
AFE1_AFE2-1:1
Power debugging
Zoom
Commands for zooming the window, in other words, changing the time scale.
Choose between:
Zoom to Selection makes the current selection fit the window. Shortcut key:
Return.
Zoom In zooms in on the time scale. Shortcut key: +
Zoom Out zooms out on the time scale. Shortcut key: –
10ns, 100ns, 1us, etc makes an interval of 10 nanoseconds, 100 nanoseconds, 1
microsecond, respectively, fit the window.
1ms, 10ms, etc makes an interval of 1 millisecond or 10 milliseconds,
respectively, fit the window.
10m, 1h, etc makes an interval of 10 minutes or 1 hour, respectively, fit the
window.
Power Log
A heading that shows that the Power Log-specific commands below are
available.
Enable
Toggles the display of the graph on or off. If you disable a graph, that graph will
be indicated as OFF in the window. If no data has been collected for a graph, no
data will appear instead of the graph.
Clear
Deletes the log information. Note that this will happen also when you reset the
debugger.
Viewing Range
Displays a dialog box, see Viewing Range dialog box, page 194.
Size
Determines the vertical size of the graph; choose between Small, Medium, and
Large.
Solid Graph
Displays the graph as a color-filled solid graph instead of as a thin line.
Show Numerical Value
Shows the numerical value of the variable, in addition to the graph.
Go To Source
Displays the corresponding source code in an editor window, if applicable.
225
AFE1_AFE2-1:1
Reference information on power debugging
Requirements
The C-SPY Power Debugger driver and the Power Debugger probe.
AFE1_AFE2-1:1
Power debugging
Display area
This area contains these columns:
Time
The time from the application reset until the event. Note that the time offset of
a continuous block of samples (in other words when you start and stop the
execution) is approximated by IAR Embedded Workbench. However, relative
time periods within a block are very accurate because each sample is
timestamped at the debug probe, based on an on-board clock.
This column is available when you have selected Show Time from the context
menu.
Cycles
The number of cycles from the application reset until the event. This
information is cleared at reset.
If a cycle is displayed in italics, the target system could not collect a correct
time, but instead had to approximate it.
This column is available when you have selected Show Cycles from the context
menu.
Name [unit]
The power measurement value expressed in the unit you specified in the Power
Setup window.
227
AFE1_AFE2-1:1
Reference information on power debugging
Context menu
This context menu is available:
AFE1_AFE2-1:1
Power debugging
Show Time
Displays the Time column.
If the Time column is displayed by default in the C-SPY driver you are using,
this menu command is not available.
Show Cycles
Displays the Cycles column.
If the Cycles column is not supported in the C-SPY driver you are using, this
menu command is not available.
Open Setup Window
Opens the Power Log Setup window.
229
AFE1_AFE2-1:1
Reference information on power debugging
Use the State Log Setup window to specify whether to halt the CPU in connection with
activity—state changes—for the GPIO input pins.
Requirements
The C-SPY Power Debugger driver and the Power Debugger probe.
Display area
Each row in this area displays how the CPU behaves for the listed source (GPIO input
pins).
Source
The name of the GPIO input pin.
Action
Specifies an action to take. To choose an action, right-click on the row to open
the context menu.
Context menu
This context menu is available:
AFE1_AFE2-1:1
Power debugging
Requirements
The C-SPY Power Debugger driver and the Power Debugger probe.
Display area
This area contains these columns:
Time
The time from the application reset until the event. Note that the time offset of
a continuous block of samples (in other words when you start and stop the
execution) is approximated by IAR Embedded Workbench. However, relative
time periods within a block are very accurate because each sample is
timestamped at the debug probe, based on an on-board clock.
231
AFE1_AFE2-1:1
Reference information on power debugging
This column is available when you have selected Show Time from the context
menu. If the Show Time command is not available, the Time column is
displayed by default.
Cycles
The number of cycles from the start of the execution until the event.
A cycle count displayed in italics indicates an approximative value. Italics is
used when the target system has not been able to collect a correct value, but
instead had to approximate it.
This column is available when you have selected Show Cycles from the context
menu provided that the C-SPY driver you are using supports it.
Source
The name of the GPIO input pin.
Status
The status at the given time.
Active
The active time calculated using the on and off time for the source. If it is written
in italics, it is based on at least one approximative time.
Context menu
This context menu is available:
AFE1_AFE2-1:1
Power debugging
Save to File
Displays a standard file selection dialog box where you can select the
destination file for the log information. The entries in the log file are separated
by TAB and LF characters. An X in the Approx column indicates that the
timestamp is an approximation.
Show Time
Displays the Time column.
If the Time column is always displayed by default in the C-SPY driver you are
using, this menu command is not available.
Show Cycles
Displays the Cycles column.
If the C-SPY driver you are using does not support the Cycles column, this
menu command is not available.
Requirements
The C-SPY Power Debugger driver and the Power Debugger probe.
233
AFE1_AFE2-1:1
Reference information on power debugging
Display area
Each row in this area displays statistics about the specific measurement source based on
the log information in these columns; and summary information is listed at the bottom
of the display area:
Source
The name of the GPIO input pin.
Count
The number of times the source was activated.
First time
The first time the source was activated.
Total (Time)**
The accumulated time the source has been active.
Total (%)
The accumulated time in percent that the source has been active.
Shortest
The shortest time spent with this source active.
Longest
The longest time spent with this source active.
Min interval
The shortest time between two activations of this source.
Max interval
The longest time between two activations of this source.
Current time
The current time or cycles—execution time since the start of execution or the
number of cycles. (This information might not be available in the C-SPY driver
you are using.)
** Calculated in the same way as for the Execution time/cycles in the State Log
window.
AFE1_AFE2-1:1
Power debugging
Context menu
This context menu is available:
235
AFE1_AFE2-1:1
Reference information on power debugging
The State Log graph displays a graphical view of logged activity—state changes—for
the GPIO pins in relation to a common time axis.
Note: There is a limit on the number of saved logs. When this limit is exceeded, the
oldest entries in the buffer are erased.
For more information about the Timeline window, how to display a graph, and the other
supported graphs, see The application timeline, page 175.
See also, Requirements and restrictions for power debugging, page 213.
Requirements
The C-SPY Power Debugger driver and the Power Debugger probe.
Display area
Where:
● The label area at the left end of the graph displays the name of the sources of the
status information.
● The graph itself shows the state of the GPIO pins generated by the debug probe or
associated hardware. The white figure indicates the time spent in the state. This
graph is a graphical representation of the information in the State Log window, see
State Log window, page 231.
● If the bar is displayed without a vertical border, the missing border indicates an
approximate time for the log.
At the bottom of the window, there is a shared time axis that uses seconds as the time
unit.
AFE1_AFE2-1:1
Power debugging
Context menu
This context menu is available:
Note: The exact contents of the context menu you see on the screen depends on which
features that your combination of software and hardware supports. However, the list of
menu commands below is complete and covers all possible commands.
These commands are available:
Navigate
Commands for navigating the graph(s). Choose between:
Next moves the selection to the next relevant point in the graph. Shortcut key:
right arrow.
Previous moves the selection backward to the previous relevant point in the
graph. Shortcut key: left arrow.
First moves the selection to the first data entry in the graph. Shortcut key:
Home.
Last moves the selection to the last data entry in the graph. Shortcut key: End.
End moves the selection to the last data in any displayed graph, in other words
the end of the time axis. Shortcut key: Ctrl+End.
Auto Scroll
Toggles automatic scrolling on or off. When on, the most recently collected data
is automatically displayed when you choose Navigate>End.
237
AFE1_AFE2-1:1
Reference information on power debugging
Zoom
Commands for zooming the window, in other words, changing the time scale.
Choose between:
Zoom to Selection makes the current selection fit the window. Shortcut key:
Return.
Zoom In zooms in on the time scale. Shortcut key: +
Zoom Out zooms out on the time scale. Shortcut key: –
10ns, 100ns, 1us, etc makes an interval of 10 nanoseconds, 100 nanoseconds, 1
microsecond, respectively, fit the window.
1ms, 10ms, etc makes an interval of 1 millisecond or 10 milliseconds,
respectively, fit the window.
10m, 1h, etc makes an interval of 10 minutes or 1 hour, respectively, fit the
window.
State Log
A heading that shows that the State Log-specific commands below are available.
Enable
Toggles the display of the graph on or off. If you disable a graph, that graph will
be indicated as OFF in the window. If no data has been collected for a graph, no
data will appear instead of the graph.
Clear
Deletes the log information. Note that this will happen also when you reset the
debugger.
Go To Source
Displays the corresponding source code in an editor window, if applicable.
Sort by
Sorts the entries according to their ID or name. The selected order is used in the
graph when new interrupts appear.
source
Goes to the previous/next log for the selected source.
Open Setup Window
Opens the State Log Setup window. This command might not be supported by
the combination of C-SPY driver and debug probe you are using.
Select Graphs
Selects which graphs to be displayed in the Timeline window.
AFE1_AFE2-1:1
Power debugging
239
AFE1_AFE2-1:1
Reference information on power debugging
AFE1_AFE2-1:1
Part 3. Advanced
debugging
This part of the C-SPY® Debugging Guide for AVR includes these chapters:
● Interrupts
● C-SPY macros
241
242
Interrupts
● Introduction to interrupts
Introduction to interrupts
These topics are covered:
● Briefly about the interrupt simulation system
● Interrupt characteristics
● C-SPY system macros for interrupt simulation
● Target-adapting the interrupt simulation system
See also:
● Reference information on C-SPY system macros, page 265
● Breakpoints, page 105
● The IAR C/C++ Compiler User Guide for AVR
243
AFE1_AFE2-1:1
Introduction to interrupts
INTERRUPT CHARACTERISTICS
The simulated interrupts consist of a set of characteristics which lets you fine-tune each
interrupt to make it resemble the real interrupt on your target hardware. You can specify
a first activation time, a repeat interval, a hold time, a variance, and a probability.
The interrupt simulation system uses the cycle counter as a clock to determine when an
interrupt should be raised in the simulator. You specify the first activation time, which
is based on the cycle counter. C-SPY will generate an interrupt when the cycle counter
has passed the specified activation time. However, interrupts can only be raised between
instructions, which means that a full assembler instruction must have been executed
before the interrupt is generated, regardless of how many cycles an instruction takes.
To define the periodicity of the interrupt generation you can specify the repeat interval
which defines the amount of cycles after which a new interrupt should be generated. In
addition to the repeat interval, the periodicity depends on the two options probability—
the probability, in percent, that the interrupt will actually appear in a period—and
variance—a time variation range as a percentage of the repeat interval. These options
make it possible to randomize the interrupt simulation. You can also specify a hold time
which describes how long the interrupt remains pending until removed if it has not been
processed.
AFE1_AFE2-1:1
Interrupts
__disableInterrupts
__orderInterrupt
__cancelInterrupt
__cancelAllInterrupts
The parameters of the first five macros correspond to the equivalent entries of the
Interrupts dialog box.
For more information about each macro, see Reference information on C-SPY system
macros, page 265.
245
AFE1_AFE2-1:1
Using the interrupt system
AFE1_AFE2-1:1
Interrupts
Option Settings
Activation 4000
Repeat interval 2000
Hold time 10
Probability (%) 100
Variance (%) 0
Table 11: Timer interrupt settings
247
AFE1_AFE2-1:1
Reference information on interrupts
This dialog box lists all defined interrupts. Use this dialog box to enable or disable the
interrupt simulation system, as well as to enable or disable individual interrupts.
Requirements
The C-SPY simulator.
Enable simulation
Enables or disables interrupt simulation. If the interrupt simulation is disabled, the
definitions remain but no interrupts are generated.
Interrupt
Lists all available interrupts. Your selection will automatically update the Description
box.
The list is populated with entries from the device description file that you have selected.
Activation time
Specify the value of the cycle counter, after which the specified type of interrupt will be
generated.
AFE1_AFE2-1:1
Interrupts
Repeat interval
Specify the periodicity of the interrupt in cycles.
Hold time
Specify how long, in cycles, the interrupt remains pending until removed if it has not
been processed.
Probability
Specify the probability, in percent, that the interrupt will actually occur within the
specified period.
Variance
Specify a timing variation range, as a percentage of the repeat interval in which the
interrupt may occur for a period. For example, if the repeat interval is 100 and the
variance 5%, the interrupt might occur anywhere between T=95 and T=105, to simulate
a variation in the timing.
Installed interrupts
Lists the installed interrupts. The interrupt specification text in the list is prefixed with
either [S] for a single-shot interrupt or [R] for a repeated interrupt. If the interrupt is
activated but pending an additional [P] will be inserted.
Buttons
These buttons are available:
249
AFE1_AFE2-1:1
Reference information on interrupts
AFE1_AFE2-1:1
C-SPY macros
● Introduction to C-SPY macros
251
AFE1_AFE2-1:1
Introduction to C-SPY macros
AFE1_AFE2-1:1
C-SPY macros
Example
Consider this example of a macro function which illustrates the various components of
the macro language:
__var oldVal;
CheckLatest(val)
{
if (oldVal != val)
{
__message "Message: Changed from ", oldVal, " to ", val, "\n";
oldVal = val;
}
}
Note: Reserved macro words begin with double underscores to prevent name conflicts.
253
AFE1_AFE2-1:1
Using C-SPY macros
AFE1_AFE2-1:1
C-SPY macros
This macro function registers the additional macro files MyMacroUtils.mac and
MyDeviceSimulation.mac. Because the macro function is defined with the function
name execUserSetup, it will be executed directly after your application has been
downloaded.
2 Save the file using the filename extension mac.
3 Before you start C-SPY, choose Project>Options>Debugger>Setup. Select Use
Setup file and choose the macro file you just created.
The macros will now be registered during the C-SPY startup sequence.
255
AFE1_AFE2-1:1
Using C-SPY macros
Alternatively, in the macro file editor window, select the macro function name
TimerStatus(). Right-click, and choose Quick Watch from the context menu that
appears.
AFE1_AFE2-1:1
C-SPY macros
257
AFE1_AFE2-1:1
Reference information on the macro language
This method can be used if you suspect that something is wrong with the execution, for
example because it seems not to terminate in a reasonable time.
MACRO FUNCTIONS
C-SPY macro functions consist of C-SPY variable definitions and macro statements
which are executed when the macro is called. An unlimited number of parameters can
be passed to a macro function, and macro functions can return a value on exit.
A C-SPY macro has this form:
macroName (parameterList)
{
macroBody
}
Type checking is neither performed on the values passed to the macro functions nor on
the return value.
MACRO VARIABLES
A macro variable is a variable defined and allocated outside your application. It can then
be used in a C-SPY expression, or you can assign application data—values of the
variables in your application—to it. For more information about C-SPY expressions, see
C-SPY expressions, page 86.
The syntax for defining one or more macro variables is:
__var nameList;
AFE1_AFE2-1:1
C-SPY macros
A macro variable defined outside a macro body has global scope, and it exists
throughout the whole debugging session. A macro variable defined within a macro body
is created when its definition is executed and destroyed on return from the macro.
By default, macro variables are treated as signed integers and initialized to 0. When a
C-SPY variable is assigned a value in an expression, it also acquires the type of that
expression. For example:
Expression What it means
myvar = 3.5; myvar is now type double, value 3.5.
myvar = (int*)i; myvar is now type pointer to int, and the value is the same as i.
Table 12: Examples of C-SPY macro variables
In case of a name conflict between a C symbol and a C-SPY macro variable, C-SPY
macro variables have a higher precedence than C variables. Note that macro variables
are allocated on the debugger host and do not affect your application.
MACRO PARAMETERS
A macro parameter is intended for parameterization of device support. The named
parameter will behave as a normal C-SPY macro variable with these differences:
● The parameter definition can have an initializer
● Values of a parameters can be set through options (either in the IDE or in cspybat).
● A value set from an option will take precedence over a value set by an initializer
● A parameter must have an initializer, be set through an option, or both. Otherwise, it
has an undefined value, and accessing it will cause a runtime error.
The syntax for defining one or more macro parameters is:
__param param[ = value, ...;]
Use the command line option --macro_param to specify a value to a parameter, see
--macro_param, page 330.
MACRO STRINGS
In addition to C types, macro variables can hold values of macro strings. Note that
macro strings differ from C language strings.
When you write a string literal, such as "Hello!", in a C-SPY expression, the value is
a macro string. It is not a C-style character pointer char*, because char* must point to
a sequence of characters in target memory and C-SPY cannot expect any string literal to
actually exist in target memory.
You can manipulate a macro string using a few built-in macro functions, for example
__strFind or __subString. The result can be a new macro string. You can
259
AFE1_AFE2-1:1
Reference information on the macro language
concatenate macro strings using the + operator, for example str + "tail". You can
also access individual characters using subscription, for example str[3]. You can get the
length of a string using sizeof(str). Note that a macro string is not
NULL-terminated.
The macro function __toString is used for converting from a NULL-terminated C
string in your application (char* or char[]) to a macro string. For example, assume
this definition of a C string in your application:
char const *cstr = "Hello";
MACRO STATEMENTS
Statements are expected to behave in the same way as the corresponding C statements
would do. The following C-SPY macro statements are accepted:
Expressions
expression;
For more information about C-SPY expressions, see C-SPY expressions, page 86.
Conditional statements
if (expression)
statement
if (expression)
statement
else
statement
AFE1_AFE2-1:1
C-SPY macros
Loop statements
for (init_expression; cond_expression; update_expression)
statement
while (expression)
statement
do
statement
while (expression);
Return statements
return;
return expression;
If the return value is not explicitly set, signed int 0 is returned by default.
Blocks
Statements can be grouped in blocks.
{
statement1
statement2
.
.
.
statementN
}
FORMATTED OUTPUT
C-SPY provides various methods for producing formatted output:
261
AFE1_AFE2-1:1
Reference information on the macro language
To produce strings:
myMacroVar = __smessage 42, " is the answer.";
These match the formats available in the Watch and Locals windows, but number
prefixes and quotes around strings and characters are not printed. Another example:
__message "The character '", cvar:%c, "' has the decimal value
", cvar;
AFE1_AFE2-1:1
C-SPY macros
would produce:
65 is the numeric value of the character A
Note: The default format for certain types is primarily designed to be useful in the
Watch window and other related windows. For example, a value of type char is
formatted as 'A' (0x41), while a pointer to a character (potentially a C string) is
formatted as 0x8102 "Hello", where the string part shows the beginning of the string
(currently up to 60 characters).
When printing a value of type char*, use the %x format specifier to print just the pointer
value in hexadecimal notation, or use the system macro __toString to get the full
string value.
execUserPreload
Syntax execUserPreload
Description Called after communication with the target system is established but before
downloading the target application.
Implement this macro to initialize memory locations and/or registers which are vital for
loading data properly.
263
AFE1_AFE2-1:1
Reference information on reserved setup macro function names
execUserExecutionStarted
Syntax execUserExecutionStarted
Description Called when the debugger is about to start or resume execution. The macro is not called
when performing a one-instruction assembler step, in other words, Step or Step Into in
the Disassembly window.
execUserExecutionStopped
Syntax execUserExecutionStopped
Description Called when the debugger has stopped execution. The macro is not called when
performing a one-instruction assembler step, in other words, Step or Step Into in the
Disassembly window.
execUserSetup
Syntax execUserSetup
The reason for this is that the simulator saves interrupt settings between sessions and if
they are not removed they will get duplicated every time execUserSetup is executed
again. This seriously affects the execution speed.
AFE1_AFE2-1:1
C-SPY macros
execUserPreReset
Syntax execUserPreReset
Description Called each time just before the reset command is issued.
Implement this macro to set up any required device state.
execUserReset
Syntax execUserReset
Description Called each time just after the reset command is issued.
Implement this macro to set up and restore data.
execUserExit
Syntax execUserExit
265
AFE1_AFE2-1:1
Reference information on C-SPY system macros
Macro Description
__closeFile Closes a file that was opened by __openFile
__delay Delays execution
__disableInterrupts Disables generation of interrupts
__driverType Verifies the driver type
__enableInterrupts Enables generation of interrupts
__evaluate Interprets the input string as an expression and
evaluates it.
__fillMemory8 Fills a specified memory area with a byte value.
__fillMemory16 Fills a specified memory area with a 2-byte value.
__fillMemory32 Fills a specified memory area with a 4-byte value.
__getCycleCounter Reads the cycle counter
__isBatchMode Checks if C-SPY is running in batch mode or not.
__loadImage Loads an image.
__memoryRestore Restores the contents of a file to a specified memory
zone
__memoryRestoreFromFile Reads from a file and restores to memory
__memorySave Saves the contents of a specified memory area to a
file
__memorySaveToFile Saves a range of a memory zone to a file
__messageBoxYesCancel Displays a Yes/Cancel dialog box for user interaction
__messageBoxYesNo Displays a Yes/No dialog box for user interaction
__openFile Opens a file for I/O operations
__orderInterrupt Generates an interrupt
__readFile Reads from the specified file
__readFileByte Reads one byte from the specified file
__readMemory8, Reads one byte from the specified memory location
__readMemoryByte
__readMemory16 Reads two bytes from the specified memory location
__readMemory32 Reads four bytes from the specified memory location
__registerMacroFile Registers macros from the specified file
__resetFile Rewinds a file opened by __openFile
__setCodeBreak Sets a code breakpoint
__setComplexBreak Sets a complex breakpoint
Table 13: Summary of system macros
AFE1_AFE2-1:1
C-SPY macros
Macro Description
__setDataBreak Sets a data breakpoint
__setLogBreak Sets a log breakpoint
__setSimBreak Sets a simulation breakpoint
__setTraceStartBreak Sets a trace start breakpoint
__setTraceStopBreak Sets a trace stop breakpoint
__sourcePosition Returns the file name and source location if the
current execution location corresponds to a source
location
__strFind Searches a given string for the occurrence of another
string
__subString Extracts a substring from another string
__targetDebuggerVersion Returns the version of the target debugger
__toLower Returns a copy of the parameter string where all the
characters have been converted to lower case
__toString Prints strings
__toUpper Returns a copy of the parameter string where all the
characters have been converted to upper case
__unloadImage Unloads a debug image
__writeFile Writes to the specified file
__writeFileByte Writes one byte to the specified file
__writeMemory8, Writes one byte to the specified memory location
__writeMemoryByte
__writeMemory16 Writes a two-byte word to the specified memory
location
__writeMemory32 Writes a four-byte word to the specified memory
location
Table 13: Summary of system macros
__abortLaunch
Syntax __abortLaunch(message)
Parameters message
A string that is printed as an error message when the macro executes.
267
AFE1_AFE2-1:1
Reference information on C-SPY system macros
Description This macro can be used for aborting a debugger launch, for example if another macro
sees that something goes wrong during initialization and cannot perform a proper setup.
This is an emergency exit, not a recommended way to end a debug session like the C
library function abort().
__cancelAllInterrupts
Syntax __cancelAllInterrupts()
__cancelInterrupt
Syntax __cancelInterrupt(interrupt_id)
Parameters interrupt_id
The value returned by the corresponding __orderInterrupt macro call
(unsigned long).
Return value
Result Value
Successful int 0
Unsuccessful Non-zero error number
Table 14: __cancelInterrupt return values
AFE1_AFE2-1:1
C-SPY macros
__clearBreak
Syntax __clearBreak(break_id)
Parameters break_id
The value returned by any of the set breakpoint macros.
__closeFile
Syntax __closeFile(fileHandle)
Parameters fileHandle
A macro variable used as filehandle by the __openFile macro.
__delay
Syntax __delay(value)
Parameters value
The number of milliseconds to delay execution.
269
AFE1_AFE2-1:1
Reference information on C-SPY system macros
__disableInterrupts
Syntax __disableInterrupts()
Return value
Result Value
Successful int 0
Unsuccessful Non-zero error number
Table 15: __disableInterrupts return values
__driverType
Syntax __driverType(driver_id)
Parameters driver_id
A string corresponding to the driver you want to check for. Choose one of these:
"sim" corresponds to the simulator driver.
Return value
Result Value
Successful 1
Unsuccessful 0
Table 16: __driverType return values
Description Checks to see if the current C-SPY driver is identical to the driver type of the
driver_id parameter.
AFE1_AFE2-1:1
C-SPY macros
Example __driverType("sim")
If the simulator is the current driver, the value 1 is returned. Otherwise 0 is returned.
__enableInterrupts
Syntax __enableInterrupts()
Return value
Result Value
Successful int 0
Unsuccessful Non-zero error number
Table 17: __enableInterrupts return values
__evaluate
Syntax __evaluate(string, valuePtr)
Parameters string
Expression string.
valuePtr
Pointer to a macro variable storing the result.
Return value
Result Value
Successful int 0
Unsuccessful int 1
Table 18: __evaluate return values
Description This macro interprets the input string as an expression and evaluates it. The result is
stored in a variable pointed to by valuePtr.
Example This example assumes that the variable i is defined and has the value 5:
__evaluate("i + 3", &myVar)
271
AFE1_AFE2-1:1
Reference information on C-SPY system macros
__fillMemory8
Syntax __fillMemory8(value, address, zone, length, format)
Parameters value
An integer that specifies the value.
address
An integer that specifies the memory start address.
zone
A string that specifies the memory zone, see C-SPY memory zones, page 134.
length
An integer that specifies how many bytes are affected.
format
One of these alternatives:
__fillMemory16
Syntax __fillMemory16(value, address, zone, length, format)
AFE1_AFE2-1:1
C-SPY macros
Parameters value
An integer that specifies the value.
address
An integer that specifies the memory start address.
zone
A string that specifies the memory zone, see C-SPY memory zones, page 134.
length
An integer that defines how many 2-byte entities to be affected.
format
One of these alternatives:
__fillMemory32
Syntax __fillMemory32(value, address, zone, length, format)
Parameters value
An integer that specifies the value.
address
An integer that specifies the memory start address.
273
AFE1_AFE2-1:1
Reference information on C-SPY system macros
zone
A string that specifies the memory zone, see C-SPY memory zones, page 134.
length
An integer that defines how many 4-byte entities to be affected.
format
One of these alternatives:
__getCycleCounter
Syntax __getCycleCounter()
Return value Returns the current value of the cycle counter as a long long int.
AFE1_AFE2-1:1
C-SPY macros
__isBatchMode
Syntax __isBatchMode()
Return value
Result Value
True int 1
False int 0
Table 19: __isBatchMode return values
Description This macro returns True if the debugger is running in batch mode, otherwise it returns
False.
__loadImage
Syntax __loadImage(path, offset, debugInfoOnly)
Parameters path
A string that identifies the path to the image to download. The path must either
be absolute or use argument variables. For information about argument
variables, see the IDE Project Management and Building Guide for AVR.
offset
An integer that identifies the offset to the destination address for the downloaded
image.
debugInfoOnly
A non-zero integer value if no code or data should be downloaded to the target
system, which means that C-SPY will only read the debug information from the
debug file. Or, 0 (zero) for download.
Return value
Value Result
Non-zero integer number A unique module identification.
int 0 Loading failed.
Table 20: __loadImage return values
275
AFE1_AFE2-1:1
Reference information on C-SPY system macros
Example 1 Your system consists of a ROM library and an application. The application is your active
project, but you have a debug file corresponding to the library. In this case you can add
this macro call in the execUserSetup macro in a C-SPY macro file, which you
associate with your project:
__loadImage("ROMfile", 0x8000, 1);
This macro call loads the debug information for the ROM library ROMfile without
downloading its contents (because it is presumably already in ROM). Then you can
debug your application together with the library.
Example 2 Your system consists of a ROM library and an application, but your main concern is the
library. The library needs to be programmed into flash memory before a debug session.
While you are developing the library, the library project must be the active project in the
IDE. In this case you can add this macro call in the execUserSetup macro in a C-SPY
macro file, which you associate with your project:
__loadImage("ApplicationFile", 0x8000, 0);
The macro call loads the debug information for the application and downloads its
contents (presumably into RAM). Then you can debug your library together with the
application.
See also Images, page 340 and Loading multiple images, page 53.
__memoryRestore
Syntax __memoryRestore(zone, filename)
Parameters zone
A string that specifies the memory zone, see C-SPY memory zones, page 134.
filename
A string that specifies the file to be read. The filename must include a path,
which must either be absolute or use argument variables. For information about
argument variables, see the IDE Project Management and Building Guide for
AVR.
Description Reads the contents of a file and saves it to the specified memory zone. It is recommended
that you use this macro instead of __memoryRestoreFromFile.
AFE1_AFE2-1:1
C-SPY macros
__memoryRestoreFromFile
Syntax __memoryRestoreFromFile(filename, zone)
Parameters
filename The file to be read.
zone The memory zone name (string); for a list of available zones,
see C-SPY memory zones, page 134.
Description Reads the contents of a file in intel-hex or Motorola S-record format and writes it to the
specified memory zone. This macro is available for backwards compatibility.
__memorySave
Syntax __memorySave(start, stop, format, filename)
Parameters start
A string that specifies the first location of the memory area to be saved.
stop
A string that specifies the last location of the memory area to be saved.
format
A string that specifies the format to be used for the saved memory. Choose
between:
intel-extended
motorola
motorola-s19
motorola-s28
277
AFE1_AFE2-1:1
Reference information on C-SPY system macros
motorola-s37.
filename
A string that specifies the file to write to. The filename must include a path,
which must either be absolute or use argument variables. For information about
argument variables, see the IDE Project Management and Building Guide for
AVR.
Return value 0 if successful. At failure, macro execution is aborted and log messages are produced.
Description Saves the contents of a specified memory area to a file. It is recommended that you use
this macro instead of __memorySaveToFile.
__memorySaveToFile
Syntax __memorySaveToFile(filename, zone, start, stop)
Parameters
filename The file to be written.
zone The memory zone name (string); for a list of available zones,
see C-SPY memory zones, page 134.
start The start address of the memory range to be saved.
stop The stop address of the memory range to be saved.
Description Saves a range of a memory zone to a file. The file is written in the Intel hex format. This
macro is available for backwards compatibility.
AFE1_AFE2-1:1
C-SPY macros
__messageBoxYesCancel
Syntax __messageBoxYesCancel(message, caption)
Parameters message
A message that will appear in the message box.
caption
The title that will appear in the message box.
Return value
Result Value
Yes 1
No 0
Table 21: __messageBoxYesCancel return values
Description Displays a Yes/Cancel dialog box when called and returns the user input. Typically, this
is useful for creating macros that require user interaction.
__messageBoxYesNo
Syntax __messageBoxYesNo(message, caption)
Parameters message
A message that will appear in the message box.
caption
The title that will appear in the message box.
Return value
Result Value
Yes 1
No 0
Table 22: __messageBoxYesNo return values
Description Displays a Yes/No dialog box when called and returns the user input. Typically, this is
useful for creating macros that require user interaction.
279
AFE1_AFE2-1:1
Reference information on C-SPY system macros
__openFile
Syntax __openFile(filename, access)
Parameters filename
The file to be opened. The filename must include a path, which must either be
absolute or use argument variables. For information about argument variables,
see the IDE Project Management and Building Guide for AVR.
access
The access type (string).
These are mandatory but mutually exclusive:
"a" append, new data will be appended at the end of the open file
"r" read (by default in text mode; combine with b for binary mode: rb)
"w" write (by default in text mode; combine with b for binary mode: wb)
Return value
Result Value
Successful The file handle
Unsuccessful An invalid file handle, which tests as False
Table 23: __openFile return values
Description Opens a file for I/O operations. The default base directory of this macro is where the
currently open project file (*.ewp) is located. The argument to __openFile can
specify a location relative to this directory. In addition, you can use argument variables
such as $PROJ_DIR$ and $TOOLKIT_DIR$ in the path argument.
AFE1_AFE2-1:1
C-SPY macros
See also For information about argument variables, see the IDE Project Management and
Building Guide for AVR.
__orderInterrupt
Syntax __orderInterrupt(specification, first_activation,
repeat_interval, variance,
hold_time, probability)
Parameters specification
The interrupt name (string). The interrupt system will automatically get the
description from the device description file.
first_activation
The first activation time in cycles (integer)
repeat_interval
The periodicity in cycles (integer)
variance
The timing variation range in percent (integer between 0 and 100)
hold_time
The hold time (integer)
probability
The probability in percent (integer between 0 and 100)
281
AFE1_AFE2-1:1
Reference information on C-SPY system macros
Example This example generates a repeating interrupt using an infinite hold time first activated
after 4000 cycles:
__orderInterrupt( "USART0 TXC", 4000, 2000, 0, 0, 100 );
__readFile
Syntax __readFile(fileHandle, valuePtr)
Parameters fileHandle
A macro variable used as filehandle by the __openFile macro.
valuePtr
A pointer to a variable.
Return value
Result Value
Successful 0
Unsuccessful Non-zero error number
Table 24: __readFile return values
Description Reads a sequence of hexadecimal digits from the given file and converts them to an
unsigned long which is assigned to the value parameter, which should be a pointer
to a macro variable.
Only printable characters representing hexadecimal digits and white-space characters
are accepted, no other characters are allowed.
In this example, if the file pointed to by myFileHandle contains the ASCII characters
1234 abcd 90ef, consecutive reads will assign the values 0x1234 0xabcd 0x90ef
to the variable number.
AFE1_AFE2-1:1
C-SPY macros
__readFileByte
Syntax __readFileByte(fileHandle)
Parameters fileHandle
A macro variable used as filehandle by the __openFile macro.
Return value -1 upon error or end-of-file, otherwise a value between 0 and 255.
__readMemory8, __readMemoryByte
Syntax __readMemory8(address, zone)
__readMemoryByte(address, zone)
Parameters address
The memory address (integer).
zone
A string that specifies the memory zone, see C-SPY memory zones, page 134.
283
AFE1_AFE2-1:1
Reference information on C-SPY system macros
__readMemory16
Syntax __readMemory16(address, zone)
Parameters address
The memory address (integer).
zone
A string that specifies the memory zone, see C-SPY memory zones, page 134.
__readMemory32
Syntax __readMemory32(address, zone)
Parameters address
The memory address (integer).
zone
A string that specifies the memory zone, see C-SPY memory zones, page 134.
AFE1_AFE2-1:1
C-SPY macros
__registerMacroFile
Syntax __registerMacroFile(filename)
Parameters filename
A file containing the macros to be registered (string). The filename must include
a path, which must either be absolute or use argument variables. For information
about argument variables, see the IDE Project Management and Building Guide
for AVR.
Description Registers macros from a setup macro file. With this function you can register multiple
macro files during C-SPY startup.
Example __registerMacroFile("c:\\testdir\\macro.mac");
__resetFile
Syntax __resetFile(fileHandle)
Parameters fileHandle
A macro variable used as filehandle by the __openFile macro.
285
AFE1_AFE2-1:1
Reference information on C-SPY system macros
__setCodeBreak
Syntax __setCodeBreak(location, count, condition, cond_type, action)
Parameters location
A string that defines the code location of the breakpoint, either a valid C-SPY
expression whose value evaluates to a valid address, an absolute location, or a
source location. For more information about the location types, see Enter
Location dialog box, page 130.
count
The number of times that a breakpoint condition must be fulfilled before a break
occurs (integer).
condition
The breakpoint condition (string).
cond_type
The condition type; either "CHANGED" or "TRUE" (string).
action
An expression, typically a call to a macro, which is evaluated when the
breakpoint is detected.
Return value
Result Value
Successful An unsigned integer uniquely identifying the breakpoint. This value
must be used to clear the breakpoint.
Unsuccessful 0
Table 25: __setCodeBreak return values
Description Sets a code breakpoint, that is, a breakpoint which is triggered just before the processor
fetches an instruction at the specified location.
This example sets a code breakpoint on the label main in your source:
__setCodeBreak("main", 0, "1", "TRUE", "");
AFE1_AFE2-1:1
C-SPY macros
__setComplexBreak
Syntax __setComplexBreak(control, a_addr, b_addr, access_type,
a_access, b_access, complex_data, c_value, d_value, c_compare,
d_compare, action)
Parameters
control Breakpoint control:
ENABLE_A to enable a breakpoint at a_addr
W for write
RW for read/write
287
AFE1_AFE2-1:1
Reference information on C-SPY system macros
W for write
RW for read/write
AFE1_AFE2-1:1
C-SPY macros
Return value
Result Value
Successful An unsigned integer uniquely identifying the breakpoint. This value must be
used to clear the breakpoint.
Unsuccessful 0
Table 26: __set Complex Break return values
Description Sets a complex breakpoint, that is, a breakpoint which is triggered directly after the
processor has read or written data at the specified location.
Example The following example enables one data read/write breakpoint at the address for
variable a and will break if the memory byte value at address is equal to 0x22, and it
enables one data read breakpoint at the address for variable b and will break if the
memory byte value at address is greater than or equal to 0x11. When a break occurs, the
macro function ActionData() will be called.
__var brk;
brk=__setComplexBreak("ENABLE_AB", "a", "b", "DATA", "RW", "R",
"CD_COMBINED_WITH_AB", "0x22", "0x11" "EQ", "GE",
"ActionData()");
...
__clearBreak(brk);
__setDataBreak
Syntax __setDataBreak(location, count, condition, cond_type, access,
action)
Parameters location
A string that defines the data location of the breakpoint, either a valid C-SPY
expression whose value evaluates to a valid address or an absolute location. For
more information about the location types, see Enter Location dialog box, page
130.
289
AFE1_AFE2-1:1
Reference information on C-SPY system macros
count
The number of times that a breakpoint condition must be fulfilled before a break
occurs (integer).
condition
The breakpoint condition (string).
cond_type
The condition type; either "CHANGED" or "TRUE" (string).
access
The memory access type: "R", for read, "W" for write, or "RW" for read/write.
action
An expression, typically a call to a macro, which is evaluated when the
breakpoint is detected.
Return value
Result Value
Successful An unsigned integer uniquely identifying the breakpoint. This value
must be used to clear the breakpoint.
Unsuccessful 0
Table 27: __setDataBreak return values
Description Sets a data breakpoint, that is, a breakpoint which is triggered directly after the processor
has read or written data at the specified location.
AFE1_AFE2-1:1
C-SPY macros
__setLogBreak
Syntax __setLogBreak(location, message, msg_type, condition,
cond_type)
Parameters location
A string that defines the code location of the breakpoint, either a valid C-SPY
expression whose value evaluates to a valid address, an absolute location, or a
source location. For more information about the location types, see Enter
Location dialog box, page 130.
message
The message text.
msg_type
The message type; choose between:
TEXT, the message is written word for word.
Return value
Result Value
Successful An unsigned integer uniquely identifying the breakpoint. The same
value must be used when you want to clear the breakpoint.
Unsuccessful 0
Table 28: __setLogBreak return values
Description Sets a log breakpoint, that is, a breakpoint which is triggered when an instruction is
fetched from the specified location. If you have set the breakpoint on a specific machine
instruction, the breakpoint will be triggered and the execution will temporarily halt and
print the specified message in the C-SPY Debug Log window.
291
AFE1_AFE2-1:1
Reference information on C-SPY system macros
logOn()
{
logBp1 = __setLogBreak ("{C:\\temp\\Utilities.c}.23.1",
"\"Entering trace zone at :\", #PC:%X", "ARGS", "1", "TRUE");
logBp2 = __setLogBreak ("{C:\\temp\\Utilities.c}.30.1",
"Leaving trace zone...", "TEXT", "1", "TRUE");
}
logOff()
{
__clearBreak(logBp1);
__clearBreak(logBp2);
}
See also Formatted output, page 261 and Breakpoints, page 105.
__setSimBreak
Syntax __setSimBreak(location, access, action)
Parameters location
A string that defines the data location of the breakpoint, either a valid C-SPY
expression whose value evaluates to a valid address or an absolute location. For
more information about the location types, see Enter Location dialog box, page
130.
access
The memory access type: "R" for read or "W" for write.
action
An expression, typically a call to a macro, which is evaluated when the
breakpoint is detected.
Return value
Result Value
Successful An unsigned integer uniquely identifying the breakpoint. This value
must be used to clear the breakpoint.
Unsuccessful 0
Table 29: __setSimBreak return values
AFE1_AFE2-1:1
C-SPY macros
Description Use this system macro to set immediate breakpoints, which will halt instruction
execution only temporarily. This allows a C-SPY macro function to be called when the
processor is about to read data from a location or immediately after it has written data.
Instruction execution will resume after the action.
This type of breakpoint is useful for simulating memory-mapped devices of various
kinds (for instance serial ports and timers). When the processor reads at a
memory-mapped location, a C-SPY macro function can intervene and supply the
appropriate data. Conversely, when the processor writes to a memory-mapped location,
a C-SPY macro function can act on the value that was written.
__setTraceStartBreak
Syntax __setTraceStartBreak(location)
Parameters location
A string that defines the code location of the breakpoint, either a valid C-SPY
expression whose value evaluates to a valid address, an absolute location, or a
source location. For more information about the location types, see Enter
Location dialog box, page 130.
Return value
Result Value
Successful An unsigned integer uniquely identifying the breakpoint. The same
value must be used when you want to clear the breakpoint.
Unsuccessful 0
Table 30: __setTraceStartBreak return values
Description Sets a breakpoint at the specified location. When that breakpoint is triggered, the trace
system is started.
293
AFE1_AFE2-1:1
Reference information on C-SPY system macros
traceOn()
{
startTraceBp = __setTraceStartBreak
("{C:\\TEMP\\Utilities.c}.23.1");
stopTraceBp = __setTraceStopBreak
("{C:\\temp\\Utilities.c}.30.1");
}
traceOff()
{
__clearBreak(startTraceBp);
__clearBreak(stopTraceBp);
}
__setTraceStopBreak
Syntax __setTraceStopBreak(location)
Parameters location
A string that defines the code location of the breakpoint, either a valid C-SPY
expression whose value evaluates to a valid address, an absolute location, or a
source location. For more information about the location types, see Enter
Location dialog box, page 130.
Return value
Result Value
Successful An unsigned integer uniquely identifying the breakpoint. The same
value must be used when you want to clear the breakpoint.
Unsuccessful int 0
Table 31: __setTraceStopBreak return values
Description Sets a breakpoint at the specified location. When that breakpoint is triggered, the trace
system is stopped.
AFE1_AFE2-1:1
C-SPY macros
__sourcePosition
Syntax __sourcePosition(linePtr, colPtr)
Parameters linePtr
Pointer to the variable storing the line number
colPtr
Pointer to the variable storing the column number
Return value
Result Value
Successful Filename string
Unsuccessful Empty ("") string
Table 32: __sourcePosition return values
Description If the current execution location corresponds to a source location, this macro returns the
filename as a string. It also sets the value of the variables, pointed to by the parameters,
to the line and column numbers of the source location.
__strFind
Syntax __strFind(macroString, pattern, position)
Parameters macroString
A macro string.
pattern
The string pattern to search for
position
The position where to start the search. The first position is 0
Return value The position where the pattern was found or -1 if the string is not found.
295
AFE1_AFE2-1:1
Reference information on C-SPY system macros
Description This macro searches a given string (macroString) for the occurrence of another string
(pattern).
__subString
Syntax __subString(macroString, position, length)
Parameters macroString
A macro string.
position
The start position of the substring. The first position is 0.
length
The length of the substring
Example __subString("Compiler", 0, 2)
__targetDebuggerVersion
Syntax __targetDebuggerVersion()
Return value A string that represents the version number of the C-SPY debugger processor module.
AFE1_AFE2-1:1
C-SPY macros
Description This macro returns the version number of the C-SPY debugger processor module.
__toLower
Syntax __toLower(macroString)
Parameters macroString
A macro string.
Description This macro returns a copy of the parameter macroString where all the characters have
been converted to lower case.
Example __toLower("IAR")
__toString
Syntax __toString(C_string, maxlength)
Parameters C_string
Any null-terminated C string.
maxlength
The maximum length of the returned macro string.
297
AFE1_AFE2-1:1
Reference information on C-SPY system macros
Description This macro is used for converting C strings (char* or char[]) into macro strings.
__toUpper
Syntax __toUpper(macroString)
Parameters macroString
A macro string.
Description This macro returns a copy of the parameter macroString where all the characters have
been converted to upper case.
Example __toUpper("string")
__unloadImage
Syntax __unloadImage(module_id)
Parameters module_id
An integer which represents a unique module identification, which is retrieved
as a return value from the corresponding __loadImage C-SPY macro.
AFE1_AFE2-1:1
C-SPY macros
Return value
Value Result
module_id A unique module identification (the same as the input
parameter).
int 0 The unloading failed.
Table 33: __unloadImage return values
See also Loading multiple images, page 53 and Images, page 340.
__writeFile
Syntax __writeFile(fileHandle, value)
Parameters fileHandle
A macro variable used as filehandle by the __openFile macro.
value
An integer.
Description Prints the integer value in hexadecimal format (with a trailing space) to the file file.
Note: The __fmessage statement can do the same thing. The __writeFile macro is
provided for symmetry with __readFile.
__writeFileByte
Syntax __writeFileByte(fileHandle, value)
Parameters fileHandle
A macro variable used as filehandle by the __openFile macro.
value
An integer.
299
AFE1_AFE2-1:1
Reference information on C-SPY system macros
__writeMemory8, __writeMemoryByte
Syntax __writeMemory8(value, address, zone)
__writeMemoryByte(value, address, zone)
Parameters value
An integer.
address
The memory address (integer).
zone
A string that specifies the memory zone, see C-SPY memory zones, page 134.
__writeMemory16
Syntax __writeMemory16(value, address, zone)
Parameters value
An integer.
address
The memory address (integer).
zone
A string that specifies the memory zone, see C-SPY memory zones, page 134.
AFE1_AFE2-1:1
C-SPY macros
__writeMemory32
Syntax __writeMemory32(value, address, zone)
Parameters value
An integer.
address
The memory address (integer).
zone
A string that specifies the memory zone, see C-SPY memory zones, page 134.
301
AFE1_AFE2-1:1
Graphical environment for macros
Use this window to list, register, and edit your debugger macro files.
Double-click a macro file to open it in the editor window and edit it.
See also Registering C-SPY macros—an overview, page 254.
Requirements
None; this window is always available.
Display area
This area contains these columns:
File
The name of an available macro file. To register the macro file, select the check
box to the left of the filename. The name of a registered macro file appears in
bold style.
Full path
The path to the location of the added macro file.
AFE1_AFE2-1:1
C-SPY macros
Context menu
This context menu is available:
303
AFE1_AFE2-1:1
Graphical environment for macros
Use this window to list all registered debugger macro functions, either predefined
system macros or your own. This window is useful when you edit your own macro
functions and want an overview of all available macros that you can use.
● Click the column headers Name or File to sort alphabetically on either function
name or filename.
● Double-clicking a macro defined in a file opens that file in the editor window.
● To open a macro in the Macro Quicklaunch window, drag it from the Debugger
Macros window and drop it in the Macro Quicklaunch window.
● Select a macro and press F1 to get online help information for that macro.
Requirements
None; this window is always available.
Display area
This area contains these columns:
Name
The name of the debugger macro.
Parameters
The parameters of the debugger macro.
File
For macros defined in a file, the name of the file is displayed. For predefined
system macros, -System Macro- is displayed.
AFE1_AFE2-1:1
C-SPY macros
Context menu
This context menu is available:
305
AFE1_AFE2-1:1
Graphical environment for macros
Requirements
None; this window is always available.
AFE1_AFE2-1:1
C-SPY macros
Display area
This area contains these columns:
Recalculate icon
To evaluate the expression, double-click the icon. The latest evaluated
expression appears in bold style.
Expression
One or several expressions that you want to evaluate. Click <click to add>
to add an expression. If the return value has changed since last time, the value
will be displayed in red.
Result
Shows the return value from the expression evaluation.
Context menu
This context menu is available:
307
AFE1_AFE2-1:1
Graphical environment for macros
AFE1_AFE2-1:1
The C-SPY command line
utility—cspybat
● Using C-SPY in batch mode
STARTING CSPYBAT
1 To start cspybat you must first create a batch file. An easy way to do that is to use one
of the batch files that C-SPY automatically generates when you start C-SPY in the
IDE.
C-SPY generates a batch file projectname.buildconfiguration.cspy.bat every
time C-SPY is initialized. In addition, two more files are generated:
● project.buildconfiguration.general.xcl, which contains options specific
to cspybat.
● project.buildconfiguration.driver.xcl, which contains options specific to
the C-SPY driver you are using.
You can find the files in the directory $PROJ_DIR$\settings. The files contain the
same settings as the IDE, and provide hints about additional options that you can use.
2 To start cspybat, you can use this command line:
project.cspybat.bat [debugfile]
309
AFE1_AFE2-1:1
Using C-SPY in batch mode
Note that debugfile is optional. You can specify it if you want to use a different debug
file than the one that is used in the project.buildconfiguration.general.xcl
file.
OUTPUT
When you run cspybat, these types of output can be produced:
● Terminal output from cspybat itself
All such terminal output is directed to stderr. Note that if you run cspybat from
the command line without any arguments, the cspybat version number and all
available options including brief descriptions are directed to stdout and displayed
on your screen.
● Terminal output from the application you are debugging
All such terminal output is directed to stdout, provided that you have used the
--plugin option. See --plugin, page 331.
● Error return codes
cspybat returns status information to the host operating system that can be tested in
a batch file. For successful, the value int 0 is returned, and for unsuccessful the value
int 1 is returned.
INVOCATION SYNTAX
The invocation syntax for cspybat is:
cspybat processor_DLL driver_DLL debug_file
[cspybat_options] --backend driver_options
Note: In those cases where a filename is required—including the DLL files—you are
recommended to give a full path to the filename.
Parameters
The parameters are:
Parameter Description
processor_DLL The processor-specific DLL file; available in avr\bin.
driver_DLL The C-SPY driver DLL file; available in avr\bin.
debug_file The object file that you want to debug (filename extension d90). See
also --debugfile, page 318.
cspybat_options The command line options that you want to pass to cspybat. Note
that these options are optional. For information about each option,
see Reference information on C-SPY command line options, page 315.
Table 34: cspybat parameters
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
Parameter Description
--backend Marks the beginning of the parameters to the C-SPY driver; all
options that follow will be sent to the driver. Note that this option is
mandatory.
driver_options The command line options that you want to pass to the C-SPY driver.
Note that some of these options are mandatory and some are
optional. For information about each option, see Reference information
on C-SPY command line options, page 315.
Table 34: cspybat parameters (Continued)
311
AFE1_AFE2-1:1
Summary of C-SPY command line options
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
313
AFE1_AFE2-1:1
Summary of C-SPY command line options
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
--64bit_doubles
Syntax --64bit_doubles
Description Use this option to specify that 64-bit doubles are used instead of 32-bit doubles.
Project>Options>General Options>Target>Use 64-bit doubles
--64k_flash
Syntax --64k_flash
Description Use this option to enable 64-Kbytes flash mode for the processor configurations -v2 and
-v3.
--attach_to_running_target
Syntax --attach_to_running_target
315
AFE1_AFE2-1:1
Reference information on C-SPY command line options
Note: This option might not be supported by the combination of C-SPY driver and
device that you are using. If you are using this option with an unsupported combination,
C-SPY produces a message.
Description Use this option to make the debugger attach to a running application at its current
location, without resetting the target system.
If you have defined any breakpoints in your project, the C-SPY driver will set them
during attachment. If the C-SPY driver cannot set them without stopping the target
system, the breakpoints will be disabled. The option also suppresses download and the
Run to option.
Project>Attach to Running Target
--avrone_jtag_clock
Syntax --avrone_jtag_clock=speed
Parameters
speed The JTAG or PDI clock frequency in Hz. Possible values are 0-65535000
Hz in steps of 1000 Hz.
Description Use this option to specify the speed of the debugging interface.
Project>Options>Debugger>Driver>Driver 1>Debug Port>Frequency in kHz
--backend
Syntax --backend {driver options}
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
Description Use this option to send options to the C-SPY driver. All options that follow --backend
will be passed to the C-SPY driver, and will not be processed by cspybat itself.
This option is not available in the IDE.
--code_coverage_file
Syntax --code_coverage_file file
Note that this option must be placed before the --backend option on the command line.
Parameters file
The name of the destination file for the code coverage information.
Description Use this option to enable the generation of a text-based report file for code coverage
information. The code coverage information will be generated after the execution has
completed and you can find it in the specified file. Because most embedded applications
do not terminate, you might have to use this option in combination with --timeout or
--cycles.
Note that this option requires that the C-SPY driver you are using supports code
coverage. If you try to use this option with a C-SPY driver that does not support code
coverage, an error message will be directed to stderr.
See also Code coverage, page 207, --cycles, page 318, --timeout, page 333.
To set this option, choose View>Code Coverage, right-click and choose Save As when
the C-SPY debugger is running.
--cpu
Syntax --cpu=cpu_name
Parameters
cpu_name The CPU model, xm128a1, m2560, tiny441, etc.
317
AFE1_AFE2-1:1
Reference information on C-SPY command line options
Description Use this option to specify the CPU model your application was compiled for. This
option cannot be used together with -v.
Project>Options>General Options>Target>Processor configuration
--cycles
Syntax --cycles cycles
Note that this option must be placed before the --backend option on the command line.
Parameters cycles
The number of cycles to run.
Description Use this option to specify the maximum number of cycles to run. If the target program
executes longer than the number of cycles specified, the target program will be aborted.
Using this option requires that the C-SPY driver you are using supports a cycle counter,
and that it can be sampled while executing.
This option is not available in the IDE.
--debugfile
Syntax --debugfile filename
Parameters filename
The name of the debug file to use.
This option can be placed both before and after the --backend option on the command
line.
Description Use this option to make cspybat use the specified debug file instead of the one used in
the generated cpsybat.bat file.
This option is not available in the IDE.
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
--disable_internal_eeprom
Syntax --disable_internal_eeprom
--disable_interrupts
Syntax --disable_interrupts
--download_only
Syntax --download_only
Note that this option must be placed before the --backend option on the command line.
Description Use this option to download the code image without starting a debug session afterwards.
To set a related option, choose:
Project>Options>Debugger>Setup and deselect Run to.
--drv_communication
Syntax --drv_communication=[COMn|USB]
Parameters
COMn A serial communication port. n can be between 1 and 32. Note that COMn
is not used in AVR ONE! and JTAGICE3.
319
AFE1_AFE2-1:1
Reference information on C-SPY command line options
USB The USB port. Can only be used by the AVR ONE!, JTAGICE mkII,
JTAGICE3, and AVR Dragon drivers.
Description Use this option to specify the communication channel to be used between C-SPY and
the target system.
Project>Options>Debugger>Driver
--drv_communication_log
Syntax --drv_communication_log=filename
Parameters
filename The name of the log file.
Description Use this option to log the communication between C-SPY and the target system to a file.
To interpret the result, detailed knowledge of the communication protocol is required.
Project>Options>Debugger>Atmel-ICE>Communication>Log communication
Project>Options>Debugger>Power Debugger>Communication>Log
communication
Project>Options>Debugger>AVR ONE!>Communication>Log communication
Project>Options>Debugger>JTAGICE3>Communication>Log communication
Project>Options>Debugger>JTAGICE mkII>Serial Port>Log communication
Project>Options>Debugger>Dragon>Communication>Log communication
--drv_debug_port
Syntax --drv_debug_port={autodetect|debugwire|pdi|jtag|tpi|updi}
Parameters
autodetect Specifies auto-detection of the debug interface.
debugwire Specifies the debugWIRE debug interface.
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
--drv_download_data
Syntax --drv_download_data
Description Use this option to enable downloading of constant data into RAM.
Project>Options>Debugger>Driver>Driver 1>Allow download to RAM
--drv_dragon
Syntax --drv_dragon
Description Use this option to specify the AVR Dragon driver to be used.
321
AFE1_AFE2-1:1
Reference information on C-SPY command line options
Project>Options>Debugger>Driver
--drv_power debugger
Syntax --drv_power_debugger
Description Use this option to specify the C-SPY Power Debugger driver to be used.
Project>Options>Debugger>Driver
--drv_preserve_app_section
Syntax --drv_preserve_app_section
Description Use this option to preserve the application area of the flash memory during download.
Project>Options>Debugger>Driver>Driver 2>Preserve FLASH>Application Area
--drv_preserve_boot_section
Syntax --drv_preserve_boot_section
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
Description Use this option to preserve the boot area of the flash memory during download.
Project>Options>Debugger>Driver>Driver 2>Preserve FLASH>Boot Area
--drv_set_exit_breakpoint
Syntax --drv_set_exit_breakpoint
Description Use this option in the CLIB runtime environment to set a system breakpoint on the exit
label. This consumes a hardware breakpoint.
--drv_set_getchar_breakpoint
Syntax --drv_set_getchar_breakpoint
323
AFE1_AFE2-1:1
Reference information on C-SPY command line options
Description Use this option in the CLIB runtime environment to set a system breakpoint on the
getchar label. This consumes a hardware breakpoint.
--drv_set_putchar_breakpoint
Syntax --drv_set_putchar_breakpoint
Description Use this option in the CLIB runtime environment to set a system breakpoint on the
putchar label. This consumes a hardware breakpoint.
--drv_suppress_download
Syntax --drv_suppress_download
Description Use this option to disable the downloading of code, preserving the current contents of
the flash memory.
Project>Options>Debugger>Driver>Driver 1>Suppress download
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
--drv_use_PDI
Syntax --drv_use_PDI
Description Use this option if you want the C-SPY driver to communicate with the device using the
PDI interface.
Project>Options>Debugger>Driver>Driver 1>Use PDI
--drv_verify_download
Syntax --drv_verify_download
Description Use this option to verify that the downloaded code image can be read back from target
memory with the correct contents.
Project>Options>Debugger>Driver>Driver 1>Target Consistency Check>Verify
All
--eeprom_size
Syntax --eeprom_size=size
Parameters
size The size of the built-in EEPROM area in bytes.
Description Use this option to specify the size of the built-in EEPROM area. Do not use together
with --cpu.
Project>Options>General Options>Target>Utilize inbuilt EEPROM
325
AFE1_AFE2-1:1
Reference information on C-SPY command line options
--enhanced_core
Syntax --enhanced_core
Description Use this option to enable the enhanced instruction set; the instructions MOVW, MUL, MULS,
MULSU, FMUL, FMULS, FMULSU, LPM Rd,Z, LPM Rd,Z+, ELPM Rd,Z, ELPM Rd,Z+, and
SPM.
-f
Syntax -f filename
Parameters filename
A text file that contains the command line options (default filename extension
xcl).
This option can be placed either before or after the --backend option on the command
line.
Description Use this option to make cspybat read command line options from the specified file.
In the command file, you format the items exactly as if they were on the command line
itself, except that you may use multiple lines, because the newline character is treated
like a space or tab character.
Both C/C++ style comments are allowed in the file. Double quotes behave in the same
way as in the Microsoft Windows command line environment.
To set this option, use Project>Options>Debugger>Extra Options.
--function_profiling
Syntax --function_profiling filename
Parameters filename
The name of the log file where the profiling data is saved.
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
Description Use this option to find the functions in your source code where the most time is spent
during execution. The profiling information is saved to the specified file. For more
information about function profiling, see Profiling, page 197.
C-SPY driver>Function Profiling
--jtagice_clock
Syntax --jtagice_clock=speed
Parameters
speed The JTAG clock frequency in Hz. Possible values are 0-3570000 Hz.
Description Use this option to specify the speed of the JTAG clock.
Project>Options>Debugger>Driver>Driver 1>JTAG Port>Frequency in Hz
--jtagice_do_hardware_reset
Syntax --jtagice_do_hardware_reset
Description Use this option to make the hardware reset every time the debugger is reset.
Project>Options>Debugger>Driver>Driver 2>Hardware reset on C-SPY reset
327
AFE1_AFE2-1:1
Reference information on C-SPY command line options
--jtagice_leave_timers_running
Syntax --jtagice_leave_timers_running
Description Use this option to ensure that the timers always run, even if the application is stopped.
Project>Options>Debugger>Driver>Driver 2>Run timers in stopped mode
--jtagice_preserve_eeprom
Syntax --jtagice_preserve_eeprom
Description Use this option to preserve the EEPROM contents even if device is reprogrammed.
Project>Options>Debugger>Driver>Driver 2>Preserve EEPROM contents even if
device is reprogrammed
--jtagice_restore_fuse
Syntax --jtagice_restore_fuse
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
Description Use this option to allow the debugger to modify the OCD enable fuse and preserve the
EEPROM fuse at startup. Note that each change of fuse switch decreases the life span
of the chip.
Project>Options>Debugger>Driver>Driver 2>Restore fuses when ending debug
session
--jtagicemkII_use_software_breakpoints
Syntax --jtagicemkII_use_software_breakpoints
--leave_target_running
Syntax --leave_target_running
Description Use this option to make the debugger leave the application running on the target
hardware after the debug session is closed.
329
AFE1_AFE2-1:1
Reference information on C-SPY command line options
Any existing breakpoints will not be automatically removed. You might want to
consider disabling all breakpoints before using this option.
C-SPY driver>Leave Target Running
--macro
Syntax --macro filename
Note that this option must be placed before the --backend option on the command line.
Parameters filename
The C-SPY macro file to be used (filename extension mac).
Description Use this option to specify a C-SPY macro file to be loaded before executing the target
application. This option can be used more than once on the command line.
--macro_param
Syntax --macro_param [param=value]
Note that this option must be placed before the --backend option on the command line.
Description Use this option to assign av value to a C-SPY macro parameter.This option can be used
more than once on the command line.
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
Project>Options>Debugger>Extra Options
-p
Syntax -p filename
Parameters filename
The device description file to be used.
Description Use this option to specify the device description file to be used.
--plugin
Syntax --plugin filename
Note that this option must be placed before the --backend option on the command line.
Parameters filename
The plugin file to be used (filename extension dll).
Description Certain C/C++ standard library functions, for example printf, can be supported by
C-SPY—for example, the C-SPY Terminal I/O window—instead of by real hardware
devices. To enable such support in cspybat, a dedicated plugin module called
avrlibsupportbat.dll located in the avr\bin directory must be used.
Use this option to include this plugin during the debug session. This option can be used
more than once on the command line.
Note: You can use this option to include also other plugin modules, but in that case the
module must be able to work with cspybat specifically. This means that the C-SPY
plugin modules located in the common\plugin directory cannot normally be used with
cspybat.
331
AFE1_AFE2-1:1
Reference information on C-SPY command line options
Project>Options>Debugger>Plugins
--program_fuses_after_download
Syntax --program_fuses_after_download fuse=value[,fuse=value,...]
Parameters
fuse The fuse or lock bit to set a value for. Choose between:
--lock_bits_value
--low_fuse_value
--high_fuse_value
--extended_fuse_value
--fuse_byte0_value
--fuse_byte1_value
--fuse_byte2_value
--fuse_byte4_value
--fuse_byte5_value
value 0x00-0xFF
Description Use this option to write values to device-specific on-chip fuses and lock bits after
downloading your application to the device.
See also For more information about fuse settings, see the device-specific documentation
provided by Microchip Technology.
To set related options, choose C-SPY driver>Fuse Handler.
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
--silent
Syntax --silent
Note that this option must be placed before the --backend option on the command line.
--timeout
Syntax --timeout milliseconds
Note that this option must be placed before the --backend option on the command line.
Parameters milliseconds
The number of milliseconds before the execution stops.
Description Use this option to limit the maximum allowed execution time.
This option is not available in the IDE.
-v
Syntax -v {0|1|2|3|4|5|6}
Parameters
0 A maximum of 256 bytes data and 8 Kbytes code. Default memory model: Tiny.
1 A maximum of 64 Kbytes data and 8 Kbytes code. Default memory model: Tiny.
2 A maximum of 256 bytes data and 128 Kbytes code. Default memory model: Tiny.
3 A maximum of 64 Kbytes data and 128 Kbytes code. Default memory model: Tiny.
4 A maximum of 16 Mbytes data and 128 Kbytes code. Default memory model:
Small.
333
AFE1_AFE2-1:1
Reference information on C-SPY command line options
5 A maximum of 64 Kbytes data and 8 Mbytes code. Default memory model: Small.
6 A maximum of 16 Mbytes data and 8 Mbytes code. Default memory model: Small.
Description Use this option to specify the processor configuration your application was compiled
for. This option cannot be used together with --cpu.
Project>Options>General Options>Target>Processor configuration
AFE1_AFE2-1:1
Part 4. Additional
reference information
This part of the C-SPY® Debugging Guide for AVR includes these chapters:
● Debugger options
335
336
Debugger options
● Setting debugger options
337
AFE1_AFE2-1:1
Reference information on general debugger options
5 To restore all settings to the default factory settings, click the Factory Settings button.
6 When you have set all the required options, click OK in the Options dialog box.
AFE1_AFE2-1:1
Debugger options
Setup
The general Setup options select the C-SPY driver, the setup macro file, and device
description file to use, and specify which default source code location to run to.
Driver
Selects the C-SPY driver for the target system you have.
Run to
Specifies the location C-SPY runs to when the debugger starts after a reset. By default,
C-SPY runs to the main function.
To override the default location, specify the name of a different location you want
C-SPY to run to. You can specify assembler labels or whatever can be evaluated as such,
for example function names.
If the option is deselected, the program counter will contain the regular hardware reset
address at each reset.
See also Executing from reset, page 50.
Setup macros
Registers the contents of a setup macro file in the C-SPY startup sequence. Select Use
macro file and specify the path and name of the setup file, for example
SetupSimple.mac. If no extension is specified, the extension mac is assumed. A
browse button is available for your convenience.
339
AFE1_AFE2-1:1
Reference information on general debugger options
Images
The Images options control the use of additional debug files to be downloaded.
AFE1_AFE2-1:1
Debugger options
Plugins
The Plugins options select the C-SPY plugin modules to be loaded and made available
during debug sessions.
Description
Describes the plugin module.
Location
Informs about the location of the plugin module.
Generic plugin modules are stored in the common\plugins directory. Target-specific
plugin modules are stored in the avr\plugins directory.
Originator
Informs about the originator of the plugin module, which can be modules provided by
IAR Systems or by third-party vendors.
Version
Informs about the version number.
341
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
Atmel-ICE 1
The Atmel-ICE 1 options control the C-SPY driver for Atmel-ICE.
AFE1_AFE2-1:1
Debugger options
Debug Port
Selects the communication type. Choose between:
Auto detect Auto-detects JTAG or PDI. The JTAG Port options are not
available with this setting. A JTAG device must be first in a
JTAG chain.
JTAG Specifies JTAG only mode.
PDI Specifies PDI only mode.
Frequency in Hz Defines the debug port clock speed. You can choose the
value from the drop-down list, or enter a custom value in the
text box. The value is in kHz and can be any value from 1 to
65536. The default value is 100 kHz.
A too small value (less than 28 kHz) might cause the
communication to time out.
A too large value will result in an unexpected error while
debugging, such as an execution/read/write failure.
JTAG Port
Configures the JTAG port.
Target device is part of If the AVR CPU is not alone on the JTAG chain, its position
a JTAG daisy chain in the chain is defined by this option.
Devices Before Specify the number of JTAG data bits before the device in
the JTAG chain.
Devices After Specify the number of JTAG data bits after the device in the
JTAG chain.
Instruction bits Before Specify the number of JTAG instruction register bits before
the device in the JTAG chain.
Instruction bits After Specify the number of JTAG instruction register bits after
the device in the JTAG chain.
343
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
Download control
Controls the download.
AFE1_AFE2-1:1
Debugger options
Atmel-ICE 2
The Atmel-ICE 2 options control the C-SPY driver for Atmel-ICE.
System breakpoints on
Disables the use of system breakpoints in the CLIB runtime environment. If you do not
use the C-SPY Terminal I/O window or if you do not need a breakpoint on the exit
label, you can save hardware breakpoints by not reserving system breakpoints.
Select or deselect the options exit, putchar, and getchar, respectively.
In the DLIB runtime environment, C-SPY will always set a system breakpoint on the
__DebugBreak label. You cannot disable this behavior.
345
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
Preserve FLASH
Selects which part of the flash memory, if any, that you want to preserve during
download. Choose between None, Boot Area, or Application Area.
Communication
The Communication options control the C-SPY driver for Atmel-ICE, AVR ONE!,
JTAGICE3, Dragon, or Power Debugger.
USB
Specifies single emulator mode. Use this option for the USB port and if you have one
device connected to your host computer.
USB ID
Specifies multi-emulator mode. Use this option for the USB port and if you have more
than one device connected to your host computer. Specify the serial number of the
device that you want to connect to, or the USB ID visible in the Log Messages window.
The serial number, for example ONE00737, is printed on the tag underneath the device.
Log communication
Logs the communication between C-SPY and the target system to a file. To interpret the
result, detailed knowledge of the interface is required.
AFE1_AFE2-1:1
Debugger options
Extra Options
The Extra Options page provides you with a command line interface to C-SPY.
/args --verbose
347
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
AVR ONE! 1
The AVR ONE! 1 options control the C-SPY driver for AVR ONE!.
Debug Port
Selects the communication type. Choose between
Auto detect Auto-detects JTAG or PDI. The JTAG Port options are not
available in this mode. A JTAG device must be first in a
JTAG chain.
JTAG Specifies JTAG only mode.
PDI Specifies PDI only mode.
Frequency in Hz Defines the debug port clock speed. You can choose the
value from the drop-down list, or enter a custom value in the
text box. The value is in kHz and can be any value from 1 to
65536. The default value is 100 kHz.
A too small value (less than 28 kHz) might cause the
communication to time out.
A too large value will result in an unexpected error while
debugging, such as an execution/read/write failure.
JTAG Port
Configures the JTAG port.
Target device is part of If the AVR CPU is not alone on the JTAG chain, its position
in the chain is defined by this option.
a JTAG daisy chain
AFE1_AFE2-1:1
Debugger options
Devices Before Specify the number of JTAG data bits before the device in
the JTAG chain.
Devices After Specify the number of JTAG data bits after the device in the
JTAG chain.
Instruction bits Before Specify the number of JTAG instruction register bits before
the device in the JTAG chain.
Instruction bits After Specify the number of JTAG instruction register bits after
the device in the JTAG chain.
Download control
Controls the download.
349
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
AVR ONE! 2
The AVR ONE! 2 options control the C-SPY driver for AVR ONE!.
System breakpoints on
Disables the use of system breakpoints in the CLIB runtime environment. If you do not
use the C-SPY Terminal I/O window or if you do not need a breakpoint on the exit
label, you can save hardware breakpoints by not reserving system breakpoints.
Select or deselect the options exit, putchar, and getchar, respectively.
AFE1_AFE2-1:1
Debugger options
In the DLIB runtime environment, C-SPY will always set a system breakpoint on the
__DebugBreak label. You cannot disable this behavior.
Preserve FLASH
Selects which part of the flash memory, if any, that you want to preserve during
download. Choose between None, Boot Area, or Application Area.
JTAGICE3 1
The JTAGICE3 1 options control the C-SPY driver for JTAGICE3.
Debug Port
Selects the communication type. Choose between
Auto detect Auto-detects JTAG or PDI. The JTAG Port options are not
available with this setting. A JTAG device must be first in a
JTAG chain.
JTAG Specifies JTAG only mode.
PDI Specifies PDI only mode.
351
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
Frequency in Hz Defines the debug port clock speed. You can choose the
value from the drop-down list, or enter a custom value in the
text box. The value is in kHz and can be any value from 1 to
65536. The default value is 100 kHz.
A too small value (less than 28 kHz) might cause the
communication to time out.
A too large value will result in an unexpected error while
debugging, such as an execution/read/write failure.
JTAG Port
Configures the JTAG port.
Target device is part of If the AVR CPU is not alone on the JTAG chain, its position
in the chain is defined by this option.
a JTAG daisy chain
Devices Before Specify the number of JTAG data bits before the device in
the JTAG chain.
Devices After Specify the number of JTAG data bits after the device in the
JTAG chain.
Instruction bits Before Specify the number of JTAG instruction register bits before
the device in the JTAG chain.
Instruction bits After Specify the number of JTAG instruction register bits after
the device in the JTAG chain.
Download control
Controls the download.
AFE1_AFE2-1:1
Debugger options
Allow download to Downloads constant data into RAM. By default, the option
RAM is deselected and an error message is displayed if you try to
download constant data to RAM.
Target consistency Verifies that the memory on the target system is writable
check and mapped in a consistent way. A warning message will
appear if there are any problems during download. Choose
between:
None, target consistency check is not performed.
Verify Boundaries, verifies the boundaries of each
downloaded module. This is a fast and simple, but not
complete, check of the memory.
Verify All, checks every byte after loading. This is a slow,
but complete, check of the memory.
JTAGICE3 2
The JTAGICE3 2 options control the C-SPY driver for JTAGICE3.
353
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
System breakpoints on
Disables the use of system breakpoints in the CLIB runtime environment. If you do not
use the C-SPY Terminal I/O window or if you do not need a breakpoint on the exit
label, you can save hardware breakpoints by not reserving system breakpoints.
Select or deselect the options exit, putchar, and getchar, respectively.
In the DLIB runtime environment, C-SPY will always set a system breakpoint on the
__DebugBreak label. You cannot disable this behavior.
Preserve FLASH
Selects which part of the flash memory, if any, that you want to preserve during
download. Choose between None, Boot Area, or Application Area.
JTAGICE mkII 1
The JTAGICE mkII 1 options control the C-SPY drivers for JTAGICE mkII and
Dragon.
AFE1_AFE2-1:1
Debugger options
Use PDI
Enables communication with the device using the PDI interface.
Communication
Selects the communication type. Choose between:
USB Selects the USB port. Use this setting if you have one AVR
JTAGICE mkII device connected to your host computer.
USB ID Selects the USB port. Use this setting if you have more than
one AVR JTAGICE mkII device connected to your host
computer. Specify the serial number of the device that you
want to connect to. The serial number is printed on the tag
underneath the device.
Serial port Selects the serial port. To configure the serial port, select
the Serial Port page in the Options dialog box and then
choose a port from the Default communication drop-down
list. By default, the COM1 port is used at 38400 baud.
JTAG Port
Configures the JTAG port.
Frequency in Hz Defines the JTAG clock speed. You can choose the value
from the drop-down list, or enter a custom value in the text
box. The value is in Hz and can be any value from 5000 to
1000000. The frequency value is rounded down to nearest
available in the JTAGICE. The default value is 100 kHz.
A too small value (less than 28000) might cause the
communication to time out. The value must not be greater
than 1/4 of the target CPU clock frequency.
A too large value will result in an unexpected error while
debugging, such as an execution/read/write failure.
Target device is part of If the AVR CPU is not alone on the JTAG chain, its position
in the chain is defined by this option.
a JTAG daisy chain
Devices Before Specify the number of JTAG data bits before the device in
the JTAG chain.
Devices After Specify the number of JTAG data bits after the device in the
JTAG chain.
355
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
Instruction bits Before Specify the number of JTAG instruction register bits before
the device in the JTAG chain.
Instruction bits After Specify the number of JTAG instruction register bits after
the device in the JTAG chain.
Download control
Controls the download.
AFE1_AFE2-1:1
Debugger options
JTAGICE mkII 2
The JTAGICE mkII 2 options control the C-SPY drivers for JTAGICE mkII and
Dragon.
System breakpoints on
Disables the use of system breakpoints in the CLIB runtime environment. If you do not
use the C-SPY Terminal I/O window or if you do not need a breakpoint on the exit
label, you can save hardware breakpoints by not reserving system breakpoints.
Select or deselect the options exit, putchar, and getchar, respectively.
In the DLIB runtime environment, C-SPY will always set a system breakpoint on the
__DebugBreak label. You cannot disable this behavior.
357
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
Preserve FLASH
Selects which part of the flash memory, if any, that you want to preserve during
download. Choose between None, Boot Area, or Application Area.
Serial Port
The Serial Port options determine how the serial port should be used.
Default communication
Sets the default communication to use the port you specify and use it at 38400 baud.
Port
Selects one of the supported ports: COM1 (default), COM2, ..., COM32.
Baud
Selects the baud rate.
If the debug session is terminated unexpectedly (by a fatal error, for instance), you might
have to switch the emulator on and off to make it reconnect—first at default rate and then
at the selected rate.
Parity
Selects the parity; only None is allowed.
Data bits
Selects the number of data bits; only 8 data bits is allowed.
AFE1_AFE2-1:1
Debugger options
Stop bits
Selects the number of stop bits: 1 stop bit or 2 stop bits.
Handshaking
Selects the handshaking method, None or RTSCTS.
Log communication
Logs the communication between C-SPY and the target system to a file. To interpret the
result, detailed knowledge of the interface is required.
Dragon 1
The Dragon 1 options control the C-SPY drivers for Dragon.
Use PDI
Enables communication with the device using the PDI interface.
359
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
JTAG Port
Configures the JTAG port.
Frequency in Hz Defines the JTAG clock speed. You can choose the value
from the drop-down list, or enter a custom value in the text
box. The value is in Hz and can be any value from 5000 to
1000000. The frequency value is rounded down to nearest
available in the JTAGICE. The default value is 100 kHz.
A too small value (less than 28000) might cause the
communication to time out. The value must not be greater
than 1/4 of the target CPU clock frequency.
A too large value will result in an unexpected error while
debugging, such as an execution/read/write failure.
Target device is part of If the AVR CPU is not alone on the JTAG chain, its position
in the chain is defined by this option.
a JTAG daisy chain
Devices Before Specify the number of JTAG data bits before the device in
the JTAG chain.
Devices After Specify the number of JTAG data bits after the device in the
JTAG chain.
Instruction bits Before Specify the number of JTAG instruction register bits before
the device in the JTAG chain.
Instruction bits After Specify the number of JTAG instruction register bits after
the device in the JTAG chain.
Download control
Controls the download.
AFE1_AFE2-1:1
Debugger options
Allow download to Downloads constant data into RAM. By default, the option
RAM is deselected and an error message is displayed if you try to
download constant data to RAM.
Target consistency Verifies that the memory on the target system is writable
check and mapped in a consistent way. A warning message will
appear if there are any problems during download. Choose
between:
None, target consistency check is not performed.
Verify Boundaries, verifies the boundaries of each
downloaded module. This is a fast and simple, but not
complete, check of the memory.
Verify All, checks every byte after loading. This is a slow,
but complete, check of the memory.
Dragon 2
The Dragon 2 options control the C-SPY drivers for Dragon.
361
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
System breakpoints on
Disables the use of system breakpoints in the CLIB runtime environment. If you do not
use the C-SPY Terminal I/O window or if you do not need a breakpoint on the exit
label, you can save hardware breakpoints by not reserving system breakpoints.
Select or deselect the options exit, putchar, and getchar, respectively.
In the DLIB runtime environment, C-SPY will always set a system breakpoint on the
__DebugBreak label. You cannot disable this behavior.
Power Debugger 1
The Power Debugger 1 options control the C-SPY driver for Power Debugger.
Debug Port
Selects the communication type. Choose between:
Auto detect Auto-detects JTAG or PDI. The JTAG Port options are not
available with this setting. A JTAG device must be first in a
JTAG chain.
AFE1_AFE2-1:1
Debugger options
JTAG Port
Configures the JTAG port.
Target device is part of If the AVR CPU is not alone on the JTAG chain, its position
a JTAG daisy chain in the chain is defined by this option.
Devices Before Specify the number of JTAG data bits before the device in
the JTAG chain.
Devices After Specify the number of JTAG data bits after the device in the
JTAG chain.
Instruction bits Before Specify the number of JTAG instruction register bits before
the device in the JTAG chain.
Instruction bits After Specify the number of JTAG instruction register bits after
the device in the JTAG chain.
Download control
Controls the download.
363
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
Allow download to Downloads constant data into RAM. By default, the option
RAM is deselected and an error message is displayed if you try to
download constant data to RAM.
Target consistency Verifies that the memory on the target system is writable
check and mapped in a consistent way. A warning message will
appear if there are any problems during download. Choose
between:
None, target consistency check is not performed.
Verify Boundaries, verifies the boundaries of each
downloaded module. This is a fast and simple, but not
complete, check of the memory.
Verify All, checks every byte after loading. This is a slow,
but complete, check of the memory.
Power Debugger 2
The Power Debugger 2 options control the C-SPY driver for Power Debugger.
AFE1_AFE2-1:1
Debugger options
System breakpoints on
Disables the use of system breakpoints in the CLIB runtime environment. If you do not
use the C-SPY Terminal I/O window or if you do not need a breakpoint on the exit
label, you can save hardware breakpoints by not reserving system breakpoints.
Select or deselect the options exit, putchar, and getchar, respectively.
In the DLIB runtime environment, C-SPY will always set a system breakpoint on the
__DebugBreak label. You cannot disable this behavior.
Preserve FLASH
Selects which part of the flash memory, if any, that you want to preserve during
download. Choose between None, Boot Area, or Application Area.
365
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
Suppress download
Disables the downloading of code, while preserving the present content of the flash.
This command is useful if you need to exit C-SPY for a while and then continue the
debug session without downloading code. The implicit RESET performed by C-SPY at
startup is not disabled though.
If this option is combined with Verify all, the debugger will read your application back
from the flash memory and verify that it is identical with the application currently being
debugged.
This option can be used if it is supported by the third-party driver.
Verify all
Verifies that the memory on the target system is writable and mapped in a consistent
way. A warning message will appear if there are any problems during download. Every
byte is checked after it is loaded. This is a slow but complete check of the memory. This
option can be used if is supported by the third-party driver.
Log communication
Logs the communication between C-SPY and the target system to a file. To interpret the
result, detailed knowledge of the interface is required. This option can be used if is
supported by the third-party driver.
AFE1_AFE2-1:1
Additional information on
C-SPY drivers
This chapter describes the additional menus and features provided by the
C-SPY® drivers. You will also find some useful hints about resolving problems.
C-SPY driver
Before you start the C-SPY debugger, you must first specify a C-SPY driver in the
Options dialog box, using the option Debugger>Setup>Driver.
When you start a debug session, a menu specific to that C-SPY driver will appear on the
menu bar, with commands specific to the driver.
When we in this guide write “choose C-SPY driver>” followed by a menu command,
C-SPY driver refers to the menu. If the feature is supported by the driver, the command
will be on the menu.
367
AFE1_AFE2-1:1
Reference information on C-SPY driver menus
Simulator menu
When you use the simulator driver, the Simulator menu is added to the menu bar.
Menu commands
These commands are available on the menu:
Interrupts
Displays a dialog box where you can manage interrupts, see Interrupts dialog
box, page 248.
Trace
Opens a window which displays the collected trace data, see Trace window,
page 164.
Function Trace
Opens a window which displays the trace data for function calls and function
returns, see Function Trace window, page 167.
Trace Expressions
Opens a window where you can specify specific variables and expressions for
which you want to collect trace data, see Trace Expressions window, page 170.
Function Profiler
Opens a window which shows timing information for the functions, see
Function Profiler window, page 202.
Data Log
Opens a window which logs accesses to up to four different memory locations
or areas, see Data Log window, page 188.
Data Log Summary
Opens a window which displays a summary of data accesses to specific memory
location or areas, see Data Log Summary window, page 191.
AFE1_AFE2-1:1
Additional information on C-SPY drivers
Timeline
Opens a window which gives a graphical view of various kinds of information
on a timeline, see The application timeline, page 175.
Breakpoint Usage
Displays a window which lists all active breakpoints, see Breakpoint Usage
window, page 119.
Dragon menu
When you are using the C-SPY Dragon driver, the Dragon menu is added to the menu
bar. Before the debugger is started, the menu looks like this:
369
AFE1_AFE2-1:1
Reference information on C-SPY driver menus
Atmel-ICE menu
When you are using the C-SPY Atmel-ICE driver, the Atmel-ICE menu is added to the
menu bar. Before the debugger is started, the menu looks like this:
AFE1_AFE2-1:1
Additional information on C-SPY drivers
Ending Session Disables Disables the use of debugWire before ending the debug
debugWire session.
Power Debugging This command is not applicable to Atmel-ICE.
Settings
Power Log Setup This command is not applicable to Atmel-ICE.
Power Log This command is not applicable to Atmel-ICE.
State Log Setup This command is not applicable to Atmel-ICE.
State Log This command is not applicable to Atmel-ICE.
State Log Summary This command is not applicable to Atmel-ICE.
Timeline This command is not applicable to Atmel-ICE.
Breakpoint Usage Opens a window which lists all active breakpoints, see
Breakpoint Usage window, page 119.
JTAGICE3 menu
When you are using the C-SPY JTAGICE3 driver, the JTAGICE3 menu is added to the
menu bar. Before the debugger is started, the menu looks like this:
371
AFE1_AFE2-1:1
Reference information on C-SPY driver menus
Breakpoint Usage Opens a window which lists all active breakpoints, see
Breakpoint Usage window, page 119.
Ending Session Disables Disables the use of debugWIRE before ending the debug
debugWire session.
AFE1_AFE2-1:1
Additional information on C-SPY drivers
Breakpoint Usage Opens a window which lists all active breakpoints, see
Breakpoint Usage window, page 119.
Power Debugging Settings Displays a dialog box where you can select which GPIO
input pins to monitor, see Power Debugging Settings,
page 222.
Fuse Handler Displays a dialog box, which provides programming
possibilities of the device-specific on-chip fuses, see
Fuse Handler dialog box, page 377.
Chip Erase Performs a chip erase, that is, erases flash memory,
EEPROM, and lock bits. For more information, see the
documentation for the target you are using.
Ending Session Disables Disables the use of debugWire before ending the debug
debugWire session.
Power Debugging Settings Displays a dialog box; see Power Debugging Settings,
page 222.
373
AFE1_AFE2-1:1
Reference information on the C-SPY hardware debugger drivers
Power Log Setup Opens a window; see Power Log Setup window, page
220.
Power Log Opens a window; see Power Log window, page 226.
State Log Setup Opens a window; see State Log Setup window, page
229.
State Log Opens a window; see State Log window, page 231.
State Log Summary Opens a window; see State Log Summary window, page
233.
Timeline Opens the Timeline window; see Reference
information on application timeline, page 180.
Breakpoint Usage Opens a window which lists all active breakpoints, see
Breakpoint Usage window, page 119.
AFE1_AFE2-1:1
Additional information on C-SPY drivers
Note: To use the fuse handler, the JTAG Enable fuse must be enabled on one of the
pages. If a debugWIRE interface is used, it will be temporarily disabled while using the
fuse handler. Before you start debugging and after programming the fuses, you must
enable the interface again. The JTAGICE mkII/Dragon debugger driver will guide you
through this.
The fuse handler provides programming possibilities of the device-specific on-chip
fuses and lock bits via JTAGICE mkII/Dragon.
Because different devices have different features, the available options and possible
settings depend on which device is selected. However, the available options are divided
into a maximum of four groups: Lock Bits, Low Fuse, High Fuse, and Extended Fuse.
For detailed information about the fuse settings, see the device-specific documentation
provided by Microchip Technology.
When you open the Fuse Handler dialog box, the device-specific fuses are read and the
dialog box will reflect the fuse values.
375
AFE1_AFE2-1:1
Reference information on the C-SPY hardware debugger drivers
Requirements
One of these alternatives:
● The C-SPY JTAGICE mkII driver
● The C-SPY Dragon driver.
Overview
Displays an overview of the fuse settings for each fuse group.
New Value Displays the value of the fuses reflecting the user-defined
settings. In other words, the value of the fuses after they have
been programmed.
Old Value Displays the last read value of the fuses.
Old Value Displays the last read value of the on-chip fuses on the
device.
New Value Displays the value of the fuses reflecting the user-defined
settings. This text field is editable.
To specify the fuse settings, you can either use the New Value text field or use the
options.
Selecting an option means that this fuse should be enabled/programmed, which means
that the on-chip fuse is set to zero.
Device ID
Displays the device ID that has been read from the device.
Read Fuses
Reads the on-chip fuses from the device and the Before text fields will be updated
accordingly.
Program Fuses
Programs the new fuse values—displayed in the After text box—to the on-chip fuses.
AFE1_AFE2-1:1
Additional information on C-SPY drivers
Log Messages
Displays the device information, and status and diagnostic messages for all
read/program operations.
Note: To use the fuse handler, the JTAG Enable fuse must be enabled on one of the tabs
or you can use PDI, see Atmel-ICE 1, page 342, Power Debugger 1, page 362, AVR
ONE! 1, page 348, or JTAGICE3 1, page 351, specifically the information about the
Debug Port option.The debugger driver will guide you through this.
The fuse handler provides programming possibilities of the device-specific on-chip
fuses and lock bits via the debug probe.
Because different devices have different features, the available options and possible
settings depend on which device is selected. However, the available options are divided
into a maximum of six groups: Lock Bits, Fuse 0, Fuse 1, Fuse 2, Fuse 3, and Fuse 4.
377
AFE1_AFE2-1:1
Reference information on the C-SPY hardware debugger drivers
For detailed information about the fuse settings, see the device-specific documentation
provided by Microchip Technology.
When you open the Fuse Handler dialog box, the device-specific fuses are read and the
dialog box will reflect the fuse values.
Requirements
One of these alternatives:
● The C-SPY Atmel-ICE driver
● The C-SPY Power Debugger driver
● The C-SPY AVR ONE! driver
● The C-SPY JTAGICE3 driver.
Device ID
Displays the device ID that has been read from the device.
Overview
Displays an overview of the fuse settings for each fuse group.
New Value Displays the value of the fuses reflecting the user-defined
settings. In other words, the value of the fuses after they have
been programmed.
Old Value Displays the last read value of the fuses.
Old Value Displays the last read value of the on-chip fuses on the
device.
New Value Displays the value of the fuses reflecting the user-defined
settings. This text field is editable.
To specify the fuse settings, you can either use the New Value text field or use the
options.
Selecting an option means that this fuse should be enabled/programmed, which means
that the on-chip fuse is set to zero.
AFE1_AFE2-1:1
Additional information on C-SPY drivers
Read Fuses
Reads the on-chip fuses from the device and the Before text fields will be updated
accordingly.
Program Fuses
Programs the new fuse values—displayed in the After text box—to the on-chip fuses.
Log Messages
Displays the device information, and status and diagnostic messages for all
read/program operations.
Resolving problems
These topics are covered:
● No contact with the target hardware
Debugging using the C-SPY hardware debugger systems requires interaction between
many systems, independent from each other. For this reason, setting up this debug
system can be a complex task. If something goes wrong, it might be difficult to locate
the cause of the problem.
This section includes suggestions for resolving the most common problems that can
occur when debugging with the C-SPY hardware debugger systems.
For problems concerning the operation of the evaluation board, refer to the
documentation supplied with it, or contact your hardware distributor.
379
AFE1_AFE2-1:1
Resolving problems
AFE1_AFE2-1:1
Index
Index
A B
A access (Complex breakpoints option) . . . . . . . . . . . . . . 128 B access (Complex breakpoints option) . . . . . . . . . . . . . . 128
Abort (Report Assert option) . . . . . . . . . . . . . . . . . . . . . . . 81 --attach_to_running_target (C-SPY command line option)315
__abortLaunch (C-SPY system macro) . . . . . . . . . . . . . . . 267 --backend (C-SPY command line option) . . . . . . . . . . . . . 316
absolute location, specifying for a breakpoint . . . . . . . . . . 130 backtrace information
Action (Data breakpoints option) . . . . . . . . . . . . . . . . . . . 129 viewing in Call Stack window . . . . . . . . . . . . . . . . . . . . 75
Add to Watch Window (Symbolic Memory window context batch mode, using C-SPY in . . . . . . . . . . . . . . . . . . . . . . . 309
menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 Baud (debugger option) . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Address Range (Find in Trace option) . . . . . . . . . . . . . . . 173 Big Endian (Memory window context menu) . . . . . . . . . . 142
Allow download to RAM (Atmel-ICE option) . . . . . 344, 364 blocks, in C-SPY macros . . . . . . . . . . . . . . . . . . . . . . . . . 261
Allow download to RAM (AVR ONE! option) . . . . . . . . 349 bold style, in this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Allow download to RAM (Dragon option) . . . . . . . . . . . . 361 Break On Branch/Skip (Dragon menu) . . . . . . . . . . . . . . . 370
Allow download to RAM (JTAGICE mkII option). . . . . . 356 Break On Branch/Skip (JTAGICE mkII menu) . . . . . . . . 369
Allow download to RAM (JTAGICE3 option) . . . . . . . . . 353 Break on Throw (Debug menu) . . . . . . . . . . . . . . . . . . . . . 59
Ambiguous symbol (Resolve Symbol Ambiguity option) . 104 Break on Uncaught Exception (Debug menu) . . . . . . . . . . . 59
application, built outside the IDE . . . . . . . . . . . . . . . . . . . . 52 Break (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
assembler labels, viewing . . . . . . . . . . . . . . . . . . . . . . . . . . 89 breakpoint condition, example . . . . . . . . . . . . . . . . . 115–116
assembler source code, fine-tuning . . . . . . . . . . . . . . . . . . 197 Breakpoint control (Complex breakpoints option) . . . . . . 128
assembler symbols, using in C-SPY expressions . . . . . . . . 87 Breakpoint Usage window . . . . . . . . . . . . . . . . . . . . . . . . 119
assembler variables, viewing . . . . . . . . . . . . . . . . . . . . . . . 89 Breakpoint Usage (Atmel-ICE menu) . . . . . . . . . . . . . . . . 371
assumptions, programming experience . . . . . . . . . . . . . . . . 21 Breakpoint Usage (AVR ONE! menu) . . . . . . . . . . . . . . . 373
Atmel Power Debugger. . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Breakpoint Usage (Dragon menu). . . . . . . . . . . . . . . . . . . 370
Atmel-ICE options . . . . . . . . . . . . . . . . . . . . . . . . . . 342, 345 Breakpoint Usage (JTAGICE mkII menu) . . . . . . . . . . . . 369
Atmel-ICE (C-SPY driver) . . . . . . . . . . . . . . . . . . . . . . . . . 37 Breakpoint Usage (JTAGICE3 menu) . . . . . . . . . . . . . . . 372
menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 Breakpoint Usage (Power Debugger menu) . . . . . . . . . . . 374
Auto Scroll (Timeline window context menu) 183, 186, 224, breakpoints
237 code, example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Auto window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 complex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Autostep settings dialog box . . . . . . . . . . . . . . . . . . . . . . . . 82 example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Autostep (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 connecting a C-SPY macro . . . . . . . . . . . . . . . . . . . . . 256
AVR ONE! options. . . . . . . . . . . . . . . . . . . . . . . . . . 348, 350 consumers of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
AVR ONE! (C-SPY driver) . . . . . . . . . . . . . . . . . . . . . . . . 45 data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
hardware installation . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 data log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 description of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
--avrone_jtag_clock (C-SPY command line option) . . . . . 316 disabling used by Stack window . . . . . . . . . . . . . . . . . 111
icons for in the IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
in Memory window . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
listing all . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
381
AFE1_AFE2-1:1
reasons for using . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Clear Group (Registers User Groups
setting Setup window context menu) . . . . . . . . . . . . . . . . . . . . . . 157
in memory window . . . . . . . . . . . . . . . . . . . . . . . . . 113 Clear trace data (Trace toolbar). . . . . . . . . . . . . . . . . . . . . 164
using system macros . . . . . . . . . . . . . . . . . . . . . . . . 114 Clear (Interrupt Log window context menu) . . . . . . . 232, 235
using the dialog box . . . . . . . . . . . . . . . . . . . . . . . . 112 Clear (Power Log window context menu). . . . . . . . . . . . . 228
single-stepping if not available . . . . . . . . . . . . . . . . . . . 50 __clearBreak (C-SPY system macro) . . . . . . . . . . . . . . . . 269
toggling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 CLIB
types of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 consuming breakpoints . . . . . . . . . . . . . . . . . . . . . . . . 110
useful tips. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 library reference information for . . . . . . . . . . . . . . . . . . 24
Breakpoints dialog box naming convention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 __closeFile (C-SPY system macro) . . . . . . . . . . . . . . . . . 269
Complex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 code breakpoints
Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Data Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 toggling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Immediate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Code Coverage window . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Code Coverage (Disassembly window context menu) . . . . 73
Trace Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 --code_coverage_file (C-SPY command line option) . . . . 317
Trace Stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 code, covering execution of . . . . . . . . . . . . . . . . . . . . . . . 208
Breakpoints window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 command line options . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Browse (Trace toolbar) . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 typographic convention . . . . . . . . . . . . . . . . . . . . . . . . . 25
byte order, setting in Memory window . . . . . . . . . . . . . . . 142 command prompt icon, in this guide . . . . . . . . . . . . . . . . . . 25
Communication (JTAGICE mkII option) . . . . . . . . . . . . . 355
complex breakpoints, overview . . . . . . . . . . . . . . . . . . . . 107
C Complex data (Complex breakpoints option) . . . . . . . . . . 128
C function information, in C-SPY. . . . . . . . . . . . . . . . . . . . 68 computer style, typographic convention . . . . . . . . . . . . . . . 25
C symbols, using in C-SPY expressions . . . . . . . . . . . . . . . 86 conditional statements, in C-SPY macros . . . . . . . . . . . . . 260
C variables, using in C-SPY expressions . . . . . . . . . . . . . . 86 context menu, in windows . . . . . . . . . . . . . . . . . . . . . . . . . 89
Calibrate (Power Debugging Settings option) . . . . . . . . . . 222 conventions, used in this guide . . . . . . . . . . . . . . . . . . . . . . 24
call chain, displaying in C-SPY . . . . . . . . . . . . . . . . . . . . . 68 Copy Window Contents (Disassembly
Call stack information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 window context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Call Stack window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Copy (Debug Log window context menu) . . . . . . . . . . . . . 80
for backtrace information . . . . . . . . . . . . . . . . . . . . . . . . 68 copyright notice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Call Stack (Timeline window context menu) . . . . . . . . . . 183 Core (Cores window) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
__cancelAllInterrupts (C-SPY system macro) . . . . . . . . . 268 cores
__cancelInterrupt (C-SPY system macro) . . . . . . . . . . . . . 268 inspecting state of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Chip Erase (Atmel-ICE menu) . . . . . . . . . . . . . . . . . . . . . 370 Cores window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Chip Erase (JTAGICE3 menu) . . . . . . . . . . . . . . . . . . . . . 372 --cpu (C-SPY command line option). . . . . . . . . . . . . . . . . 317
Chip Erase (Power Debugger menu) . . . . . . . . . . . . . . . . . 373 cspybat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Clear All (Debug Log window context menu) . . . . . . . . . . 80 reading options from file (-f) . . . . . . . . . . . . . . . . . . . . 326
current position, in C-SPY Disassembly window . . . . . . . . 72
AFE1_AFE2-1:1
Index
383
AFE1_AFE2-1:1
Debug (Report Assert option) . . . . . . . . . . . . . . . . . . . . . . . 81 context menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
--debugfile (cspybat option) . . . . . . . . . . . . . . . . . . . . . . . 318 disclaimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
debugger concepts, definitions of . . . . . . . . . . . . . . . . . . . . 32 DLIB
debugger drivers consuming breakpoints . . . . . . . . . . . . . . . . . . . . . . . . 110
simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 naming convention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Debugger Macros window . . . . . . . . . . . . . . . . . . . . . . . . 304 do (macro statement) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
debugger system overview . . . . . . . . . . . . . . . . . . . . . . . . . 33 document conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
debugging projects documentation
externally built applications . . . . . . . . . . . . . . . . . . . . . . 52 overview of guides . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
loading multiple images . . . . . . . . . . . . . . . . . . . . . . . . . 53 overview of this guide . . . . . . . . . . . . . . . . . . . . . . . . . . 21
debugging, RTOS awareness . . . . . . . . . . . . . . . . . . . . . . . 31 Download control (Atmel-ICE option) . . . . . . . . . . . . . . . 344
debugWIRE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369–370 Download control (AVR ONE! option) . . . . . . . . . . . . . . 349
Default communication (Serial Port option) . . . . . . . . . . . 358 Download control (Dragon option) . . . . . . . . . . . . . . . . . . 360
__delay (C-SPY system macro) . . . . . . . . . . . . . . . . . . . . 269 Download control (JTAGICE mkII option) . . . . . . . . . . . 356
Delay (Autostep Settings option) . . . . . . . . . . . . . . . . . . . . 82 Download control (JTAGICE3 option) . . . . . . . . . . . . . . . 352
Delete (Breakpoints window context menu) . . . . . . . . . . . 118 Download control (Power Debugger option) . . . . . . . . . . 363
Device description file (debugger option) . . . . . . . . . . . . . 340 --download_only (C-SPY command line option) . . . . . . . 319
device description files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Dragon options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359, 361
definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Dragon (C-SPY driver) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
memory zones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
modifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Driver (debugger option) . . . . . . . . . . . . . . . . . . . . . . . . . 339
register zone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 __driverType (C-SPY system macro) . . . . . . . . . . . . . . . . 270
Device ID (Fuse Handler option) . . . . . . . . . . . . . . . 376, 378 --drv_communication (C-SPY command line option). . . . 319
Devices After (Atmel-ICE option) . . . . . . . . . . . . . . 343, 363 --drv_communication_log (C-SPY command line option) 320
Devices After (AVR ONE! option) . . . . . . . . . . . . . . . . . . 349 --drv_debug_port (C-SPY command line option) . . . . . . . 320
Devices After (Dragon option) . . . . . . . . . . . . . . . . . . . . . 360 --drv_download_data (C-SPY command line option) . . . . 321
Devices After (JTAGICE mkII option) . . . . . . . . . . . . . . . 355 --drv_dragon (C-SPY command line option) . . . . . . . . . . 321
Devices After (JTAGICE3 option) . . . . . . . . . . . . . . . . . . 352 --drv_power_debugger (C-SPY command line option) . . . 322
Devices Before (Atmel-ICE option) . . . . . . . . . . . . . 343, 363 --drv_preserve_app_section (C-SPY command
Devices Before (AVR ONE! option) . . . . . . . . . . . . . . . . 349 line option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
Devices Before (Dragon option) . . . . . . . . . . . . . . . . . . . . 360 --drv_preserve_boot_section (C-SPY command
Devices Before (JTAGICE mkII option) . . . . . . . . . . . . . 355 line option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
Devices Before (JTAGICE3 option) . . . . . . . . . . . . . . . . . 352 --drv_set_exit_breakpoint (C-SPY command line option) 323
Disable All (Breakpoints window context menu) . . . . . . . 118 --drv_set_getchar_breakpoint
Disable (Breakpoints window context menu) . . . . . . . . . . 118 (C-SPY command line option) . . . . . . . . . . . . . . . . . . . . . 323
__disableInterrupts (C-SPY system macro) . . . . . . . . . . . 270 --drv_set_putchar_breakpoint
--disable_internal_eeprom (C-SPY command line option) 319 (C-SPY command line option) . . . . . . . . . . . . . . . . . . . . . 324
--disable_interrupts (C-SPY command line option) . . . . . 319 --drv_suppress_download (C-SPY command line option) 324
Disassembly window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 --drv_use_PDI (C-SPY command line option) . . . . . . . . . 325
--drv_verify_download (C-SPY command line option) . . 325
AFE1_AFE2-1:1
Index
385
AFE1_AFE2-1:1
filename extensions Fuse Handler (JTAGICE3 menu) . . . . . . . . . . . . . . . . . . . 372
ddf, selecting device description file . . . . . . . . . . . . . . . 51 Fuse Handler (Power Debugger menu) . . . . . . . . . . . . . . . 373
mac, using macro file . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Filename (Memory Restore option) . . . . . . . . . . . . . . . . . 145
Filename (Memory Save option) . . . . . . . . . . . . . . . . . . . 144 G
Fill dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 __getCycleCounter (C-SPY system macro) . . . . . . . . . . . 274
__writeMemory8 (C-SPY system macro) . . . . . . . . . . . . . 272 Go to Source (Breakpoints window context menu) . . . . . . 118
__writeMemory16 (C-SPY system macro) . . . . . . . . . . . . 272 Go to Source (Call Stack window context menu) . . . . . . . . 76
__writeMemory32 (C-SPY system macro) . . . . . . . . . . . . 273 Go To Source (Timeline window context
Find in Trace dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . 172 menu) . . . . . . . . . . . . . . . . . . . . . . . . 183, 187, 225–226, 238
Find in Trace window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Go (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57, 67
Find in Trace (Disassembly window context menu) . . . . . . 75
Find (Memory window context menu) . . . . . . . . . . . . . . . 142
Find (Trace toolbar) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 H
first activation time (interrupt property) Handshaking (debugger option) . . . . . . . . . . . . . . . . . . . . 359
definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 Hardware reset on C-SPY reset (AVR ONE! option) . . . . 350
flash memory, load library module to . . . . . . . . . . . . . . . . 276 Hardware reset on C-SPY reset (Dragon option) . . . . . . . 362
__fmessage (C-SPY macro keyword) . . . . . . . . . . . . . . . . 261 Hardware reset on C-SPY reset (JTAGICE mkII
for (macro statement) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
Format (Registers User Groups hardware setup, power consumption because of . . . . . . . . 216
Setup window context menu) . . . . . . . . . . . . . . . . . . . . . . 157 highlighting, in C-SPY . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Format (Registers window context menu) . . . . . . . . . . . . 155
formats, C-SPY input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Frequency in Hz (Atmel-ICE option) . . . . . . . . . . . . 343, 363
Frequency in Hz (AVR ONE! option) . . . . . . . . . . . . . . . 348
I
IAR debugger driver plugin (debugger option) . . . . . . . . . 366
Frequency in Hz (Dragon option) . . . . . . . . . . . . . . . . . . . 360
icons, in this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Frequency in Hz (JTAGICE mkII option). . . . . . . . . . . . . 355
if else (macro statement) . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Frequency in Hz (JTAGICE3 option) . . . . . . . . . . . . . . . . 352
if (macro statement) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Function Profiler window . . . . . . . . . . . . . . . . . . . . . . . . . 202
Ignore (Report Assert option) . . . . . . . . . . . . . . . . . . . . . . . 81
Function Profiler (Simulator menu) . . . . . . . . . . . . . . . . . 368
Images window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Function Trace window . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Images, loading multiple . . . . . . . . . . . . . . . . . . . . . . . . . . 340
functions
immediate breakpoints, overview . . . . . . . . . . . . . . . . . . . 107
C-SPY running to when starting . . . . . . . . . . . . . . 50, 339
Include (Log File option) . . . . . . . . . . . . . . . . . . . . . . . . . . 80
most time spent in, locating . . . . . . . . . . . . . . . . . . . . . 197
input formats, C-SPY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
--function_profiling (cspybat option) . . . . . . . . . . . . . . . . 326
Input Mode dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Fuse Handler dialog box . . . . . . . . . . . . . . . . . . . . . . 375, 377
input, special characters in Terminal I/O window . . . . . . . . 78
Fuse Handler (Atmel-ICE menu) . . . . . . . . . . . . . . . . . . . 370
installation directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Fuse Handler (AVR ONE! menu) . . . . . . . . . . . . . . . . . . . 372
Instruction bits After (Atmel-ICE option) . . . . . . . . . 343, 363
Fuse Handler (Dragon menu) . . . . . . . . . . . . . . . . . . . . . . 370
Instruction bits After (AVR ONE! option) . . . . . . . . . . . . 349
Fuse Handler (JTAGICE mkII menu) . . . . . . . . . . . . . . . . 369
AFE1_AFE2-1:1
Index
J linker options
typographic convention . . . . . . . . . . . . . . . . . . . . . . . . . 25
JTAG daisy chain (AVR ONE! option) . . . . . . . . . . . . . . 348 consuming breakpoints . . . . . . . . . . . . . . . . . . . . . . . . 110
JTAG daisy chain (Dragon option) . . . . . . . . . . . . . . . . . . 360 Little Endian (Memory window context menu) . . . . . . . . 142
JTAG daisy chain (JTAGICE mkII option) . . . . . . . . . . . 355 __loadImage (C-SPY system macro) . . . . . . . . . . . . . . . . 275
JTAG daisy chain (JTAGICE3 option) . . . . . . . . . . . . . . . 352 loading multiple debug files, list currently loaded . . . . . . . 60
JTAG Port (Atmel-ICE option) . . . . . . . . . . . . . . . . . . . . . 343 loading multiple images . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
JTAG Port (AVR ONE! option) . . . . . . . . . . . . . . . . . . . . 348 Locals window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
JTAG Port (Dragon option) . . . . . . . . . . . . . . . . . . . . . . . 360 log breakpoints, overview . . . . . . . . . . . . . . . . . . . . . . . . . 106
JTAG Port (JTAGICE mkII option) . . . . . . . . . . . . . . . . . 355 Log communication (debugger option) . . . . . . . 346, 359, 366
JTAG Port (JTAGICE3 option) . . . . . . . . . . . . . . . . . . . . 352 Log File dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
JTAG Port (Power Debugger option) . . . . . . . . . . . . . . . . 363 Log Messages (Fuse Handler option) . . . . . . . . . . . . 377, 379
JTAGICE mkII options . . . . . . . . . . . . . . . . . . . . . . . 354, 357 Logging>Set Log file (Debug menu) . . . . . . . . . . . . . . . . . 59
JTAGICE mkII (C-SPY driver) . . . . . . . . . . . . . . . . . . . . . 43 Logging>Set Terminal I/O Log file (Debug menu). . . . . . . 59
loop statements, in C-SPY macros . . . . . . . . . . . . . . . . . . 261
387
AFE1_AFE2-1:1
low-power mode, power consumption during . . . . . . . . . . 214 Motorola, C-SPY output format . . . . . . . . . . . . . . . . . . . . . 34
Move to PC (Disassembly window context menu) . . . . . . . 73
M N
mac (filename extension), using a macro file . . . . . . . . . . . 50
--macro (C-SPY command line option) . . . . . . . . . . . . . . 330 naming conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
macro files, specifying . . . . . . . . . . . . . . . . . . . . . . . . 50, 339 Navigate (Timeline window context menu)182, 186, 224, 237
Macro Quicklaunch window . . . . . . . . . . . . . . . . . . . . . . . 306 New Breakpoint (Breakpoints window context menu) . . . 118
Macro Registration window . . . . . . . . . . . . . . . . . . . . . . . 302 Next Statement (Debug menu) . . . . . . . . . . . . . . . . . . . . . . 58
macro statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 Next Symbol (Symbolic Memory window context menu) 148
macros
executing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
using . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 O
--macro-param (C-SPY command line option) . . . . . . . . . 330 Open Setup Window (Power Log window context menu) 229
main function, C-SPY running to when starting . . . . . 50, 339 Open User Groups Setup Window (Registers window context
Memory Fill (Memory window context menu) . . . . . . . . . 142 menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Memory Restore dialog box . . . . . . . . . . . . . . . . . . . . . . . 144 __openFile (C-SPY system macro) . . . . . . . . . . . . . . . . . . 280
Memory Restore (Memory window context menu) . . . . . 143 Operation (Fill option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Memory Save dialog box . . . . . . . . . . . . . . . . . . . . . . . . . 143 operators, sizeof in C-SPY . . . . . . . . . . . . . . . . . . . . . . . . . 88
Memory Save (Memory window context menu) . . . . . . . . 143 optimizations, effects on variables . . . . . . . . . . . . . . . . . . . 88
Memory window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 options
memory zones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 in the IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
in device description file . . . . . . . . . . . . . . . . . . . . . . . 135 on the command line . . . . . . . . . . . . . . . . . . . . . . 315, 347
__memoryRestore (C-SPY system macro) . . . . . . . . . . . . 276 Options (Stack window context menu) . . . . . . . . . . . . . . . 152
__memoryRestoreFromFile (C-SPY system macro) . . . . . 277 __orderInterrupt (C-SPY system macro). . . . . . . . . . . . . . 281
__memorySave (C-SPY system macro) . . . . . . . . . . . . . . 277 Originator (debugger option) . . . . . . . . . . . . . . . . . . . . . . 341
__memorySaveToFile (C-SPY system macro) . . . . . . . . . 278
Memory>Restore (Debug menu) . . . . . . . . . . . . . . . . . . . . 59
Memory>Save (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . 59 P
menu bar, C-SPY-specific . . . . . . . . . . . . . . . . . . . . . . . . . 57 -p (C-SPY command line option) . . . . . . . . . . . . . . . . . . . 331
__message (C-SPY macro keyword) . . . . . . . . . . . . . . . . 261 __param (C-SPY macro keyword) . . . . . . . . . . . . . . . . . . 259
__messageBoxYesCancel (C-SPY system macro) . . . . . . 279 parameters
__messageBoxYesNo (C-SPY system macro) . . . . . . . . . 279 tracing incorrect values of . . . . . . . . . . . . . . . . . . . . . . . 68
Messages window, amount of output . . . . . . . . . . . . . . . . . 79 typographic convention . . . . . . . . . . . . . . . . . . . . . . . . . 25
migration, from earlier IAR compilers . . . . . . . . . . . . . . . . 23 Parity (debugger option) . . . . . . . . . . . . . . . . . . . . . . . . . . 358
MISRA C part number, of this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 PC (Cores window). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Mixed Mode (Disassembly window context menu) . . . . . . 75 peripheral units
Motorola, C-SPY input format . . . . . . . . . . . . . . . . . . . . . . 31 debugging power consumption for . . . . . . . . . . . . . . . . 211
AFE1_AFE2-1:1
Index
389
AFE1_AFE2-1:1
__readMemory32 (C-SPY system macro) . . . . . . . . . . . . 284 Run timers in stopped mode (JTAGICE3 option) . . . . . . . 353
reference information, typographic convention . . . . . . . . . . 25 Run timers in stopped mode (Power Debugger option). . . 364
Refresh (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Run to Cursor (Call Stack window context menu) . . . . . . . 76
register groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 Run to Cursor (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . 58
predefined, enabling. . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Run to Cursor (Disassembly window context menu) . . . . . 73
Register User Groups Setup window . . . . . . . . . . . . . . . . 156 Run to Cursor, command for executing . . . . . . . . . . . . . . . 68
registered trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Run to (C-SPY option) . . . . . . . . . . . . . . . . . . . . . . . . 50, 339
__registerMacroFile (C-SPY system macro) . . . . . . . . . . 285
Registers window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
registers, displayed in Registers window . . . . . . . . . . . . . 153 S
Remove All Groups (Registers User Save to File (Register User Groups
Groups Setup window context menu) . . . . . . . . . . . . . . . . 157 Setup window context menu) . . . . . . . . . . . . . . . . . . . . . . 157
Remove All (Macro Quicklaunch window Save to File (Registers window context menu) . . . . . . . . . 155
context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 Save (Memory Save option) . . . . . . . . . . . . . . . . . . . . . . . 144
Remove (Macro Quicklaunch window context menu) . . . 307 Save (Trace toolbar) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Remove (Registers User Groups Scale (Viewing Range option) . . . . . . . . . . . . . . . . . . . . . 194
Setup window context menu) . . . . . . . . . . . . . . . . . . . . . . 157 Select All (Debug Log window context menu) . . . . . . . . . . 80
repeat interval (interrupt property), definition of . . . . . . . 244 Select Graphs
Replace (Memory window context menu) . . . . . . . . . . . . 142 (Timeline window context menu) . . . . . . . 183, 187, 226, 238
Report Assert dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Select plugins to load (debugger option) . . . . . . . . . . . . . . 341
Reset (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 serial port setup, hardware drivers . . . . . . . . . . . . . . . . . . 358
__resetFile (C-SPY system macro) . . . . . . . . . . . . . . . . . . 285 Set Data Breakpoint (Memory window context menu) . . . 143
Resolve Source Ambiguity dialog box . . . . . . . . . . . . . . . 131 Set Data Log
Restore fuses when ending debug session (Atmel-ICE Breakpoint (Memory window context menu) . . . . . . . . . . 143
option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345 Set Next Statement (Debug menu) . . . . . . . . . . . . . . . . . . . 59
Restore fuses when ending debug session (AVR ONE! Set Next Statement (Disassembly window context menu) . 74
option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350 __setCodeBreak (C-SPY system macro). . . . . . . . . . . . . . 286
Restore fuses when ending debug session (JTAGICE3 __setComplexBreak (C-SPY system macro) . . . . . . . . . . 287
option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
__setDataBreak (C-SPY system macro) . . . . . . . . . . . . . . 289
Restore fuses when ending debug session (Power Debugger
__setLogBreak (C-SPY system macro) . . . . . . . . . . . . . . 291
option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
__setSimBreak (C-SPY system macro) . . . . . . . . . . . . . . 292
Restore (Memory Restore option) . . . . . . . . . . . . . . . . . . . 145
__setTraceStartBreak (C-SPY system macro) . . . . . . . . . 293
return (macro statement) . . . . . . . . . . . . . . . . . . . . . . . . . . 261
__setTraceStopBreak (C-SPY system macro) . . . . . . . . . . 294
ROM-monitor, definition of . . . . . . . . . . . . . . . . . . . . . . . . 34
setup macro file, registering . . . . . . . . . . . . . . . . . . . . . . . . 50
RTOS awareness debugging . . . . . . . . . . . . . . . . . . . . . . . . 31
setup macro functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
RTOS awareness (C-SPY plugin module) . . . . . . . . . . . . . 31
reserved names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
Run timers in stopped mode (Atmel-ICE option) . . . . . . . 345
Setup macros (debugger option) . . . . . . . . . . . . . . . . . . . . 339
Run timers in stopped mode (AVR ONE! option) . . . . . . 350
Setup (C-SPY options) . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
Run timers in stopped mode (Dragon option) . . . . . . . . . . 361
SFR
Run timers in stopped mode (JTAGICE mkII option). . . . 357
in Registers window. . . . . . . . . . . . . . . . . . . . . . . . . . . 155
AFE1_AFE2-1:1
Index
using as assembler symbols . . . . . . . . . . . . . . . . . . . . . . 87 State Log Summary (Power Debugger menu) . . . . . . . . . . 374
shortcut menu. See context menu State Log window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Show all images (Images window context menu) . . . . . . . . 61 State Log (Power Debugger menu) . . . . . . . . . . . . . . . . . . 374
Show Arguments (Call Stack window context menu) . . . . . 76 State Log (Timeline window context menu) . . . . . . . . . . . 238
Show Cycles (Interrupt Log window context static analysis
menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229, 233, 235 documentation for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Show Numerical Value (Timeline Statics window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
window context menu) . . . . . . . . . . . . . . . . . . . . . . . 187, 225 Status (Cores window) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Show offsets (Stack window context menu) . . . . . . . . . . . 151 stdin and stdout, redirecting to C-SPY window . . . . . . . . . 77
Show only (Image window context menu) . . . . . . . . . . . . . 61 Step Into (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Show Time (Interrupt Log window context Step Into, description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229, 233, 235 Step Out (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Show variables (Stack window context menu) . . . . . . . . . 151 Step Out, description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
--silent (C-SPY command line option) . . . . . . . . . . . . . . . 333 Step Over (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . 58
simulating interrupts, enabling/disabling . . . . . . . . . . . . . 248 Step Over, description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Simulator menu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 step points, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
simulator, introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Stop bits (debugger option) . . . . . . . . . . . . . . . . . . . . . . . . 359
Size (Timeline window context menu) . . . . . . . . . . . 187, 225 Stop Debugging (Debug menu) . . . . . . . . . . . . . . . . . . . . . 58
sizeof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 __strFind (C-SPY system macro) . . . . . . . . . . . . . . . . . . . 295
__smessage (C-SPY macro keyword) . . . . . . . . . . . . . . . . 261 __subString (C-SPY system macro) . . . . . . . . . . . . . . . . . 296
software breakpoints Suppress download
enabling for Atmel-ICE . . . . . . . . . . . . . . . . . . . . . . . . 345 Atmel-ICE option . . . . . . . . . . . . . . . . . . . . . . . . 344, 363
enabling for AVR Dragon . . . . . . . . . . . . . . . . . . 329, 362 AVR ONE! option . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
enabling for AVR ONE! . . . . . . . . . . . . . . . . . . . 329, 350 debugger option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
enabling for JTAGICE mkII . . . . . . . . . . . . . . . . 329, 357 Dragon option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
enabling for JTAGICE3 . . . . . . . . . . . . . . . . . . . . 329, 354 JTAGICE mkII option . . . . . . . . . . . . . . . . . . . . . . . . . 356
enabling for Power Debugger . . . . . . . . . . . . . . . . . . . 365 JTAGICE3 option . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
use of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Symbolic Memory window . . . . . . . . . . . . . . . . . . . . . . . . 146
software delay, power consumption during . . . . . . . . . . . . 213 Symbols window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Solid Graph (Timeline window context menu) . . . . . 187, 225 symbols, using in C-SPY expressions . . . . . . . . . . . . . . . . . 86
__sourcePosition (C-SPY system macro) . . . . . . . . . . . . . 295 System breakpoints on (Atmel-ICE option) . . . . . . . . . . . 345
special function registers (SFR) System breakpoints on (AVR ONE! option) . . . . . . . . . . . 350
in Registers window. . . . . . . . . . . . . . . . . . . . . . . . . . . 155 System breakpoints on (Dragon option) . . . . . . . . . . . . . . 362
using as assembler symbols . . . . . . . . . . . . . . . . . . . . . . 87 System breakpoints on (JTAGICE mkII option) . . . . . . . . 357
Stack window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 System breakpoints on (JTAGICE3 option) . . . . . . . . . . . 354
stack.mac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 System breakpoints on (Power Debugger option) . . . . . . . 365
standard C, sizeof operator in C-SPY . . . . . . . . . . . . . . . . . 88
Start address (Fill option) . . . . . . . . . . . . . . . . . . . . . . . . . 145
Start address (Memory Save option) . . . . . . . . . . . . . . . . . 144
State Log Setup (Power Debugger menu) . . . . . . . . . . . . . 374
391
AFE1_AFE2-1:1
T Toggle Breakpoint (Code) (Disassembly
window context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Toggle Breakpoint (Log) (Call
Target Consistency Check (Atmel-ICE option) . . . . 344, 364
Stack window context menu) . . . . . . . . . . . . . . . . . . . . . . . 76
Target Consistency Check (AVR ONE! option) . . . . . . . . 349
Toggle Breakpoint (Log) (Disassembly
Target Consistency Check (Dragon option) . . . . . . . . . . . 361
window context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Target Consistency Check (JTAGICE mkII
Toggle Breakpoint (Trace Start) (Call
option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
Stack window context menu) . . . . . . . . . . . . . . . . . . . . . . . 77
Target Consistency Check (JTAGICE3 option) . . . . . . . . 353
Toggle Breakpoint (Trace Start) (Disassembly
Target device is part of a JTAG
window context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
daisy chain (Atmel-ICE option) . . . . . . . . . . . . . . . . 343, 363
Toggle Breakpoint (Trace Stop) (Call
Target device is part of a JTAG
Stack window context menu) . . . . . . . . . . . . . . . . . . . . . . . 77
daisy chain (AVR ONE! option) . . . . . . . . . . . . . . . . . . . . 348
Toggle Breakpoint (Trace Stop) (Disassembly
Target device is part of a JTAG
window context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
daisy chain (Dragon option) . . . . . . . . . . . . . . . . . . . . . . . 360
Toggle source (Trace toolbar) . . . . . . . . . . . . . . . . . . . . . . 164
Target device is part of a JTAG
__toLower (C-SPY system macro) . . . . . . . . . . . . . . . . . . 297
daisy chain (JTAGICE mkII option) . . . . . . . . . . . . . . . . . 355
tools icon, in this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Target device is part of a JTAG
daisy chain (JTAGICE3 option) . . . . . . . . . . . . . . . . . . . . 352 __toString (C-SPY system macro) . . . . . . . . . . . . . . . . . . 297
target system, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 33 __toUpper (C-SPY system macro) . . . . . . . . . . . . . . . . . . 298
__targetDebuggerVersion (C-SPY system macro) . . . . . . 296 trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161, 175
Terminal IO Log Files (Terminal IO Log Files option) . . . 78 Trace Expressions window . . . . . . . . . . . . . . . . . . . . . . . . 170
Terminal I/O Log Files dialog box . . . . . . . . . . . . . . . . . . . 78 trace start and stop breakpoints, overview . . . . . . . . . . . . 106
Terminal I/O window . . . . . . . . . . . . . . . . . . . . . . . . . . 69, 77 Trace Start breakpoints dialog box . . . . . . . . . . . . . . . . . . 168
terminology. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Trace Stop breakpoints dialog box . . . . . . . . . . . . . . . . . . 169
Text search (Find in Trace option) . . . . . . . . . . . . . . . . . . 172 Trace window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Third-Party Driver (debugger options) . . . . . . . . . . . . . . . 365 trace (calls), profiling source . . . . . . . . . . . . . . . . . . 198, 203
Time Axis Unit (Timeline trace (flat), profiling source . . . . . . . . . . . . . . . . . . . 198, 204
window context menu) . . . . . . . . . . . . . . . 184, 187, 226, 239 trace, in Timeline window . . . . . . . . . . . . 181, 184, 229, 235
Timeline window . . . . . . . . . . . . . . . . . . . 181, 184, 229, 235 trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Timeline (Power Debugger menu) . . . . . . . . . . . . . . . . . . 374 typographic conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
--timeout (C-SPY command line option) . . . . . . . . . . . . . 333
timer interrupt, example . . . . . . . . . . . . . . . . . . . . . . . . . . 246
timers (Atmel-ICE), running in stopped mode . . . . . . . . . 345
U
timers (AVR ONE!), running in stopped mode . . . . . . . . . 350 UBROF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
timers (Dragon), running in stopped mode . . . . . . . . . . . . 361 Unavailable, C-SPY message . . . . . . . . . . . . . . . . . . . . . . . 89
timers (JTAGICE mkII), running in stopped mode . . . . . . 357 Universal Binary Relocatable Object Format. See UBROF
timers (JTAGICE3), running in stopped mode . . . . . . . . . 353 __unloadImage(C-SPY system macro) . . . . . . . . . . . . . . . 298
timers (Power Debugger), running in stopped mode . . . . . 364 USB
Toggle Breakpoint (Code) (Call Atmel-IVE option . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Stack window context menu) . . . . . . . . . . . . . . . . . . . . . . . 76 AVR ONE! option . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
AFE1_AFE2-1:1
Index
393
AFE1_AFE2-1:1
__loadImage (C-SPY system macro) . . . . . . . . . . . . . . . . 275 __writeMemory8 (C-SPY system macro) . . . . . . . . . . . . . 300
__memoryRestore (C-SPY system macro) . . . . . . . . . . . . 276 __writeMemory16 (C-SPY system macro) . . . . . . . . . . . . 300
__memoryRestoreFromFile (C-SPY system macro) . . . . . 277 __writeMemory32 (C-SPY system macro) . . . . . . . . . . . . 301
__memorySave (C-SPY system macro) . . . . . . . . . . . . . . 277 -f (cspybat option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
__memorySaveToFile (C-SPY system macro) . . . . . . . . . 278 -p (C-SPY command line option) . . . . . . . . . . . . . . . . . . . 331
__message (C-SPY macro keyword) . . . . . . . . . . . . . . . . 261 -v (C-SPY command line option) . . . . . . . . . . . . . . . . . . . 333
__messageBoxYesCancel (C-SPY system macro) . . . . . . 279 --attach_to_running_target (C-SPY command line option)315
__messageBoxYesNo (C-SPY system macro) . . . . . . . . . 279 --avrone_jtag_clock (C-SPY command line option) . . . . . 316
__openFile (C-SPY system macro) . . . . . . . . . . . . . . . . . . 280 --backend (C-SPY command line option) . . . . . . . . . . . . . 316
__orderInterrupt (C-SPY system macro). . . . . . . . . . . . . . 281 --code_coverage_file (C-SPY command line option) . . . . 317
__param (C-SPY macro keyword) . . . . . . . . . . . . . . . . . . 259 --cpu (C-SPY command line option). . . . . . . . . . . . . . . . . 317
__readFile (C-SPY system macro) . . . . . . . . . . . . . . . . . . 282 --cycles (C-SPY command line option) . . . . . . . . . . . . . . 318
__readFileByte (C-SPY system macro) . . . . . . . . . . . . . . 283 --debugfile (cspybat option) . . . . . . . . . . . . . . . . . . . . . . . 318
__readMemoryByte (C-SPY system macro) . . . . . . . . . . . 283 --disable_internal_eeprom (C-SPY command
__readMemory8 (C-SPY system macro) . . . . . . . . . . . . . 283 line option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
__readMemory16 (C-SPY system macro) . . . . . . . . . . . . 284 --disable_interrupts (C-SPY command line option) . . . . . 319
__readMemory32 (C-SPY system macro) . . . . . . . . . . . . 284 --download_only (C-SPY command line option) . . . . . . . 319
__registerMacroFile (C-SPY system macro) . . . . . . . . . . 285 --drv_communication (C-SPY command line option). . . . 319
__resetFile (C-SPY system macro) . . . . . . . . . . . . . . . . . . 285 --drv_communication_log (C-SPY command
__setCodeBreak (C-SPY system macro). . . . . . . . . . . . . . 286 line option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
__setComplexBreak (C-SPY system macro) . . . . . . . . . . 287 --drv_debug_port (C-SPY command line option) . . . . . . . 320
__setDataBreak (C-SPY system macro) . . . . . . . . . . . . . . 289 --drv_download_data (C-SPY command line option) . . . . 321
__setLogBreak (C-SPY system macro) . . . . . . . . . . . . . . 291 --drv_dragon (C-SPY command line option) . . . . . . . . . . 321
__setSimBreak (C-SPY system macro) . . . . . . . . . . . . . . 292 --drv_power_debugger (C-SPY command line option) . . . 322
__setTraceStartBreak (C-SPY system macro) . . . . . . . . . 293 --drv_preserve_app_section (C-SPY command
__setTraceStopBreak (C-SPY system macro) . . . . . . . . . . 294 line option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
__smessage (C-SPY macro keyword) . . . . . . . . . . . . . . . . 261 --drv_preserve_boot_section (C-SPY command
__sourcePosition (C-SPY system macro) . . . . . . . . . . . . . 295 line option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
__strFind (C-SPY system macro) . . . . . . . . . . . . . . . . . . . 295 --drv_set_exit_breakpoint (C-SPY command
line option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
__subString (C-SPY system macro) . . . . . . . . . . . . . . . . . 296
--drv_set_getchar_breakpoint
__targetDebuggerVersion (C-SPY system macro) . . . . . . 296
(C-SPY command line option) . . . . . . . . . . . . . . . . . . . . . 323
__toLower (C-SPY system macro) . . . . . . . . . . . . . . . . . . 297
--drv_set_putchar_breakpoint
__toString (C-SPY system macro) . . . . . . . . . . . . . . . . . . 297
(C-SPY command line option) . . . . . . . . . . . . . . . . . . . . . 324
__toUpper (C-SPY system macro) . . . . . . . . . . . . . . . . . . 298
--drv_suppress_download (C-SPY command
__unloadImage (C-SPY system macro) . . . . . . . . . . . . . . 298 line option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
__var (C-SPY macro keyword) . . . . . . . . . . . . . . . . . . . . . 258 --drv_use_PDI (C-SPY command line option) . . . . . . . . . 325
__writeFile (C-SPY system macro) . . . . . . . . . . . . . . . . . 299 --drv_verify_download (C-SPY command line option) . . 325
__writeFileByte (C-SPY system macro) . . . . . . . . . . . . . . 299 --eeprom_size (C-SPY command line option) . . . . . . . . . 325
__writeMemoryByte (C-SPY system macro) . . . . . . . . . . 300 --enhanced_core (C-SPY command line option) . . . . . . . . 326
AFE1_AFE2-1:1
Index
Numerics
1x Units (Symbolic Memory window context menu) . . . . 148
--64bit_doubles (C-SPY command line option) . . . . . . . . 315
--64k_flash (C-SPY command line option) . . . . . . . . . . . . 315
8x Units (Memory window context menu) . . . . . . . . . . . . 142
395
AFE1_AFE2-1:1