C-SPY® Debugging Guide - FTP Directory Listing

C-SPY® Debugging Guide - FTP Directory Listing
C-SPY® Debugging Guide
for the Texas Instruments
MSP430 Microcontroller Family
UCS430-5
COPYRIGHT NOTICE
© 2010-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,
visualSTATE, IAR KickStart Kit, IAR Experiment!, 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.
Texas Instruments is a registered trademark of Texas Instruments Corporation. MSP430
is a trademark of Texas Instruments Corporation.
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
Fifth edition: March 2017
Part number: UCS430-5
This guide applies to version 7.x of IAR Embedded Workbench® for the Texas
Instruments MSP430 microcontroller family.
Internal reference: M21, Mym8.0, IMAE.
C-SPY® Debugging Guide
2
for MSP430
AFE1_AFE2-1:1
Brief contents
Tables
..................................................................................................................... 21
Preface .................................................................................................................... 23
Part 1. Basic debugging
The IAR C-SPY Debugger
................................................................ 31
........................................................................... 33
Getting started using C-SPY
....................................................................... 43
Executing your application
.......................................................................... 59
Variables and expressions
............................................................................ 79
Breakpoints
........................................................................................................ 103
Memory and registers
.................................................................................. 137
Part 2. Analyzing your application ................................ 175
Trace
..................................................................................................................... 177
The application timeline
Profiling
.............................................................................. 191
................................................................................................................ 221
Code coverage ................................................................................................. 231
Power debugging
............................................................................................ 235
Part 3. Advanced debugging ................................................. 259
Interrupts
............................................................................................................ 261
The advanced cycle counter
State storage
..................................................................... 283
..................................................................................................... 291
The sequencer
................................................................................................. 299
C-SPY macros
................................................................................................. 305
3
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
....................................... 363
Part 4. Additional reference information
............. 387
Debugger options ........................................................................................... 389
Additional information on C-SPY drivers .......................................... 401
Index
C-SPY® Debugging Guide
4
for MSP430
AFE1_AFE2-1:1
..................................................................................................................... 413
Contents
Tables
..................................................................................................................... 21
Preface .................................................................................................................... 23
Who should read this guide ............................................................... 23
Required knowledge .......................................................................... 23
How to use this guide ........................................................................... 23
What this guide contains ..................................................................... 24
Part 1. Basic debugging ..................................................................... 24
Part 2. Analyzing your application .................................................... 24
Part 3. Advanced debugging .............................................................. 25
Part 4. Additional reference information ........................................... 25
Other documentation ........................................................................... 25
User and reference guides .................................................................. 26
The online help system ...................................................................... 26
Web sites ............................................................................................ 27
Document conventions ........................................................................ 27
Typographic conventions ................................................................... 27
Naming conventions .......................................................................... 28
Part 1. Basic debugging
The IAR C-SPY Debugger
................................................................ 31
........................................................................... 33
Introduction to C-SPY .......................................................................... 33
An integrated environment ................................................................. 33
General C-SPY debugger features ..................................................... 34
RTOS awareness ................................................................................ 35
Debugger concepts ................................................................................ 36
C-SPY and target systems .................................................................. 36
The debugger ...................................................................................... 37
The target system ............................................................................... 37
The application ................................................................................... 37
C-SPY debugger systems ................................................................... 37
5
AFE1_AFE2-1:1
The ROM-monitor program ............................................................... 38
Third-party debuggers ........................................................................ 38
C-SPY plugin modules ....................................................................... 38
C-SPY drivers overview ....................................................................... 39
Differences between the C-SPY drivers ........................................... 39
The IAR C-SPY Simulator .................................................................. 40
The C-SPY hardware debugger drivers ........................................ 40
Features .............................................................................................. 41
Communication overview .................................................................. 41
Getting started using C-SPY
....................................................................... 43
Setting up C-SPY .................................................................................... 43
Setting up for debugging .................................................................... 43
Executing from reset .......................................................................... 44
Using a setup macro file ..................................................................... 44
Selecting a device description file ..................................................... 44
Loading plugin modules ..................................................................... 45
Starting C-SPY ......................................................................................... 45
Starting a debug session ..................................................................... 45
Loading executable files built outside of the IDE .............................. 46
Starting a debug session with source files missing ............................ 46
Loading multiple images ................................................................... 47
Editing in C-SPY windows ................................................................ 47
Adapting for target hardware ........................................................... 48
Modifying a device description file ................................................... 48
Initializing target hardware before C-SPY starts ............................... 49
Using predefined C-SPY macros for device support ......................... 50
Reference information on starting C-SPY ................................... 50
C-SPY Debugger main window ......................................................... 50
Images window .................................................................................. 54
Get Alternative File dialog box .......................................................... 55
Device Information window .............................................................. 56
C-SPY® Debugging Guide
6
for MSP430
AFE1_AFE2-1:1
Contents
Executing your application
.......................................................................... 59
Introduction to application execution ........................................... 59
Briefly about application execution ................................................... 59
Source and disassembly mode debugging ......................................... 59
Single stepping ................................................................................... 60
Troubleshooting slow stepping speed ................................................ 63
Running the application ..................................................................... 64
Highlighting ....................................................................................... 64
Viewing the call stack ........................................................................ 65
Terminal input and output .................................................................. 65
Debug logging .................................................................................... 65
Reference information on application execution ..................... 66
Disassembly window ......................................................................... 67
Call Stack window ............................................................................. 71
Terminal I/O window ......................................................................... 73
Terminal I/O Log File dialog box ...................................................... 74
Debug Log window ............................................................................ 75
Log File dialog box ............................................................................ 77
Report Assert dialog box .................................................................... 78
Autostep settings dialog box .............................................................. 78
Variables and expressions
............................................................................ 79
Introduction to working with variables and expressions ...... 79
Briefly about working with variables and expressions ...................... 79
C-SPY expressions ............................................................................. 80
Limitations on variable information .................................................. 82
Working with variables and expressions ...................................... 83
Using the windows related to variables and expressions ................... 83
Viewing assembler variables ............................................................. 84
Reference information on working with variables and
expressions ................................................................................................ 85
Auto window ...................................................................................... 85
Locals window ................................................................................... 87
Watch window ................................................................................... 89
7
AFE1_AFE2-1:1
Live Watch window ........................................................................... 92
Statics window ................................................................................... 94
Quick Watch window ......................................................................... 97
Symbols window .............................................................................. 100
Resolve Symbol Ambiguity dialog box ........................................... 101
Breakpoints
........................................................................................................ 103
Introduction to setting and using breakpoints ........................ 103
Reasons for using breakpoints ......................................................... 103
Briefly about setting breakpoints ..................................................... 103
Breakpoint types .............................................................................. 104
Breakpoint icons .............................................................................. 106
Breakpoints in the C-SPY simulator ................................................ 106
Breakpoints in the C-SPY FET debugger driver ............................. 106
Breakpoint consumers ...................................................................... 107
Setting breakpoints .............................................................................. 109
Various ways to set a breakpoint ..................................................... 109
Toggling a simple code breakpoint .................................................. 109
Setting breakpoints using the dialog box ......................................... 109
Setting a data breakpoint in the Memory window ........................... 111
Setting breakpoints using system macros ........................................ 111
Useful breakpoint hints .................................................................... 112
Reference information on breakpoints ....................................... 114
Breakpoints window ........................................................................ 115
Breakpoint Usage window ............................................................... 117
Code breakpoints dialog box ............................................................ 118
Log breakpoints dialog box .............................................................. 119
Data breakpoints dialog box ............................................................ 121
Data Log breakpoints dialog box ..................................................... 123
Immediate breakpoints dialog box ................................................... 124
Range breakpoints dialog box .......................................................... 125
Conditional breakpoints dialog box ................................................. 127
Advanced Trigger breakpoints dialog box ....................................... 130
Enter Location dialog box ................................................................ 132
C-SPY® Debugging Guide
8
for MSP430
AFE1_AFE2-1:1
Contents
Breakpoint combiner dialog box ...................................................... 133
Resolve Source Ambiguity dialog box ............................................ 134
Memory and registers
.................................................................................. 137
Introduction to monitoring memory and registers ............... 137
Briefly about monitoring memory and registers .............................. 137
C-SPY memory zones ...................................................................... 138
Memory configuration for the C-SPY simulator ............................. 139
Monitoring memory and registers ................................................ 140
Defining application-specific register groups .................................. 141
Monitoring stack usage .................................................................... 142
Reference information on memory and registers .................. 144
Memory window .............................................................................. 145
Memory Save dialog box ................................................................. 149
Memory Restore dialog box ............................................................. 150
Fill dialog box .................................................................................. 151
Symbolic Memory window .............................................................. 152
Stack window ................................................................................... 155
Registers window ............................................................................. 159
Register User Groups Setup window ............................................... 162
SFR Setup window ........................................................................... 164
Edit SFR dialog box ......................................................................... 167
Memory Access Setup dialog box ................................................... 169
Edit Memory Access dialog box ...................................................... 171
Memory Dump dialog box ............................................................... 172
Part 2. Analyzing your application ................................ 175
Trace
..................................................................................................................... 177
Introduction to using trace .............................................................. 177
Reasons for using trace .................................................................... 177
Briefly about trace ............................................................................ 177
Requirements for using trace ........................................................... 178
9
AFE1_AFE2-1:1
Collecting and using trace data ...................................................... 178
Getting started with trace ................................................................. 178
Trace data collection using breakpoints ........................................... 179
Searching in trace data ..................................................................... 179
Browsing through trace data ............................................................ 180
Reference information on trace ..................................................... 180
Trace window ................................................................................... 180
Function Trace window ................................................................... 184
Trace Start breakpoints dialog box .................................................. 185
Trace Stop breakpoints dialog box ................................................... 186
Trace Expressions window .............................................................. 187
Find in Trace dialog box ................................................................. 189
Find in Trace window ...................................................................... 190
The application timeline
.............................................................................. 191
Introduction to analyzing your application’s timeline .......... 191
Briefly about analyzing the timeline ................................................ 191
Requirements for timeline support .................................................. 193
Analyzing your application’s timeline .......................................... 193
Displaying a graph in the Timeline window .................................... 194
Navigating in the graphs .................................................................. 194
Analyzing performance using the graph data .................................. 195
Getting started using data logging ................................................... 196
Getting started using data sampling ................................................. 197
Reference information on application timeline ....................... 197
Timeline window—Call Stack graph .............................................. 198
Timeline window—Data Log graph ............................................... 201
Data Log window ............................................................................. 205
Data Log Summary window ............................................................ 208
Sampled Graphs window ................................................................. 211
Data Sample Setup window ............................................................. 215
Data Sample window ....................................................................... 216
Viewing Range dialog box ............................................................... 218
C-SPY® Debugging Guide
10
for MSP430
AFE1_AFE2-1:1
Contents
Profiling
................................................................................................................ 221
Introduction to the profiler .............................................................. 221
Reasons for using the profiler .......................................................... 221
Briefly about the profiler .................................................................. 221
Requirements for using the profiler ................................................. 222
Using the profiler .................................................................................. 223
Getting started using the profiler on function level ......................... 223
Analyzing the profiling data ............................................................ 224
Getting started using the profiler on instruction level ...................... 225
Reference information on the profiler ........................................ 226
Function Profiler window ................................................................ 226
Code coverage ................................................................................................. 231
Introduction to code coverage ....................................................... 231
Reasons for using code coverage ..................................................... 231
Briefly about code coverage ............................................................ 231
Requirements and restrictions for using code coverage ................... 231
Reference information on code coverage .................................. 231
Code Coverage window ................................................................... 232
Power debugging
............................................................................................ 235
Introduction to power debugging .................................................. 235
Reasons for using power debugging ................................................ 235
Briefly about power debugging ........................................................ 235
Requirements and restrictions for power debugging ....................... 237
Optimizing your source code for power consumption ........ 237
Waiting for device status .................................................................. 238
Software delays ................................................................................ 238
DMA versus polled I/O .................................................................... 238
Low-power mode diagnostics .......................................................... 238
CPU frequency ................................................................................. 239
Detecting mistakenly unattended peripherals .................................. 239
Peripheral units in an event-driven system ...................................... 240
Finding conflicting hardware setups ................................................ 241
11
AFE1_AFE2-1:1
Analog interference .......................................................................... 241
Debugging in the power domain .................................................... 242
Displaying a power profile and analyzing the result ........................ 242
Displaying the power profile on a device without EnergyTrace++ . 243
Detecting unexpected power usage during application execution ... 244
Measuring low power currents ......................................................... 244
Changing the graph resolution ......................................................... 245
Reference information on power debugging ............................ 245
Power Log Setup window ................................................................ 246
Power Log window .......................................................................... 248
Power graph in the Timeline window ............................................. 251
State Log window ............................................................................ 252
State Log Summary window ............................................................ 254
Timeline window—State Log graph ............................................... 257
Part 3. Advanced debugging ................................................. 259
Interrupts
............................................................................................................ 261
Introduction to interrupts ................................................................ 261
Briefly about the interrupt simulation system .................................. 261
Interrupt characteristics .................................................................... 262
Interrupt simulation states ................................................................ 263
C-SPY system macros for interrupt simulation ............................... 264
Target-adapting the interrupt simulation system ............................. 265
Briefly about interrupt logging ........................................................ 265
Using the interrupt system .............................................................. 265
Simulating a simple interrupt ........................................................... 266
Simulating an interrupt in a multi-task system ................................ 267
Getting started using interrupt logging ............................................ 268
Reference information on interrupts ........................................... 268
Interrupt Setup dialog box ................................................................ 269
Edit Interrupt dialog box .................................................................. 271
Forced Interrupt window .................................................................. 272
Interrupt Status window ................................................................... 273
C-SPY® Debugging Guide
12
for MSP430
AFE1_AFE2-1:1
Contents
Interrupt Log window ...................................................................... 275
Interrupt Log Summary window ...................................................... 277
Timeline window—Interrupt Log graph .......................................... 280
The advanced cycle counter
..................................................................... 283
Introduction to the advanced cycle counter ............................. 283
Reasons for using the advanced cycle counter ................................. 283
Briefly about the advanced cycle counter ........................................ 283
Requirements for using the advanced cycle counter ........................ 283
Using the cycle counter applications ........................................... 284
Counting all CPU cycles .................................................................. 284
Measuring the DMA load versus the CPU load ............................... 284
Profiling a specific part of your application ..................................... 285
Measuring the Trigger hits ............................................................... 286
Measuring the number of CPU cycles for a task ............................. 286
Reference information on the advanced cycle counter ....... 287
Advanced Cycle Counter Control window ..................................... 287
State storage
..................................................................................................... 291
Introduction to state storage .......................................................... 291
Reasons for using state storage ........................................................ 291
Briefly about state storage ................................................................ 291
Requirements ................................................................................... 291
Using state storage .............................................................................. 292
Setting up state storage .................................................................... 292
Reference information on state storage ..................................... 293
State Storage Control window ......................................................... 294
State Storage window ...................................................................... 296
The sequencer
................................................................................................. 299
Introduction to the sequencer ........................................................ 299
Reasons for using the sequencer ...................................................... 299
Briefly about the sequencer .............................................................. 299
Requirements for using the sequencer ............................................. 300
13
AFE1_AFE2-1:1
Using the sequencer ............................................................................ 300
Setting up the sequencer (simple setup) ........................................... 300
Setting up the sequencer (advanced setup) ...................................... 300
Using the sequencer to locate a problem ......................................... 301
Reference information on the sequencer .................................. 303
Sequencer Control window ............................................................. 303
C-SPY macros
................................................................................................. 305
Introduction to C-SPY macros ....................................................... 305
Reasons for using C-SPY macros .................................................... 305
Briefly about using C-SPY macros .................................................. 306
Briefly about setup macro functions and files ................................. 306
Briefly about the macro language .................................................... 306
Using C-SPY macros ........................................................................... 307
Registering C-SPY macros—an overview ....................................... 308
Executing C-SPY macros—an overview ......................................... 308
Registering and executing using setup macros and setup files ........ 309
Executing macros using Quick Watch ............................................ 309
Executing a macro by connecting it to a breakpoint ........................ 310
Aborting a C-SPY macro ................................................................. 311
Reference information on the macro language ....................... 312
Macro functions ............................................................................... 312
Macro variables ............................................................................... 312
Macro parameters ............................................................................. 313
Macro strings .................................................................................... 313
Macro statements ............................................................................. 314
Formatted output .............................................................................. 315
Reference information on reserved setup macro function
names ......................................................................................................... 317
execUserPreload ............................................................................... 317
execUserExecutionStarted ............................................................... 318
execUserExecutionStopped ............................................................. 318
execUserSetup .................................................................................. 318
execUserPreReset ............................................................................. 319
C-SPY® Debugging Guide
14
for MSP430
AFE1_AFE2-1:1
Contents
execUserReset .................................................................................. 319
execUserExit .................................................................................... 319
Reference information on C-SPY system macros .................. 319
__abortLaunch ................................................................................. 321
__cancelAllInterrupts ...................................................................... 322
__cancelInterrupt ............................................................................. 322
__clearBreak .................................................................................... 323
__closeFile ....................................................................................... 323
__delay ............................................................................................. 323
__disableInterrupts .......................................................................... 324
__driverType .................................................................................... 324
__enableInterrupts ........................................................................... 325
__evaluate ........................................................................................ 325
__fillMemory8 ................................................................................ 326
__fillMemory16 .............................................................................. 326
__fillMemory32 .............................................................................. 327
__isBatchMode ................................................................................ 328
__loadImage .................................................................................... 329
__memoryRestore ............................................................................ 330
__memorySave ................................................................................ 330
__messageBoxYesCancel ................................................................ 331
__messageBoxYesNo ...................................................................... 332
__openFile ....................................................................................... 332
__orderInterrupt ............................................................................... 334
__popSimulatorInterruptExecutingStack ........................................ 335
__readFile ........................................................................................ 335
__readFileByte ................................................................................. 336
__readMemory8, __readMemoryByte ............................................ 336
__readMemory16 ............................................................................. 337
__readMemory32 ............................................................................. 337
__registerMacroFile ......................................................................... 338
__resetFile ........................................................................................ 338
__setAdvancedTriggerBreak ........................................................... 339
__setCodeBreak ............................................................................... 340
15
AFE1_AFE2-1:1
__setConditionalBreak .................................................................... 341
__setDataBreak ................................................................................ 343
__setDataLogBreak ......................................................................... 344
__setLogBreak ................................................................................. 345
__setRangeBreak ............................................................................. 346
__setSimBreak ................................................................................. 347
__setTraceStartBreak ....................................................................... 348
__setTraceStopBreak ....................................................................... 349
__sourcePosition .............................................................................. 350
__strFind .......................................................................................... 350
__subString ...................................................................................... 351
__targetDebuggerVersion ................................................................ 351
__toLower ........................................................................................ 352
__toString ........................................................................................ 352
__toUpper ........................................................................................ 353
__unloadImage ................................................................................ 353
__writeFile ....................................................................................... 354
__writeFileByte ............................................................................... 354
__writeMemory8, __writeMemoryByte ......................................... 355
__writeMemory16 ........................................................................... 355
__writeMemory32 ........................................................................... 356
Graphical environment for macros .............................................. 356
Macro Registration window ............................................................. 357
Debugger Macros window ............................................................... 359
Macro Quicklaunch window ............................................................ 361
The C-SPY command line utility—cspybat
....................................... 363
Using C-SPY in batch mode ............................................................. 363
Starting cspybat ................................................................................ 363
Output ............................................................................................... 364
Invocation syntax ............................................................................. 364
Summary of C-SPY command line options .............................. 365
General cspybat options ................................................................... 365
Options available for all C-SPY drivers .......................................... 366
C-SPY® Debugging Guide
16
for MSP430
AFE1_AFE2-1:1
Contents
Options available for the simulator driver ....................................... 366
Options available for the C-SPY FET Debugger driver .................. 366
Reference information on C-SPY command line options ... 367
--allow_access_to_BSL ................................................................... 368
--allow_locked_flash_access ........................................................... 368
--attach_to_running_target ............................................................... 368
--backend .......................................................................................... 369
--connection ..................................................................................... 369
--core ................................................................................................ 369
--code_coverage_file ........................................................................ 370
--cycles ............................................................................................. 370
-d ...................................................................................................... 371
--debugfile ........................................................................................ 371
--derivative ....................................................................................... 372
--disable_interrupts .......................................................................... 372
--disable_memory_cache ................................................................. 372
--downloadonly ................................................................................ 372
--eem ................................................................................................ 373
--erase_exclude ................................................................................ 374
--erase_ip_protected ......................................................................... 374
--erase_main ..................................................................................... 374
--erase_main_and_info ..................................................................... 375
--erase_retain_file ............................................................................ 375
--erase_retain_target ......................................................................... 375
-f ....................................................................................................... 376
--function_profiling .......................................................................... 376
--hardware_multiplier ...................................................................... 377
--hwmult_type .................................................................................. 377
--jtag_speed ...................................................................................... 378
--leave_target_running ..................................................................... 378
--lptx ................................................................................................. 379
--macro ............................................................................................. 379
--macro_param ................................................................................. 380
--mapu .............................................................................................. 380
17
AFE1_AFE2-1:1
--odd_word_check ........................................................................... 380
-p ...................................................................................................... 381
--plugin ............................................................................................. 381
--port ................................................................................................. 382
--protocol .......................................................................................... 382
--set_exit_breakpoint ....................................................................... 383
--set_getchar_breakpoint .................................................................. 383
--set_putchar_breakpoint ................................................................. 383
--settlingtime .................................................................................... 383
--silent .............................................................................................. 384
--timeout ........................................................................................... 384
--use_emulated_breakpoints ............................................................ 384
--use_virtual_breakpoints ................................................................. 385
--vccvoltage ...................................................................................... 385
--verify_all ....................................................................................... 385
Part 4. Additional reference information
............. 387
Debugger options ........................................................................................... 389
Setting debugger options .................................................................. 389
Reference information on general debugger options ........... 390
Setup ................................................................................................. 390
Images .............................................................................................. 391
Plugins .............................................................................................. 392
Extra Options ................................................................................... 393
Reference information on the C-SPY simulator ..................... 394
Setup options for the simulator ....................................................... 394
Reference information on C-SPY hardware debugger driver
options ....................................................................................................... 395
Setup for FET Debugger .................................................................. 395
Download ......................................................................................... 397
Breakpoints ..................................................................................... 398
C-SPY® Debugging Guide
18
for MSP430
AFE1_AFE2-1:1
Contents
Additional information on C-SPY drivers .......................................... 401
Reference information on C-SPY driver menus ..................... 401
C-SPY driver .................................................................................... 401
Simulator menu ................................................................................ 402
Emulator menu ................................................................................. 404
Reference information on the C-SPY simulator ..................... 407
Simulated Frequency dialog box ...................................................... 408
Reference information on the C-SPY FET Debugger
driver .......................................................................................................... 408
General Clock Control dialog box ................................................... 408
Extended Clock Control dialog box ................................................. 409
Resolving problems .............................................................................. 409
The device port pins do not work ..................................................... 410
Write failure during load .................................................................. 410
No contact with the target hardware ................................................ 411
Index
..................................................................................................................... 413
19
AFE1_AFE2-1:1
C-SPY® Debugging Guide
20
for MSP430
AFE1_AFE2-1:1
Tables
1: Typographic conventions used in this guide ......................................................... 27
2: Naming conventions used in this guide ................................................................ 28
3: Driver differences .................................................................................................. 39
4: C-SPY assembler symbols expressions ................................................................ 81
5: Handling name conflicts between hardware registers and assembler labels ......... 81
6: C-SPY macros for breakpoints ............................................................................ 112
7: Support for timeline information ........................................................................ 193
8: Supported graphs in the Timeline window ......................................................... 193
9: C-SPY driver profiling support ........................................................................... 223
10: Project options for enabling the profiler ........................................................... 223
11: Project options for enabling code coverage ...................................................... 232
12: Timer interrupt settings ..................................................................................... 267
13: Cycle Counter 1, combinations of start, stop, and clear reactions .................... 289
14: Sequencer settings - example ............................................................................ 302
15: State Storage Control settings—example .......................................................... 302
16: Examples of C-SPY macro variables ................................................................ 313
17: Summary of system macros .............................................................................. 319
18: __cancelInterrupt return values ......................................................................... 322
19: __disableInterrupts return values ...................................................................... 324
20: __driverType return values ............................................................................... 324
21: __enableInterrupts return values ....................................................................... 325
22: __evaluate return values ................................................................................... 325
23: __isBatchMode return values ........................................................................... 328
24: __loadImage return values ................................................................................ 329
25: __messageBoxYesCancel return values ........................................................... 332
26: __messageBoxYesNo return values ................................................................. 332
27: __openFile return values ................................................................................... 333
28: __readFile return values ................................................................................... 335
29: __setAdvancedTriggerBreak return values ....................................................... 340
30: __setCodeBreak return values .......................................................................... 341
31: __setConditionalBreak return values ................................................................ 342
21
AFE1_AFE2-1:1
32: __setDataBreak return values ........................................................................... 343
33: __setDataLogBreak return values ..................................................................... 344
34: __setLogBreak return values ............................................................................ 345
35: __setRangeBreak return values ........................................................................ 347
36: __setSimBreak return values ............................................................................ 348
37: __setTraceStartBreak return values .................................................................. 348
38: __setTraceStopBreak return values .................................................................. 349
39: __sourcePosition return values ......................................................................... 350
40: __unloadImage return values ............................................................................ 354
41: cspybat parameters ............................................................................................ 364
42: Options specific to the C-SPY drivers you are using ........................................ 389
C-SPY® Debugging Guide
22
for MSP430
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 MSP430 microcontroller.
Who should read this guide
Read this guide if you plan to develop an application using IAR Embedded Workbench
and want to get the most out of the features available in C-SPY.
REQUIRED KNOWLEDGE
To use the tools in IAR Embedded Workbench, you should have working knowledge of:
●
The architecture and instruction set of the MSP430 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 25.
How to use this guide
Each chapter in this guide covers a specific topic area. In many chapters, information is
typically divided in different sections based on information types:
●
Concepts, which describes the topic and gives overviews of features related to the
topic area. Any requirements or restrictions are also listed. Read this section to learn
about the topic area.
●
Tasks, which lists useful tasks related to the topic area. For many of the tasks, you
can also find step-by-step descriptions. Read this section for information about
required tasks as well as for information about how to perform certain tasks.
●
Reference information, which gives reference information related to the topic area.
Read this section for information about certain GUI components. You can easily
access this type of information for a certain component in the IDE by pressing F1.
23
AFE1_AFE2-1:1
What this guide contains
If you are new to using IAR Embedded Workbench, we suggest that you first read the
guide Getting Started with IAR Embedded Workbench® for an overview of the tools and
the features that the IDE offers. The tutorials, which you can find in the IAR Information
Center, will help you get started using IAR Embedded Workbench.
Finally, we recommend the Glossary if you should encounter any unfamiliar terms in
the IAR Systems user documentation.
What this guide contains
Below is a brief outline and summary of the chapters in this guide.
Note: Some of the screenshots in this guide are taken from a similar product and not
from IAR Embedded Workbench for MSP430.
PART 1. BASIC DEBUGGING
●
The IAR C-SPY Debugger introduces you to the C-SPY debugger and to the
concepts that are related to debugging in general and to C-SPY in particular. The
chapter also introduces the various C-SPY drivers. The chapter briefly shows the
difference in functionality that the various C-SPY drivers provide.
●
Getting started using C-SPY helps you get started using C-SPY, which includes
setting up, starting, and adapting C-SPY for target hardware.
●
Executing your application describes the conceptual differences between source
and disassembly mode debugging, the facilities for executing your application, and
finally, how you can handle terminal input and output.
●
Variables and expressions describes the syntax of the expressions and variables
used in C-SPY, as well as the limitations on variable information. The chapter also
demonstrates the various methods for monitoring variables and expressions.
●
Breakpoints describes the breakpoint system and the various ways to set
breakpoints.
●
Memory and registers shows how you can examine memory and registers.
PART 2. ANALYZING YOUR APPLICATION
C-SPY® Debugging Guide
24
for MSP430
AFE1_AFE2-1:1
●
Trace describes how you can inspect the program flow up to a specific state using
trace data.
●
The application timeline describes the Timeline window, and how to use the
information in it to analyze your application’s behavior.
●
Profiling describes how the profiler can help you find the functions in your
application source code where the most time is spent during execution.
Preface
●
Code coverage describes how the code coverage functionality can help you verify
whether all parts of your code have been executed, thus identifying parts which have
not been executed.
●
Power debugging describes techniques for power debugging and how you can use
C-SPY to find source code constructions that result in unexpected power
consumption.
PART 3. ADVANCED DEBUGGING
●
Interrupts contains detailed information about the C-SPY interrupt simulation
system and how to configure the simulated interrupts to make them reflect the
interrupts of your target hardware.
●
The advanced cycle counter describes the advanced cycle counter for MSP430
devices, and how it can help you to profile your application or to measure how long
some tasks take.
●
State storage describes how the state storage module can help you to examine how
your code is executed, and find problems in a specific stage of the execution.
●
The sequencer describes the sequencer module, a simple state machine that lets you
break the execution or trigger the state storage module using a more complex
method than a standard breakpoint.
●
C-SPY macros describes the C-SPY macro system, its features, the purposes of
these features, and how to use them.
●
The C-SPY command line utility—cspybat describes how to use C-SPY in batch
mode.
PART 4. ADDITIONAL REFERENCE INFORMATION
●
Debugger options describes the options you must set before you start the C-SPY
debugger.
●
Additional information on C-SPY drivers describes menus and features provided by
the C-SPY drivers not described in any dedicated topics.
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.
25
AFE1_AFE2-1:1
Other documentation
USER AND REFERENCE GUIDES
The complete set of IAR Systems development tools is described in a series of guides.
Information about:
●
System requirements and information about how to install and register the IAR
Systems products, is available in the booklet Quick Reference (available in the
product box) and the Installation and Licensing Guide.
●
Getting started using IAR Embedded Workbench and the tools it provides, is
available in the guide Getting Started with IAR Embedded Workbench®.
●
Using the IDE for project management and building, is available in the IDE Project
Management and Building Guide.
●
Using the IAR C-SPY® Debugger, is available in the C-SPY® Debugging Guide
for MSP430.
●
Programming for the IAR C/C++ Compiler for MSP430, is available in the IAR
C/C++ Compiler User Guide for MSP430.
●
Using the IAR XLINK Linker, the IAR XAR Library Builder, and the IAR XLIB
Librarian, is available in the IAR Linker and Library Tools Reference Guide.
●
Programming for the IAR Assembler for MSP430, is available in the IAR Assembler
Reference Guide for MSP430.
●
Performing a static analysis using C-STAT and the required checks, is available in
the C-STAT® Static Analysis Guide.
●
Developing safety-critical applications using the MISRA C guidelines, is available
in the IAR Embedded Workbench® MISRA C:2004 Reference Guide or the IAR
Embedded Workbench® MISRA C:1998 Reference Guide.
●
Porting application code and projects created with a previous version of the IAR
Embedded Workbench for MSP430, is available in the IAR Embedded Workbench®
Migration Guide.
Note: Additional documentation might be available depending on your product
installation.
THE ONLINE HELP SYSTEM
The context-sensitive online help contains:
C-SPY® Debugging Guide
26
for MSP430
AFE1_AFE2-1:1
●
Information about project management, editing, and building in the IDE
●
Information about debugging using the IAR C-SPY® Debugger
●
Reference information about the menus, windows, and dialog boxes in the IDE
●
Compiler reference information
●
Keyword reference information for the DLIB library functions. To obtain reference
information for a function, select the function name in the editor window and press
Preface
F1. Note that if you select a function name in the editor window and press F1 while
using the CLIB C standard library, you will get reference information for the DLIB
C/EC++ standard library.
WEB SITES
Recommended web sites:
●
The Texas Instruments web site, www.ti.com, that contains information and news
about the MSP430 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 430\doc, the full
path to the location is assumed, for example c:\Program Files\IAR
Systems\Embedded Workbench N.n\430\doc, where the initial digit of the version
number reflects the initial digit of the version number of the IAR Embedded Workbench
shared components.
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.
Table 1: Typographic conventions used in this guide
27
AFE1_AFE2-1:1
Document conventions
Style
Used for
[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.
Table 1: Typographic conventions used in this guide (Continued)
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 MSP430
IAR Embedded Workbench®
IAR Embedded Workbench® IDE for MSP430
the IDE
IAR C-SPY® Debugger for MSP430
C-SPY, the debugger
IAR C-SPY® Simulator
the simulator
IAR C/C++ Compiler™ for MSP430
the compiler
IAR Assembler™ for MSP430
the assembler
IAR XLINK Linker™
XLINK, the linker
IAR XAR Library Builder™
the library builder
Table 2: Naming conventions used in this guide
C-SPY® Debugging Guide
28
for MSP430
AFE1_AFE2-1:1
Preface
Brand name
Generic term
IAR XLIB Librarian™
the librarian
IAR DLIB Runtime Environment™
the DLIB runtime environment
IAR CLIB Runtime Environment™
the CLIB runtime environment
Table 2: Naming conventions used in this guide (Continued)
29
AFE1_AFE2-1:1
Document conventions
C-SPY® Debugging Guide
30
for MSP430
AFE1_AFE2-1:1
Part 1. Basic debugging
This part of the C-SPY® Debugging Guide for MSP430 includes these chapters:
●
The IAR C-SPY Debugger
●
Getting started using C-SPY
●
Executing your application
●
Variables and expressions
●
Breakpoints
●
Memory and registers
31
32
The IAR C-SPY Debugger
●
Introduction to C-SPY
●
Debugger concepts
●
C-SPY drivers overview
●
The IAR C-SPY Simulator
●
The C-SPY hardware debugger drivers
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
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.
33
AFE1_AFE2-1:1
Introduction to C-SPY
GENERAL C-SPY DEBUGGER FEATURES
Because IAR Systems provides an entire toolchain, the output from the compiler and
linker can include extensive debug information for the debugger, resulting in good
debugging possibilities for you.
C-SPY offers these general features:
●
Source and disassembly level debugging
C-SPY allows you to switch between source and disassembly debugging as required,
for both C or C++ and assembler source code.
●
Single-stepping on a function call level
Compared to traditional debuggers, where the finest granularity for source level
stepping is line by line, C-SPY provides a finer level of control by identifying every
statement and function call as a step point. This means that each function call—
inside expressions, and function calls that are part of parameter lists to other
functions—can be single-stepped. The latter is especially useful when debugging
C++ code, where numerous extra function calls are made, for example to object
constructors.
●
Code and data breakpoints
The C-SPY breakpoint system lets you set breakpoints of various kinds in the
application being debugged, allowing you to stop at locations of particular interest.
For example, you set breakpoints to investigate whether your program logic is correct
or to investigate how and when the data changes.
●
Monitoring variables and expressions
For variables and expressions there is a wide choice of facilities. You can easily
monitor values of a specified set of variables and expressions, continuously or on
demand. You can also choose to monitor only local variables, static variables, etc.
●
Container awareness
When you run your application in C-SPY, you can view the elements of library data
types such as STL lists and vectors. This gives you a very good overview and
debugging opportunities when you work with C++ STL containers.
●
Call stack information
The compiler generates extensive call stack information. This allows the debugger to
show, without any runtime penalty, the complete stack of function calls wherever the
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
C-SPY® Debugging Guide
34
for MSP430
AFE1_AFE2-1:1
The IAR C-SPY Debugger
conjunction with complex breakpoints and—if you are using the simulator—the
interrupt simulation system to perform a wide variety of tasks.
Additional general C-SPY debugger features
This list shows some additional features:
●
Threaded execution keeps the IDE responsive while running the target application
●
Automatic stepping
●
The source browser provides easy navigation to functions, types, and variables
●
Extensive type recognition of variables
●
Configurable registers (CPU and peripherals) and memory windows
●
Graphical stack view with overflow detection
●
Support for code coverage and function level profiling
●
The target application can access files on the host PC using file I/O (requires the
DLIB library)
●
UBROF, Intel-Standard, Intel-extended, Motorola, and TI msp430-txt input formats
supported
●
Optional terminal I/O emulation.
RTOS AWARENESS
C-SPY supports RTOS-aware debugging.
These operating systems are currently supported:
●
CMX
●
FreeRTOS, OpenRTOS, and SafeRTOS
●
Micrium uC/OS-II
●
Micrium uC/OS-III
●
OSEK
●
Segger embOS
●
TI-RTOS
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.
35
AFE1_AFE2-1:1
Debugger concepts
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
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
C-SPY AND TARGET SYSTEMS
You can use C-SPY to debug either a software target system or a hardware target system.
C-SPY® Debugging Guide
36
for MSP430
AFE1_AFE2-1:1
The IAR C-SPY Debugger
This figure gives an overview of C-SPY and possible target systems:
Note: In IAR Embedded Workbench for MSP430, there are no ROM-monitor drivers.
THE DEBUGGER
The debugger, for instance C-SPY, is the program that you use for debugging your
applications on a target system.
THE TARGET SYSTEM
The target system is the system on which you execute your application when you are
debugging it. The target system can consist of hardware, either an evaluation board or
your own hardware design. It can also be completely or partially simulated by software.
Each type of target system needs a dedicated C-SPY driver.
THE APPLICATION
A user application is the software you have developed and which you want to debug
using C-SPY.
C-SPY DEBUGGER SYSTEMS
C-SPY consists of both a general part which provides a basic set of debugger features,
and a target-specific back end. The back end consists of two components: a processor
module—one for every microcontroller, which defines the properties of the
37
AFE1_AFE2-1:1
Debugger concepts
microcontroller, and a C-SPY driver. The C-SPY driver is the part that provides
communication with and control of the target system. The driver also provides the user
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 the available C-SPY
drivers and the functionality provided by each driver, see C-SPY drivers overview, page
39.
THE ROM-MONITOR PROGRAM
The ROM-monitor program is a piece of firmware that is loaded to non-volatile memory
on your target hardware; it runs in parallel with your application. The ROM-monitor
communicates with the debugger and provides services needed for debugging the
application, for instance stepping and breakpoints.
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, TI msp430-txt, 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.
C-SPY PLUGIN MODULES
C-SPY is designed as a modular architecture with an open SDK that can be used for
implementing additional functionality to the debugger in the form of plugin modules.
These modules can be seamlessly integrated in the IDE.
Plugin modules are provided by IAR Systems, or can be supplied by third-party vendors.
Examples of such modules are:
C-SPY® Debugging Guide
38
for MSP430
AFE1_AFE2-1:1
●
Code Coverage, which is integrated in the IDE.
●
The various C-SPY drivers for debugging using certain debug systems.
●
RTOS plugin modules for support for real-time OS aware debugging.
●
C-SPYLink that bridges IAR visualSTATE and IAR Embedded Workbench to make
true high-level state machine debugging possible directly in C-SPY, in addition to
The IAR C-SPY Debugger
the normal C level symbolic debugging. For more information, see the
documentation provided with IAR visualSTATE.
For more information about the C-SPY SDK, contact IAR Systems.
C-SPY drivers overview
At the time of writing this guide, the IAR C-SPY Debugger for the MSP430
microcontrollers is available with drivers for these target systems and evaluation boards:
●
Simulator
●
FET Debugger.
DIFFERENCES BETWEEN THE C-SPY DRIVERS
This table summarizes the key differences between the C-SPY drivers:
Feature
Simulator
FET Debugger
Code breakpoints
Unlimited
Yes1
Data breakpoints
Yes
—
Execution in real time
—
Yes
Zero memory footprint
Yes
Yes
Simulated interrupts
Yes
—
Real interrupts
—
Yes
Interrupt logging
Yes
—
Data logging
Yes
—
Live watch
Yes
—
Cycle counter
Yes
Yes1
Code coverage
Yes
—
Data coverage
Yes
—
Function/instruction profiling
Yes
—1
Trace
Yes
—
—
Yes
Power debugging
1
Table 3: Driver differences
1 With specific requirements or restrictions, see the respective chapter in this guide.
39
AFE1_AFE2-1:1
The IAR C-SPY Simulator
The IAR C-SPY Simulator
The C-SPY Simulator simulates the functions of the target processor entirely in
software, which means that you can debug the program logic long before any hardware
is available. Because no hardware is required, it is also the most cost-effective solution
for many applications.
The C-SPY Simulator supports:
●
Instruction-level simulation
●
Memory configuration and validation
●
Interrupt simulation
●
Peripheral simulation (using the C-SPY macro system in conjunction with
immediate breakpoints).
Simulating hardware instead of using a hardware debugging system means that some
limitations do not apply, but that there are other limitations instead. For example:
●
You can set an unlimited number of breakpoints in the simulator.
●
When you stop executing your application, time actually stops in the simulator.
When you stop application execution on a hardware debugging system, there might
still be activities in the system. For example, peripheral units might still be active
and reading from or writing to SFR ports.
●
Application execution is significantly much slower in a simulator compared to when
using a hardware debugging system. However, during a debug session, this might
not necessarily be a problem.
●
The simulator is not cycle accurate.
●
Peripheral simulation is limited in the C-SPY Simulator and therefore the simulator
is suitable mostly for debugging code that does not interact too much with
peripheral units.
The C-SPY hardware debugger drivers
The C-SPY Flash Emulator Tool Debugger is a JTAG debugger that supports all Texas
Instruments’ debug probes and boards, and several third-party JTAG debug probes. It
provides automatic flash downloading and takes advantage of on-chip debug facilities.
To make the C-SPY FET Debugger work, a communication driver must be installed on
the host PC. This driver is automatically installed during the installation of the IAR
Embedded Workbench IDE. Because the hardware debugger kernel is built into the
microcontroller, no ordinary ROM-monitor program or extra specific hardware is
needed to make the debugging work. You can also use the debugger on your own
hardware design.
C-SPY® Debugging Guide
40
for MSP430
AFE1_AFE2-1:1
The IAR C-SPY Debugger
At the time of writing this guide, the IAR C-SPY Debugger for the MSP430
microcontrollers is available with drivers for these JTAG debug probes supported by the
FET debugger driver:
●
MSP-FET430UIF
●
MSP-FET
●
eZFET
●
eZ430
●
Olimex JTAG interface
●
Elprotronic JTAG interface.
FEATURES
In addition to the general features of C-SPY, the FET Debugger driver also provides:
●
Execution in real time with full access to the microcontroller
●
High-speed communication through a JTAG interface
●
Zero memory footprint on the target system
●
Hardware code breakpoints
●
Built-in flash loader.
Depending on the level of Enhanced Emulation Module (EEM) support, you might have
access also to:
●
State storage
●
Sequencer
●
Clock control.
COMMUNICATION OVERVIEW
Most target systems have a debug probe or a debug adapter connected between the host
computer and the evaluation board.
41
AFE1_AFE2-1:1
The C-SPY hardware debugger drivers
The C-SPY FET Debugger driver uses the USB or parallel port to communicate with the
FET Interface module. The FET Interface module communicates with the JTAG
interface on the hardware.
C-SPY debugger
C-SPY FET Debugger driver
USB or parallel
connection
FET interface
module
JTAG cable
For further information, refer to the documentation supplied with the FET Debugger.
When a debug session is started, your application is automatically downloaded and
programmed into flash memory. You can disable this feature, if necessary.
Hardware installation
For information about the hardware installation, see the documentation supplied with
the hardware debugger from Texas Instruments. The following power-up sequence is
recommended to ensure proper communication between the target board, hardware
debugger, and C-SPY:
1 Power up the target board.
2 Power up the hardware debugger.
3 Start the C-SPY debug session.
C-SPY® Debugging Guide
42
for MSP430
AFE1_AFE2-1:1
Getting started using
C-SPY
●
Setting up C-SPY
●
Starting C-SPY
●
Adapting for target hardware
●
Reference information on 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
SETTING UP FOR DEBUGGING
1 Before you start C-SPY, choose Project>Options>Debugger>Setup and select the
C-SPY driver that matches your debugger system: simulator or a hardware debugger
system.
2 In the Category list, select the appropriate C-SPY driver and make your settings.
For information about these options, see Debugger options, page 389.
3 Click OK.
4 Choose Tools>Options to open the IDE Options dialog box:
●
Select Debugger to configure the debugger behavior
●
Select Stack to configure the debugger’s tracking of stack usage.
For more information about these options, see the IDE Project Management and
Building Guide.
See also Adapting for target hardware, page 48.
43
AFE1_AFE2-1:1
Setting up C-SPY
EXECUTING FROM RESET
The Run to option—available on the Debugger>Setup page—specifies a location you
want C-SPY to run to when you start a debug session as well as after each reset. C-SPY
will place a temporary breakpoint at this location and all code up to this point is executed
before stopping at the location. Note that this temporary breakpoint is removed when the
debugger stops, regardless of how. If you stop the execution before the Run to location
has been reached, the execution will not stop at that location when you start the
execution again.
The default location to run to is the main function. Type the name of the location if you
want C-SPY to run to a different location. You can specify assembler labels or whatever
can be evaluated to such, for instance function names.
If you leave the check box empty,
USING A SETUP MACRO FILE
A setup macro file is a macro file that you choose to load automatically when C-SPY
starts. You can define the setup macro file to perform actions according to your needs,
using setup macro functions and system macros. Thus, if you load a setup macro file you
can initialize C-SPY to perform actions automatically.
For more information about setup macro files and functions, see Introduction to C-SPY
macros, page 305. For an example of how to use a setup macro file, see Initializing
target hardware before C-SPY starts, page 49.
To register a setup macro file:
1 Before you start C-SPY, choose Project>Options>Debugger>Setup.
2 Select Use macro file and type the path and name of your setup macro file, for
example Setup.mac. If you do not type a filename extension, the extension mac is
assumed.
SELECTING A DEVICE DESCRIPTION FILE
C-SPY uses device description files to handle device-specific information.
A default device description file is automatically used based on your project settings. If
you want to override the default file, you must select your device description file. Device
description files are provided in the msp430\config directory and they have the
filename extension ddf.
For more information about device description files, see Adapting for target hardware,
page 48.
C-SPY® Debugging Guide
44
for MSP430
AFE1_AFE2-1:1
Getting started using C-SPY
To override the default device description file:
1 Before you start C-SPY, choose Project>Options>Debugger>Setup.
2 Enable the use of a device description file and select a file using the Device
description file browse button.
Note: You can easily view your device description files that are used for your project.
Choose Project>Open Device Description File and select the file you want to view.
LOADING PLUGIN MODULES
On the Plugins page you can specify C-SPY plugin modules to load and make available
during debug sessions. Plugin modules can be provided by IAR Systems, and by
third-party suppliers. Contact your software distributor or IAR Systems representative,
or visit the IAR Systems web site, for information about available modules.
For more information, see Plugins, page 392.
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
STARTING A DEBUG SESSION
You can choose to start a debug session with or without loading the current executable
file.
To start C-SPY and download the current executable file, click the Download and
Debug button. Alternatively, choose Project>Download and Debug.
To start C-SPY without downloading the current executable file, click the Debug
without Downloading button. Alternatively, choose Project>Debug without
Downloading.
45
AFE1_AFE2-1:1
Starting C-SPY
LOADING EXECUTABLE FILES BUILT OUTSIDE OF THE IDE
You can also load C-SPY with an application that was built outside the IDE, for example
applications built on the command line. To load an externally built executable file and
to set build options you must first create a project for it in your workspace.
To create a project for an externally built file:
1 Choose Project>Create New Project, and specify a project name.
2 To add the executable file to the project, choose Project>Add Files and make sure to
choose All Files in the Files of type drop-down list. Locate the executable file.
3 To start the executable file, click the Download and Debug button. The project can be
reused whenever you rebuild your executable file.
The only project options that are meaningful to set for this kind of project are options in
the General Options and Debugger categories. Make sure to set up the general project
options in the same way as when the executable file was built.
STARTING A DEBUG SESSION WITH SOURCE FILES MISSING
Normally, when you use the IAR Embedded Workbench IDE to edit source files, build
your project, and start the debug session, all required files are available and the process
works as expected.
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:
Typically, you can use the dialog box like this:
C-SPY® Debugging Guide
46
for MSP430
AFE1_AFE2-1:1
●
The source files are not available: Click If possible, don’t show this dialog again
and then click Skip. C-SPY will assume that there simply is no source file available.
The dialog box will not appear again, and the debug session will not try to display
the source code.
●
Alternative source files are available at another location: Specify an alternative
source code file, click If possible, don’t show this dialog again, and then click Use
Getting started using C-SPY
this file. C-SPY will assume that the alternative file should be used. The dialog box
will not appear again, unless a file is needed for which there is no alternative file
specified and which cannot be located automatically.
If you restart the IAR Embedded Workbench IDE, the Get Alternative File dialog box
will be displayed again once even if you have clicked If possible, don’t show this
dialog again. This gives you an opportunity to modify your previous settings.
For more information, see Get Alternative File dialog box, page 55.
LOADING MULTIPLE IMAGES
Normally, a debuggable application consists of exactly one file that you debug.
However, you can also load additional debug files (images). This means that the
complete program consists of several images.
Typically, this is useful if you want to debug your application in combination with a
prebuilt ROM image that contains an additional library for some platform-provided
features. The ROM image and the application are built using separate projects in the
IAR Embedded Workbench IDE and generate separate output files.
If more than one image has been loaded, you will have access to the combined debug
information for all the loaded images. In the Images window you can choose whether
you want to have access to debug information for one image or for all images.
To load additional images at C-SPY startup:
1 Choose Project>Options>Debugger>Images and specify up to three additional
images to be loaded. For more information, see Images, page 391.
2 Start the debug session.
To load additional images at a specific moment:
Use the __loadImage system macro and execute it using either one of the methods
described in Using C-SPY macros, page 307.
To display a list of loaded images:
Choose Images from the View menu. The Images window is displayed, see Images
window, page 54.
EDITING IN C-SPY WINDOWS
You can edit the contents of the Memory, Symbolic Memory, Registers, Register
User Groups Setup, Auto, Watch, Locals, Statics, Live Watch, and Quick Watch
windows.
47
AFE1_AFE2-1:1
Adapting for target hardware
Use these keyboard keys to edit the contents of these windows:
Enter
Makes an item editable and saves the new value.
Esc
Cancels a new value.
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
To display three elements pointed to by myPtr, myPtr+1, and myPtr+2, write:
myPtr;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
To display myPtr+10, myPtr+11, myPtr+12, myPtr+13, and myPtr+14, write:
myPtr;5,10
Note: For pointers, there are no built-in limits on displayed element count, and no
validation of the pointer value.
Adapting for target hardware
These tasks are covered:
●
Modifying a device description file
●
Initializing target hardware before C-SPY starts
●
Using predefined C-SPY macros for device support
MODIFYING A DEVICE DESCRIPTION FILE
C-SPY uses device description files provided with the product to handle several of the
target-specific adaptations, see Selecting a device description file, page 44. They contain
device-specific information such as:
C-SPY® Debugging Guide
48
for MSP430
AFE1_AFE2-1:1
●
Memory information for device-specific memory zones, see C-SPY memory zones,
page 138.
●
Definitions of memory-mapped peripheral units, device-specific CPU registers, and
groups of these.
Getting started using C-SPY
●
Definitions for device-specific interrupts, which makes it possible to simulate these
interrupts in the C-SPY simulator; see Interrupts, page 261.
Normally, you do not need to modify the device description file. However, if the
predefinitions are not sufficient for some reason, you can edit the file. Note, however,
that the format of these descriptions might be updated in future upgrades of the product.
Make a copy of the device description file that best suits your needs, and modify it
according to the description in the file. Reload the project to make the changes take
effect.
For information about how to load a device description file, see Selecting a device
description file, page 44.
INITIALIZING TARGET HARDWARE BEFORE C-SPY STARTS
You can use C-SPY macros to initialize target hardware before C-SPY starts. For
example, if your hardware uses external memory that must be enabled before code can
be downloaded to it, C-SPY needs a macro to perform this action before your
application can be downloaded.
1 Create a new text file and define your macro function.
By using the built-in execUserPreload setup macro function, your macro function
will be executed directly after the communication with the target system is established
but before C-SPY downloads your application.
For example, a macro that enables external SDRAM could look like this:
/* Your macro function. */
enableExternalSDRAM()
{
__message "Enabling external SDRAM\n";
__writeMemory32(...);
}
/* Setup macro determines time of execution. */
execUserPreload()
{
enableExternalSDRAM();
}
2 Save the file with the filename extension mac.
3 Before you start C-SPY, choose Project>Options>Debugger and click the Setup tab.
4 Select the option Use Setup file and choose the macro file you just created.
Your setup macro will now be loaded during the C-SPY startup sequence.
49
AFE1_AFE2-1:1
Reference information on starting C-SPY
USING PREDEFINED C-SPY MACROS FOR DEVICE SUPPORT
For some MSP430 devices, there are predefined C-SPY macros available for specific
device support, typically provided by the chip manufacturer. These macros are useful for
performing certain device-specific tasks,
You can easily access and execute these macros using the Macro Quicklaunch window.
Reference information on starting C-SPY
Reference information about:
●
C-SPY Debugger main window, page 50
●
Images window, page 54
●
Get Alternative File dialog box, page 55
●
Device Information window, page 56
See also:
●
Tools options for the debugger in the IDE Project Management and Building Guide.
C-SPY Debugger main window
When you start a debug session, these debugger-specific items appear in the main IAR
Embedded Workbench IDE window:
●
A dedicated Debug menu with commands for executing and debugging your
application
●
Depending on the C-SPY driver you are using, a driver-specific menu, often
referred to as the Driver menu in this documentation. Typically, this menu contains
menu commands for opening driver-specific windows and dialog boxes.
●
A special debug toolbar
●
Several windows and dialog boxes specific to C-SPY.
The C-SPY main window might look different depending on which components of the
product installation you are using.
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® Debugging Guide
50
for MSP430
AFE1_AFE2-1:1
Getting started using C-SPY
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 401.
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.
These commands are available:
Go (F5)
Executes from the current statement or instruction until a breakpoint or program
exit is reached.
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.
51
AFE1_AFE2-1:1
Reference information on starting C-SPY
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 78.
Set Next Statement
Moves the program counter directly to where the cursor is, without executing
any source code. Note, however, that this creates an anomaly in the program
flow and might have unexpected effects.
C++ Exceptions>
Break on Throw
This menu command is not supported by your product package.
C++ Exceptions>
Break on Uncaught Exception
This menu command is not supported by your product package.
C-SPY® Debugging Guide
52
for MSP430
AFE1_AFE2-1:1
Getting started using C-SPY
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 149.
Memory>Restore
Displays a dialog box where you can load the contents of a file in, for example
Intel-extended, TI msp430-txt, or Motorola s-record format to a specified
memory zone, see Memory Restore dialog box, page 150.
Refresh
Refreshes the contents of all debugger windows. Because window updates are
automatic, this is needed only in unusual situations, such as when target memory
is modified in ways C-SPY cannot detect. It is also useful if code that is
displayed in the Disassembly window is changed.
Logging>Set Log file
Displays a dialog box where you can choose to log the contents of the Debug
Log window to a file. You can select the type and the location of the log file. You
can choose what you want to log: errors, warnings, system information, user
messages, or all of these. See Log File dialog box, page 77.
Logging>
Set Terminal I/O Log file
Displays a dialog box where you can choose to log simulated target access
communication to a file. You can select the destination of the log file. See
Terminal I/O Log File dialog box, page 74
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
●
Symbolic Memory window
●
Registers window
●
Watch window
●
Locals window
●
Auto window
●
Live Watch window
●
Quick Watch window
53
AFE1_AFE2-1:1
Reference information on starting C-SPY
●
Statics window
●
Call Stack window
●
Trace window
●
Function Trace window
●
Timeline window, see Reference information on application timeline, page 197
●
Terminal I/O window
●
Code Coverage window
●
Function Profiler window
●
Images window
●
Stack window
●
Symbols window.
Additional windows are available depending on which C-SPY driver you are using.
Images window
The Images window is available from the View menu.
This window lists all currently loaded images (debug files).
Normally, a source application consists of exactly one image that you debug. However,
you can also load additional images. This means that the complete debuggable unit
consists of several images. See also Loading multiple images, page 47.
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.
C-SPY® Debugging Guide
54
for MSP430
AFE1_AFE2-1:1
Getting started using C-SPY
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:
These commands are available:
Show all images
Shows debug information for all loaded debug images.
Show only image
Shows debug information for the selected debug image.
Related information
For related information, see:
●
Loading multiple images, page 47
●
Images, page 391
●
__loadImage, page 329.
Get Alternative File dialog box
The Get Alternative File dialog box is displayed if C-SPY cannot automatically find
the source files to be loaded, for example if the application was built on another
computer.
See also Starting a debug session with source files missing, page 46.
55
AFE1_AFE2-1:1
Reference information on starting C-SPY
Could not find the following source file
The missing source file.
Suggested alternative
Specify an alternative file.
Use this file
After you have specified an alternative file, Use this file establishes that file as the alias
for the requested file. Note that after you have chosen this action, C-SPY will
automatically locate other source files if these files reside in a directory structure similar
to the first selected alternative file.
The next time you start a debug session, the selected alternative file will be preloaded
automatically.
Skip
C-SPY will assume that the source file is not available for this debug session.
If possible, don’t show this dialog again
Instead of displaying the dialog box again for a missing source file, C-SPY will use the
previously supplied response.
Related information
For related information, see Starting a debug session with source files missing, page 46.
Device Information window
The Device Information window is available from the Emulator menu.
Displays information about the target hardware being used.
C-SPY® Debugging Guide
56
for MSP430
AFE1_AFE2-1:1
Getting started using C-SPY
Requirements
The C-SPY FET Debugger driver.
57
AFE1_AFE2-1:1
Reference information on starting C-SPY
C-SPY® Debugging Guide
58
for MSP430
AFE1_AFE2-1:1
Executing your application
●
Introduction to application execution
●
Reference information on application execution
Introduction to application execution
These topics are covered:
●
Briefly about application execution
●
Source and disassembly mode debugging
●
Single stepping
●
Troubleshooting slow stepping speed
●
Running the application
●
Highlighting
●
Viewing the call stack
●
Terminal input and output
●
Debug logging
BRIEFLY ABOUT APPLICATION EXECUTION
C-SPY allows you to monitor and control the execution of your application. By
single-stepping through it, and setting breakpoints, you can examine details about the
application execution, for example the values of variables and registers. You can also use
the call stack to step back and forth in the function call chain.
The terminal I/O and debug log features let you interact with your application.
You can find commands for execution on the Debug menu and on the toolbar.
SOURCE AND DISASSEMBLY MODE DEBUGGING
C-SPY allows you to switch between source mode and disassembly mode debugging as
needed.
Source debugging provides the fastest and easiest way of developing your application,
without having to worry about how the compiler or assembler has implemented the
code. In the editor windows you can execute the application one statement at a time
while monitoring the values of variables and data structures.
59
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 63 for some tips.
The step commands
There are four step commands:
●
Step Into
●
Step Over
●
Next Statement
●
Step Out.
Using the Autostep settings dialog box, you can automate the single stepping. For more
information, see Autostep settings dialog box, page 78.
C-SPY® Debugging Guide
60
for MSP430
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;
}
61
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:
extern int g(int);
int f(int n)
{
value = g(n-1) + g(n-2) + g(n-3);
return value;
}
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.
Single-stepping and flash memory in the C-SPY FET Debugger
When you use the FET Debugger driver, be aware that single-stepping over instructions
that manipulate the flash memory might cause some unexpected side-effects.
Multiple internal machine cycles are required to clear and program the flash memory.
When single-stepping over instructions that manipulate the flash memory, control is
given back to C-SPY before these operations are complete. Consequently, C-SPY will
C-SPY® Debugging Guide
62
for MSP430
AFE1_AFE2-1:1
Executing your application
update its memory window with erroneous information. A workaround to this behavior
is to follow the flash access instruction with a NOP instruction, and then step past the NOP
before reviewing the effects of the flash access instruction.
TROUBLESHOOTING SLOW STEPPING SPEED
If you find that stepping speed is slow, these troubleshooting tips might speed up
stepping:
●
If you are using a hardware debugger system, keep track of how many hardware
breakpoints that are used and make sure some of them are left for stepping.
Stepping in C-SPY is normally performed using breakpoints. When C-SPY performs
a step command, a breakpoint is set on the next statement and the application
executes until it reaches this breakpoint. If you are using a hardware debugger
system, the number of hardware breakpoints—typically used for setting a stepping
breakpoint in code that is located in flash/ROM memory—is limited. If you, for
example, step into a C switch statement, breakpoints are set on each branch; this
might consume several hardware breakpoints. If the number of available hardware
breakpoints is exceeded, C-SPY switches into single stepping on assembly level,
which can be very slow.
For more information, see Breakpoints in the C-SPY FET debugger driver, page 106
and Breakpoint consumers, page 107.
●
Disable trace data collection, using the Enable/Disable button in both the Trace
and the Function Profiling windows. Trace data collection might slow down
stepping because the collected trace data is processed after each step. Note that it is
not sufficient to just close the corresponding windows to disable trace data
collection.
●
Choose to view only a limited selection of SFR registers. You can choose between
two alternatives. Either type #SFR_name (where SFR_name reflects the name of the
SFR you want to monitor) in the Watch window, or create your own filter for
displaying a limited group of SFRs in the Register window. Displaying many SFR
registers might slow down stepping because all registers must be read from the
hardware after each step. See Defining application-specific register groups, page
141.
●
Close the Memory and Symbolic Memory windows if they are open, because the
visible memory must be read after each step and that might slow down stepping.
●
Close any window that displays expressions such as Watch, Live Watch, Locals,
Statics if it is open, because all these windows read memory after each step and that
might slow down stepping.
●
Close the Stack window if it is open. Choose Tools>Options>Stack and disable the
Enable graphical stack display and stack usage tracking option if it is enabled.
63
AFE1_AFE2-1:1
Introduction to application execution
●
If possible, increase the communication speed between C-SPY and the target
board/emulator.
RUNNING THE APPLICATION
Go
The Go command continues execution from the current position until a breakpoint or
program exit is reached.
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.
C-SPY® Debugging Guide
64
for MSP430
AFE1_AFE2-1:1
Executing your application
VIEWING THE CALL STACK
The compiler generates extensive call frame information. This allows C-SPY to show,
without any runtime penalty, the complete function call chain at any time.
Typically, this is useful for two purposes:
●
Determining in what context the current function has been called
●
Tracing the origin of incorrect values in variables and in parameters, thus locating
the function in the call chain where the problem occurred.
The Call Stack window shows a list of function calls, with the current function at the
top. When you inspect a function in the call chain, the contents of all affected windows
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 IAR
Assembler Reference Guide for MSP430.
TERMINAL INPUT AND OUTPUT
Sometimes you might have to debug constructions in your application that use stdin
and stdout without an actual hardware device for input and output. The Terminal I/O
window lets you enter input to your application, and display output from it. You can also
direct terminal I/O to a file, using the Terminal I/O Log Files dialog box.
This facility is useful in two different contexts:
●
If your application uses stdin and stdout
●
For producing debug trace printouts.
For more information, see Terminal I/O window, page 73 and Terminal I/O Log File
dialog box, page 74.
DEBUG LOGGING
The Debug Log window displays debugger output, such as diagnostic messages,
macro-generated output, and information about trace.
65
AFE1_AFE2-1:1
Reference information on application execution
It can sometimes be convenient to log the information to a file where you can easily
inspect it, see Log File dialog box, page 77. 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.
Reference information on application execution
Reference information about:
●
Disassembly window, page 67
●
Call Stack window, page 71
●
Terminal I/O window, page 73
●
Terminal I/O Log File dialog box, page 74
●
Debug Log window, page 75
●
Log File dialog box, page 77
●
Report Assert dialog box, page 78
●
Autostep settings dialog box, page 78
See also Terminal I/O options in the IDE Project Management and Building Guide.
C-SPY® Debugging Guide
66
for MSP430
AFE1_AFE2-1:1
Executing your application
Disassembly window
The C-SPY Disassembly window is available from the View menu.
This figure reflects the C-SPY simulator.
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 59.
Requirements
None; this window is always available.
67
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 138.
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 103.
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.
C-SPY® Debugging Guide
68
for MSP430
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.
Enable
Toggles code coverage on or off.
Show
Toggles the display of code coverage on or off.
Executed code is indicated by a green diamond.
Clear
Clears all code coverage information.
69
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.
Enable
Toggles instruction profiling on or off.
Show
Toggles the display of instruction profiling on or off.
For each instruction, the left-side margin displays
how many times the instruction has been executed.
Clear
Clears all instruction profiling information.
Toggle Breakpoint (Code)
Toggles a code breakpoint. Assembler instructions and any corresponding label
at which code breakpoints have been set are highlighted in red. For more
information, see Code breakpoints dialog box, page 118.
Toggle Breakpoint (Log)
Toggles a log breakpoint for trace printouts. Assembler instructions at which log
breakpoints have been set are highlighted in red. For more information, see Log
breakpoints dialog box, page 119.
Toggle Breakpoint (Trace Start)
Toggles a Trace Start breakpoint. When the breakpoint is triggered, the trace
data collection starts. Note that this menu command is only available if the
C-SPY driver you are using supports trace. For more information, see Trace
Start breakpoints dialog box, page 185.
Toggle Breakpoint (Trace Stop)
Toggles a Trace Stop breakpoint. When the breakpoint is triggered, the trace
data collection stops. Note that this menu command is only available if the
C-SPY driver you are using supports trace. For more information, see Trace
Stop breakpoints dialog box, page 186.
Enable/Disable Breakpoint
Enables and Disables a breakpoint. If there is more than one breakpoint at a
specific line, all those breakpoints are affected by the Enable/Disable
command.
Edit Breakpoint
Displays the breakpoint dialog box to let you edit the currently selected
breakpoint. If there is more than one breakpoint on the selected line, a submenu
is displayed that lists all available breakpoints on that line.
Set Next Statement
Sets the program counter to the address of the instruction at the insertion point.
C-SPY® Debugging Guide
70
for MSP430
AFE1_AFE2-1:1
Executing your application
Copy Window Contents
Copies the selected contents of the Disassembly window to the clipboard.
Mixed-Mode
Toggles between showing 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.
Find in Trace
Searches the contents of the Trace window for occurrences of the given
location—the position of the insertion point in the source code—and reports the
result in the Find in Trace window. This menu command requires support for
Trace in the C-SPY driver you are using, see Differences between the C-SPY
drivers, page 39.
Zone
Selects a memory zone, see C-SPY memory zones, page 138.
Call Stack window
The Call Stack window is available from the View menu.
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 65.
Requirements
None; this window is always available.
71
AFE1_AFE2-1:1
Reference information on application execution
Display area
Each entry in the display area is formatted in one of these ways:
function(values)***
A C/C++ function with debug information.
Provided that Show Arguments is enabled, values
is a list of the current values of the parameters, or
empty if the function does not take any parameters.
***, if present, indicates that the function has been
inlined by the compiler. For information about
function inlining, see the IAR C/C++ Compiler User
Guide for MSP430.
[label + offset]
An assembler function, or a C/C++ function without
debug information.
<exception_frame>
An interrupt.
Context menu
This context menu is available:
This figure reflects the C-SPY simulator.
These commands are available:
Go to Source
Displays the selected function in the Disassembly or editor windows.
Show Arguments
Shows function arguments.
Run to Cursor
Executes until return to the function selected in the call stack.
Toggle Breakpoint (Code)
Toggles a code breakpoint.
C-SPY® Debugging Guide
72
for MSP430
AFE1_AFE2-1:1
Executing your application
Toggle Breakpoint (Conditional)
Toggles a conditional breakpoint.
Toggle Breakpoint (Advanced Trigger)
Toggles an Advanced Trigger breakpoint.
Toggle Breakpoint (Log)
Toggles a log breakpoint.
Toggle Breakpoint (Trace Start)
Toggles a Trace Start breakpoint. When the breakpoint is triggered, trace data
collection starts. Note that this menu command is only available if the C-SPY
driver you are using supports it.
Toggle Breakpoint (Trace Stop)
Toggles a Trace Stop breakpoint. When the breakpoint is triggered, trace data
collection stops. Note that this menu command is only available if the C-SPY
driver you are using supports it.
Enable/Disable Breakpoint
Enables or disables the selected breakpoint
Terminal I/O window
The Terminal I/O window is available from the View menu.
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.
73
AFE1_AFE2-1:1
Reference information on application execution
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 65.
Requirements
None; this window is always available.
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.
Terminal I/O Log File dialog box
The Terminal I/O Log File dialog box is available by choosing Debug>Logging>Set
Terminal I/O Log File.
Use this dialog box to select a destination log file for terminal I/O from C-SPY.
See also Terminal input and output, page 65.
Requirements
None; this dialog box is always available.
C-SPY® Debugging Guide
74
for MSP430
AFE1_AFE2-1:1
Executing your application
Terminal IO Log Files
Controls the logging of terminal I/O. To enable logging of terminal I/O to a file, select
Enable Terminal IO log file and specify a filename. The default filename extension is
log. A browse button is available for your convenience.
Debug Log window
The Debug Log window is available by choosing View>Messages.
This window displays debugger output, such as diagnostic messages, macro-generated
output, and information about trace. This output is only available during a debug
session. When opened, this window is, by default, grouped together with the other
message windows, see IDE Project Management and Building Guide.
Double-click any rows in one of the following formats to display the corresponding
source code in the editor window:
<path> (<row>):<message>
<path> (<row>,<column>):<message>
See also Debug logging, page 65 and Log File dialog box, page 77.
Requirements
None; this window is always available.
75
AFE1_AFE2-1:1
Reference information on application execution
Context menu
This context menu is available:
These commands are available:
All
Shows all messages sent by the debugging tools and drivers.
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.
C-SPY® Debugging Guide
76
for MSP430
AFE1_AFE2-1:1
Executing your application
Log File dialog box
The Log File dialog box is available by choosing Debug>Logging>Set Log File.
Use this dialog box to log output from C-SPY to a file.
Requirements
None; this dialog box is always available.
Enable Log file
Enables or disables logging to the file.
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
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.
77
AFE1_AFE2-1:1
Reference information on application execution
Report Assert dialog box
The Report Assert dialog box appears if you have a call to the assert function in your
application source code, and the assert condition is false. In this dialog box you can
choose how to proceed.
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.
Autostep settings dialog box
The Autostep settings dialog box is available from the Debug menu.
Use this dialog box to customize autostepping.
The drop-down menu lists the available step commands, see Single stepping, page 60.
Requirements
None; this dialog box is always available.
Delay
Specify the delay between each step in milliseconds.
C-SPY® Debugging Guide
78
for MSP430
AFE1_AFE2-1:1
Variables and expressions
●
Introduction to working with variables and expressions
●
Working with variables and expressions
●
Reference information on working with variables and expressions
Introduction to working with variables and expressions
This section introduces different methods for looking at variables and introduces some
related concepts.
These topics are covered:
●
Briefly about working with variables and expressions
●
C-SPY expressions
●
Limitations on variable information.
BRIEFLY ABOUT WORKING WITH VARIABLES AND
EXPRESSIONS
There are several methods for looking at variables and calculating their values. These
methods are suitable for basic debugging:
●
Tooltip watch—in the editor window—provides the simplest way of viewing the
value of a variable or more complex expressions. Just point at the variable with the
mouse pointer. The value is displayed next to the variable.
●
The Auto window displays a useful selection of variables and expressions in, or
near, the current statement. The window is automatically updated when execution
stops.
●
The Locals window displays the local variables, that is, auto variables and function
parameters for the active function. The window is automatically updated when
execution stops.
●
The Watch window allows you to monitor the values of C-SPY expressions and
variables. The window is automatically updated when execution stops.
●
The Live Watch window repeatedly samples and displays the values of expressions
while your application is executing. Variables in the expressions must be statically
located, such as global variables.
●
The Statics window displays the values of variables with static storage duration.
The window is automatically updated when execution stops.
79
AFE1_AFE2-1:1
Introduction to working with variables and expressions
●
The Macro Quicklaunch window and the Quick Watch window give you precise
control over when to evaluate an expression.
●
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.
●
The Data Sample window displays samples for up to four different variables. You
can also display the data samples as graphs in the Sampled Graphs window. By
using data sampling, you will get an indication of the data value over a length of
time. Because it is a sampled value, data sampling is best suited for slow-changing
data.
For more information about these windows, see The application timeline, page 191.
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-SPY® Debugging Guide
80
for MSP430
AFE1_AFE2-1:1
Variables and expressions
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 that C++
symbols might implicitly contain function calls which are not allowed in C-SPY
symbols 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 *)
However, this line will be accepted:
sizeof(unsigned char __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 48.
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 Register
window, using the CPU Registers register group. See Registers window, page 159.
81
AFE1_AFE2-1:1
Introduction to working with variables and expressions
C-SPY macro functions
Macro functions consist of C-SPY macro variable definitions and macro statements
which are executed when the macro is called.
For information about C-SPY macro functions and how to use them, see Briefly about
the macro language, page 306.
C-SPY macro variables
Macro variables are defined and allocated outside your application, and can be used in
a C-SPY expression. In case of a name conflict between a C symbol and a C-SPY macro
variable, the C-SPY macro variable will have a higher precedence than the C variable.
Assignments to a macro variable assign both its value and type.
For information about C-SPY macro variables and how to use them, see Reference
information on the macro language, page 312.
Using sizeof
According to standard C, there are two syntactical forms of sizeof:
sizeof(type)
sizeof expr
The former is for types and the latter for expressions.
Note: In C-SPY, do not use parentheses around an expression when you use the sizeof
operator. For example, use sizeof x+2 instead of sizeof (x+2).
LIMITATIONS ON VARIABLE INFORMATION
The value of a C variable is valid only on step points, that is, the first instruction of a
statement and on function calls. This is indicated in the editor window with a bright
green highlight color. In practice, the value of the variable is accessible and correct more
often than that.
When the program counter is inside a statement, but not at a step point, the statement or
part of the statement is highlighted with a pale variant of the ordinary highlight color.
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.
C-SPY® Debugging Guide
82
for MSP430
AFE1_AFE2-1:1
Variables and expressions
Consider this example:
myFunction()
{
int i = 42;
...
x = computer(i); /* Here, the value of i is known to C-SPY */
...
}
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.
Working with variables and expressions
These tasks are covered:
●
Using the windows related to variables and expressions
●
Viewing assembler variables
See also Analyzing your application’s timeline, page 193.
USING THE WINDOWS RELATED TO VARIABLES AND
EXPRESSIONS
Where applicable, you can add, modify, and remove expressions, and change the display
format in the windows related to variables and expressions.
To add a value you can also click in the dotted rectangle and type the expression you
want to examine. To modify the value of an expression, click the Value field and modify
its content. To remove an expression, select it and press the Delete key.
For text that is too wide to fit in a column—in any of the these windows, except the
Trace window—and thus is truncated, just point at the text with the mouse pointer and
tooltip information is displayed.
Right-click in any of the windows to access the context menu which contains additional
commands. Convenient drag-and-drop between windows is supported, except for in the
83
AFE1_AFE2-1:1
Working with variables and expressions
Locals window, Data logging windows, and the Quick Watch window where it is not
relevant.
VIEWING ASSEMBLER VARIABLES
An assembler label does not convey any type information at all, which means C-SPY
cannot easily display data located at that label without getting extra information. To
view data conveniently, C-SPY by default treats all data located at assembler labels as
variables of type int. However, in the Watch, Live 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.
C-SPY® Debugging Guide
84
for MSP430
AFE1_AFE2-1:1
Variables and expressions
Reference information on working with variables and expressions
Reference information about:
●
Auto window, page 85
●
Locals window, page 87
●
Watch window, page 89
●
Live Watch window, page 92
●
Statics window, page 94
●
Quick Watch window, page 97
●
Symbols window, page 100
●
Resolve Symbol Ambiguity dialog box, page 101
See also:
●
Reference information on trace, page 180 for trace-related reference information
●
Macro Quicklaunch window, page 361
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 47.
Requirements
None; this window is always available.
85
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:
C-SPY® Debugging Guide
86
for MSP430
AFE1_AFE2-1:1
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.
Variables and expressions
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 84.
Options
Displays the IDE Options dialog box where you can set various options, for
example the Update interval option. The default value of this option is 1000
milliseconds, which means the Live Watch window will be updated once every
second during program execution.
Save to File
Saves content to a file in a tab-separated format.
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 47.
Requirements
None; this window is always available.
87
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:
C-SPY® Debugging Guide
88
for MSP430
AFE1_AFE2-1:1
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.
Variables and expressions
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 84.
Options
Displays the IDE Options dialog box where you can set various options, for
example the Update interval option. The default value of this option is 1000
milliseconds, which means the Live Watch window will be updated once every
second during program execution.
Save to File
Saves content to a file in a tab-separated format.
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.
89
AFE1_AFE2-1:1
Reference information on working with variables and expressions
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 47.
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.
C-SPY® Debugging Guide
90
for MSP430
AFE1_AFE2-1:1
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 84.
Options
Displays the IDE Options dialog box where you can set various options, for
example the Update interval option. The default value of this option is 1000
milliseconds, which means the Live Watch window will be updated once every
second during program execution.
Save to File
Saves content to a file in a tab-separated format.
91
AFE1_AFE2-1:1
Reference information on working with variables and expressions
Live Watch window
The Live Watch window is available from the View menu.
This window repeatedly samples and displays the value of expressions while your
application is executing. Variables in the expressions must be statically located, such as
global variables.
See also Editing in C-SPY windows, page 47.
Requirements
The C-SPY simulator.
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.
C-SPY® Debugging Guide
92
for MSP430
AFE1_AFE2-1:1
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.
93
AFE1_AFE2-1:1
Reference information on working with variables and expressions
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 84.
Options
Displays the IDE Options dialog box where you can set various options, for
example the Update interval option. The default value of this option is 1000
milliseconds, which means the Live Watch window will be updated once every
second during program execution.
Save to File
Saves content to a file in a tab-separated format.
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.
C-SPY® Debugging Guide
94
for MSP430
AFE1_AFE2-1:1
Variables and expressions
See also Editing in C-SPY windows, page 47.
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.
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.
95
AFE1_AFE2-1:1
Reference information on working with variables and expressions
Context menu
This context menu is available:
These commands are available:
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.
Save to File
Saves the content of the Statics window to a log file.
C-SPY® Debugging Guide
96
for MSP430
AFE1_AFE2-1:1
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.
Quick Watch window
The Quick Watch window is available from the View menu and from the context menu
in the editor window.
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 47.
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.
97
AFE1_AFE2-1:1
Reference information on working with 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 307.
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.
C-SPY® Debugging Guide
98
for MSP430
AFE1_AFE2-1:1
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 84.
Options
Displays the IDE Options dialog box where you can set various options, for
example the Update interval option. The default value of this option is 1000
milliseconds, which means the Live Watch window will be updated once every
second during program execution.
Save to File
Saves content to a file in a tab-separated format.
99
AFE1_AFE2-1:1
Reference information on working with variables and expressions
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.
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.
C-SPY® Debugging Guide
100
for MSP430
AFE1_AFE2-1:1
Variables and expressions
Context menu
This context menu is available:
These commands are available:
Functions
Toggles the display of function symbols on or off in the list.
Variables
Toggles the display of variables on or off in the list.
Labels
Toggles the display of labels on or off in the list.
Resolve Symbol Ambiguity dialog box
The Resolve Symbol Ambiguity dialog box appears, for example, when you specify a
symbol in the Disassembly window to go to, and there are several instances of the same
symbol due to templates or function overloading.
Requirements
None; this window is always available.
Ambiguous symbol
Indicates which symbol that is ambiguous.
101
AFE1_AFE2-1:1
Reference information on working with variables and expressions
Please select one symbol
A list of possible matches for the ambiguous symbol. Select the one you want to use.
C-SPY® Debugging Guide
102
for MSP430
AFE1_AFE2-1:1
Breakpoints
●
Introduction to setting and using breakpoints
●
Setting breakpoints
●
Reference information on breakpoints
Introduction to setting and using breakpoints
These topics are covered:
●
Reasons for using breakpoints
●
Briefly about setting breakpoints
●
Breakpoint types
●
Breakpoint icons
●
Breakpoints in the C-SPY simulator
●
Breakpoint consumers
REASONS FOR USING BREAKPOINTS
C-SPY® lets you set various types of breakpoints in the application you are debugging,
allowing you to stop at locations of particular interest. You can set a breakpoint at a code
location to investigate whether your program logic is correct, or to get trace printouts.
In addition to code breakpoints, and depending on what C-SPY driver you are using,
additional breakpoint types might be available. For example, you might be able to set a
data breakpoint, to investigate how and when the data changes.
You can let the execution stop under certain conditions, which you specify. You can also
let the breakpoint trigger a side effect, for instance executing a C-SPY macro function,
by transparently stopping the execution and then resuming. The macro function can be
defined to perform a wide variety of actions, for instance, simulating hardware behavior.
All these possibilities provide you with a flexible tool for investigating the status of your
application.
BRIEFLY ABOUT SETTING BREAKPOINTS
You can set breakpoints in many various ways, allowing for different levels of
interaction, precision, timing, and automation. All the breakpoints you define will
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
103
AFE1_AFE2-1:1
Introduction to setting and using breakpoints
breakpoints. The Breakpoint Usage window also lists all internally used breakpoints,
see Breakpoint consumers, page 107.
Breakpoints are set with a higher precision than single lines, using the same mechanism
as when stepping; for more information about the precision, see Single stepping, page
60.
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.
For the C-SPY FET Debugger driver, a code breakpoint can be either a hardware or a
software breakpoint.
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.
Trace Start and Stop breakpoints
Trace Start and Stop breakpoints start and stop trace data collection—a convenient way
to analyze instructions between two execution points.
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
C-SPY® Debugging Guide
104
for MSP430
AFE1_AFE2-1:1
Breakpoints
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
specified location. The execution will usually stop directly after the instruction that
accessed the data has been executed.
Data Log breakpoints
Data log breakpoints are triggered when a specified memory address is accessed. A log
entry is written in the Data Log window for each access. Data logs can also be displayed
on the Data Log graph in the Timeline window, if that window is enabled.
You can set data log breakpoints using the Breakpoints window, the Memory window,
and the editor window.
Using a single instruction, the microcontroller can only access values that are two bytes
or less. If you specify a data log breakpoint on a memory location that cannot be
accessed by one instruction, for example a double or a too large area in the Memory
window, the result might not be what you intended.
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.
Range breakpoints
Range breakpoints can be set on a data or an address range, and the action can be
specified to occur on an access inside or outside the specified range. These breakpoints
are only available if you are using a device that supports the Enhanced Emulation
Module at the required level.
Advanced trigger breakpoints
Advanced trigger breakpoints can be set with various operators on the address bus, the
data bus, or on a register, to be triggered by a certain kind of access. These breakpoints
are only available if you are using a device that supports the Enhanced Emulation
Module at the required level.
105
AFE1_AFE2-1:1
Introduction to setting and using breakpoints
Conditional breakpoints
Conditional breakpoints can be set with various operators on the address bus, the data
bus, or on a register, to be triggered by a certain kind of access. You can also specify a
conditional value. These breakpoints are only available if you are using a device that
supports the Enhanced Emulation Module at the required level.
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.
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.
BREAKPOINTS IN THE C-SPY SIMULATOR
The C-SPY simulator supports all breakpoint types and you can set an unlimited amount
of breakpoints.
BREAKPOINTS IN THE C-SPY FET DEBUGGER DRIVER
Using the C-SPY drivers for the C-SPY FET debugger, you can set code breakpoints. If
you are using a device that supports the Enhanced Emulation Module at the required
level, you also have access to an extended breakpoint system with support for:
●
C-SPY® Debugging Guide
106
for MSP430
AFE1_AFE2-1:1
breakpoints on addresses, data, and registers
Breakpoints
●
defining which type of access that should trigger the breakpoint: read, write, or
fetch
●
setting conditional breakpoints
●
triggering different actions: stopping the execution, or starting the state storage
module
●
emulated breakpoints.
The Enhanced Emulation Module (at the required level) also gives you access to the
sequencer module which is a state machine that uses breakpoints for triggering new
states.
Hardware breakpoints
To set breakpoints, the C-SPY FET Debugger uses the hardware breakpoints available
on the device. The number of hardware breakpoints is limited, and when all hardware
breakpoints have been used, C-SPY can use software breakpoints.
For information about the number of available hardware breakpoints for each device, see
the release notes or the hardware documentation.
Software breakpoints
There are two types of software breakpoints: virtual breakpoints and emulated
breakpoints. See , for information about how to specify which type to use.
When virtual breakpoints are used, C-SPY is forced into single-step mode after all
hardware breakpoints have been used. However, if your device supports the Enhanced
Emulation Module at the required level, you can use emulated breakpoints for access to
an unlimited number of breakpoints.
When emulated breakpoints are used, the instructon where the breakpoint is set will be
replaced by a special instruction that the debugger recognizes. When the debugger
encounters such an instruction, it stops. This mecjanism uses one hardware breakpoint
to emulate an unlimited number of breakpoints.
To prevent the debugger from executing in single-step mode if you do not use emulated
software breakpoints, you can disable the use of virtual breakpoints and—in the CLIB
runtime environment—fine-tune the use of breakpoint consumers. This will increase the
performance of the debugger, but you will only have access to the available number of
hardware breakpoints. For information about the breakpoint consumers of the debugger
system, see Breakpoint consumers, page 107.
BREAKPOINT CONSUMERS
A debugger system includes several consumers of breakpoints.
107
AFE1_AFE2-1:1
Introduction to setting and using 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.
You can disable the setting of system breakpoints on the putchar and getchar
functions and on the exit label; see Breakpoints, page 398.
When the Run to option is selected and all hardware breakpoints have already been
used, a virtual breakpoint will be set even if you have deselected the Use virtual
breakpoints option. When you start the debugger under these conditions, C-SPY will
prompt you to choose whether you want to execute in single-step mode or stop at the
first instruction.
These types of breakpoint consumers are displayed in the Breakpoint Usage window,
for example, C-SPY Terminal I/O & libsupport module.
C-SPY plugin modules
For example, modules for real-time operating systems can consume additional
breakpoints. Specifically, by default, the Stack window consumes one physical
breakpoint.
To disable the breakpoint used by the Stack window:
1 Choose Tools>Options>Stack.
2 Deselect the Stack pointer(s) not valid until program reaches: label option.
C-SPY® Debugging Guide
108
for MSP430
AFE1_AFE2-1:1
Breakpoints
To disable the Stack window entirely, choose Tools>Options>Stack and make sure all
options are deselected.
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.
VARIOUS WAYS TO SET A BREAKPOINT
You can set a breakpoint in various ways:
●
Toggling a simple code breakpoint.
●
Using the New Breakpoints dialog box and the Edit Breakpoints dialog box
available from the context menus in the editor window, Breakpoints window, and
in the Disassembly window. The dialog boxes give you access to all breakpoint
options.
●
Setting a data breakpoint on a memory area directly in the Memory window.
●
Using predefined system macros for setting breakpoints, which allows automation.
The different methods offer different levels of simplicity, complexity, and automation.
TOGGLING A SIMPLE CODE BREAKPOINT
Toggling a code breakpoint is a quick method of setting a breakpoint. The following
methods are available both in the editor window and in the Disassembly window:
●
Click in the gray left-side margin of the window
●
Place the insertion point in the C source statement or assembler instruction where
you want the breakpoint, and click the Toggle Breakpoint button in the toolbar
●
Choose Edit>Toggle Breakpoint
●
Right-click and choose Toggle Breakpoint from the context menu.
SETTING BREAKPOINTS USING THE DIALOG BOX
The advantage of using a breakpoint dialog box is that it provides you with a graphical
interface where you can interactively fine-tune the characteristics of the breakpoints.
109
AFE1_AFE2-1:1
Setting breakpoints
You can set the options and quickly test whether the breakpoint works according to your
intentions.
All breakpoints you define using a breakpoint dialog box are preserved between debug
sessions.
You can open the dialog box from the context menu available in the editor window,
Breakpoints window, and in the Disassembly window.
To set a new breakpoint:
1 Choose View>Breakpoints to open the Breakpoints window.
2 In the Breakpoints window, right-click, and choose New Breakpoint from the context
menu.
3 On the submenu, choose the breakpoint type you want to set.
Depending on the C-SPY driver you are using, different breakpoint types are available.
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.
C-SPY® Debugging Guide
110
for MSP430
AFE1_AFE2-1:1
Breakpoints
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.
SETTING A DATA BREAKPOINT IN THE MEMORY WINDOW
You can set breakpoints directly on a memory location in the Memory window.
Right-click in the window and choose the breakpoint command from the context menu
that appears. To set the breakpoint on a range, select a portion of the memory contents.
The breakpoint is not highlighted in the Memory window; instead, you can see, edit,
and remove it using the Breakpoints window, which is available from the View menu.
The breakpoints you set in the Memory window will be triggered for both read and
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.
SETTING BREAKPOINTS USING SYSTEM MACROS
You can set breakpoints not only in the breakpoint dialog box but also by using built-in
C-SPY system macros. When you use system macros for setting breakpoints, the
breakpoint characteristics are specified as macro parameters.
Macros are useful when you have already specified your breakpoints so that they fully
meet your requirements. You can define your breakpoints in a macro file, using built-in
system macros, and execute the file at C-SPY startup. The breakpoints will then be set
automatically each time you start C-SPY. Another advantage is that the debug session
will be documented, and that several engineers involved in the development project can
share the macro files.
Note: If you use system macros for setting breakpoints, you can still view and modify
them in the Breakpoints window. In contrast to using the dialog box for defining
breakpoints, all breakpoints that are defined using system macros are removed when you
exit the debug session.
111
AFE1_AFE2-1:1
Setting breakpoints
These breakpoint macros are available:
C-SPY macro for breakpoints
Simulator
FET Debugger
__setAdvancedTriggerBreak
—
Yes
__setCodeBreak
Yes
Yes
__setConditionalBreak
—
Yes
__setDataBreak
Yes
—
__setLogBreak
Yes
Yes
__setRangeBreak
—
Yes
__setDataLogBreak
Yes
—
__setSimBreak
Yes
—
__setTraceStartBreak
Yes
—
__setTraceStopBreak
Yes
—
__clearBreak
Yes
Yes
Table 6: C-SPY macros for breakpoints
For information about each breakpoint macro, see Reference information on C-SPY
system macros, page 319.
Setting breakpoints at C-SPY startup using a setup macro file
You can use a setup macro file to define breakpoints at C-SPY startup. Follow the
procedure described in Using C-SPY macros, page 307.
USEFUL BREAKPOINT HINTS
Below are some useful hints related to setting breakpoints.
Tracing incorrect function arguments
If a function with a pointer argument is sometimes incorrectly called with a NULL
argument, you might want to debug that behavior. These methods can be useful:
●
C-SPY® Debugging Guide
112
for MSP430
AFE1_AFE2-1:1
Set a breakpoint on the first line of the function with a condition that is true only
when the parameter is 0. The breakpoint will then not be triggered until the
problematic situation actually occurs. The advantage of this method is that no extra
source code is needed. The drawback is that the execution speed might become
unacceptably low.
Breakpoints
●
You can use the assert macro in your problematic function, for example:
int MyFunction(int * MyPtr)
{
assert(MyPtr != 0); /* Assert macro added to your source
code. */
/* Here comes the rest of your function. */
}
The execution will break whenever the condition is true. The advantage is that the
execution speed is only very slightly affected, but the drawback is that you will get a
small extra footprint in your source code. In addition, the only way to get rid of the
execution stop is to remove the macro and rebuild your source code.
●
Instead of using the assert macro, you can modify your function like this:
int MyFunction(int * MyPtr)
{
if(MyPtr == 0)
MyDummyStatement; /* Dummy statement where you set a
breakpoint. */
/* Here comes the rest of your function. */
}
You must also set a breakpoint on the extra dummy statement, so that the execution
will break whenever the condition is true. The advantage is that the execution speed
is only very slightly affected, but the drawback is that you will still get a small extra
footprint in your source code. However, in this way you can get rid of the execution
stop by just removing the breakpoint.
Performing a task and continuing execution
You can perform a task when a breakpoint is triggered and then automatically continue
execution.
You can use the Action text box to associate an action with the breakpoint, for instance
a C-SPY macro function. When the breakpoint is triggered and the execution of your
application has stopped, the macro function will be executed. In this case, the execution
will not continue automatically.
Instead, you can set a condition which returns 0 (false). When the breakpoint is
triggered, the condition—which can be a call to a C-SPY macro that performs a task—
is evaluated and because it is not true, execution continues.
113
AFE1_AFE2-1:1
Reference information on breakpoints
Consider this example where the C-SPY macro function performs a simple task:
__var my_counter;
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.
Using breakpoints when programming flash memory
When programming the flash memory, do not set a breakpoint on the instruction
immediately following the write to flash operation. A simple work-around is to follow
the write to flash operation with a NOP instruction, and set a breakpoint on the instruction
following the NOP instruction.
Reference information on breakpoints
Reference information about:
C-SPY® Debugging Guide
114
for MSP430
AFE1_AFE2-1:1
●
Breakpoints window, page 115
●
Breakpoint Usage window, page 117
●
Code breakpoints dialog box, page 118
●
Log breakpoints dialog box, page 119
●
Data breakpoints dialog box, page 121
●
Data Log breakpoints dialog box, page 123
●
Immediate breakpoints dialog box, page 124
●
Range breakpoints dialog box, page 125
●
Conditional breakpoints dialog box, page 127
●
Advanced Trigger breakpoints dialog box, page 130
●
Enter Location dialog box, page 132
●
Breakpoint combiner dialog box, page 133
●
Resolve Source Ambiguity dialog box, page 134.
Breakpoints
See also:
●
Reference information on C-SPY system macros, page 319
●
Reference information on trace, page 180.
Breakpoints window
The Breakpoints window is available from the View menu.
This window lists all breakpoints you define.
Use this window to conveniently monitor, enable, and disable breakpoints; you can also
define new breakpoints and modify existing breakpoints.
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.
115
AFE1_AFE2-1:1
Reference information on breakpoints
Context menu
This context menu is available:
These commands are available:
Go to Source
Moves the insertion point to the location of the breakpoint, if the breakpoint has
a source location. Double-click a breakpoint in the Breakpoints window to
perform the same command.
Edit
Opens the breakpoint dialog box for the breakpoint you selected.
Delete
Deletes the breakpoint. Press the Delete key to perform the same command.
Enable
Enables the breakpoint. The check box at the beginning of the line will be
selected. You can also perform the command by manually selecting the check
box. This command is only available if the breakpoint is disabled.
Disable
Disables the breakpoint. The check box at the beginning of the line will be
deselected. You can also perform this command by manually deselecting the
check box. This command is only available if the breakpoint is enabled.
Enable All
Enables all defined breakpoints.
Disable All
Disables all defined breakpoints.
New Breakpoint
Displays a submenu where you can open the breakpoint dialog box for the
available breakpoint types. All breakpoints you define using this dialog box are
preserved between debug sessions.
C-SPY® Debugging Guide
116
for MSP430
AFE1_AFE2-1:1
Breakpoints
Breakpoint Usage window
The Breakpoint Usage window is available from the menu specific to the C-SPY driver
you are using.
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 FET debugger driver, page 106.
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.
117
AFE1_AFE2-1:1
Reference information on breakpoints
Code breakpoints dialog box
The Code breakpoints dialog box is available from the context menu in the editor
window, Breakpoints window, and in the Disassembly window.
This figure reflects the C-SPY simulator.
Use the Code breakpoints dialog box to set a code breakpoint, see Setting breakpoints
using the dialog box, page 109.
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 132.
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.
Note: The Size option is not available for the C-SPY FET Debugger driver.
C-SPY® Debugging Guide
118
for MSP430
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 112.
Conditions
Specify simple or complex conditions:
Expression
Specify a valid C-SPY expression, see C-SPY expressions, page 80.
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.
Log breakpoints dialog box
The Log breakpoints dialog box is available from the context menu in the editor
window, Breakpoints window, and in the Disassembly window.
This figure reflects the C-SPY simulator.
Use the Log breakpoints dialog box to set a log breakpoint, see Setting breakpoints
using the dialog box, page 109.
119
AFE1_AFE2-1:1
Reference information on breakpoints
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 132.
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.
C-SPY macro "__message" style
Select this option to make a comma-separated list of arguments specified in the Message
text box be treated exactly as the arguments to the C-SPY macro language statement
__message, see Formatted output, page 315.
Conditions
Specify simple or complex conditions:
Expression
Specify a valid C-SPY expression, see C-SPY expressions, page 80.
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.
C-SPY® Debugging Guide
120
for MSP430
AFE1_AFE2-1:1
Breakpoints
Data breakpoints dialog box
The Data breakpoints dialog box is available from the context menu in the editor
window, Breakpoints window, the Memory window, and in the Disassembly window.
This figure reflects the C-SPY simulator.
Use the Data breakpoints dialog box to set a data breakpoint, see Setting breakpoints
using the dialog box, page 109. Data breakpoints never stop execution within a single
instruction. They are recorded and reported after the instruction is executed.
Requirements
The C-SPY simulator.
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 132.
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.
121
AFE1_AFE2-1:1
Reference information on breakpoints
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 112.
Conditions
Specify simple or complex conditions:
Expression
Specify a valid C-SPY expression, see C-SPY expressions, page 80.
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.
C-SPY® Debugging Guide
122
for MSP430
AFE1_AFE2-1:1
Breakpoints
Data Log breakpoints dialog box
The Data Log breakpoints dialog box is available from the context menu in the
Breakpoints window.
This figure reflects the C-SPY simulator.
Use the Data Log breakpoints dialog box to set a maximum of four data log breakpoints
on memory addresses, see Setting breakpoints using the dialog box, page 109.
See also Data Log breakpoints, page 105 and Getting started using data logging, page
196.
Requirements
The C-SPY simulator.
Break At
Specify a memory location as a variable (with static storage duration) or as an address.
Access Type
Selects the type of access to the variable that generates a log entry:
Read/Write
Read and write accesses from or writes to location of the variable.
Read
Read accesses from the location of the variable.
Write
Write accesses to location of the variable.
123
AFE1_AFE2-1:1
Reference information on breakpoints
Immediate breakpoints dialog box
The Immediate breakpoints dialog box is available from the context menu in the editor
window, Breakpoints window, the Memory window, and in the Disassembly window.
In the C-SPY simulator, use the Immediate breakpoints dialog box to set an immediate
breakpoint, see Setting breakpoints using the dialog box, page 109. 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 132.
Access Type
Selects the type of memory access that triggers the breakpoint:
Read
Reads from location.
Write
Writes to location.
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 112.
C-SPY® Debugging Guide
124
for MSP430
AFE1_AFE2-1:1
Breakpoints
Range breakpoints dialog box
The Range breakpoints dialog box is available from the context menu in the
Breakpoints window and the Memory window.
Use the Range breakpoints dialog box to set a range breakpoint.
Range breakpoints are available for the C-SPY FET Debugger driver on devices that
support the Enhanced Emulation Module at the required level.
Requirements
The C-SPY FET Debugger driver.
Start value
Specify the start value for the range breakpoint in the Start value text box; an
expression, an absolute address, or a source location. Alternatively, click the Edit button
to open the Enter Location dialog box; see Enter Location dialog box, page 132.
Range delimiter
Sets the end location of the range. Choose the type of delimiter and specify the value in
the text box:
End value
The same type of value as for the Start value.
Length
The length of the range in bytes (in hexadecimal notation).
125
AFE1_AFE2-1:1
Reference information on breakpoints
Automatic
Bases the range automatically on the type of expression the breakpoint is set on.
For example, if you set the breakpoint on a 12-byte structure, the range of the
breakpoint will be 12 bytes.
Type
Selects which breakpoint type to use:
Address (MAB)
Sets a breakpoint on a specified address, or anything that can be evaluated to
one. The breakpoint is triggered when the specified location is accessed. If you
have set the breakpoint on a specific machine instruction, the breakpoint will be
triggered and the execution will stop exactly before the instruction will be
executed.
Data (MDB)
Sets a breakpoint on a specified value. It is the value on the data bus that triggers
the breakpoint.
Access type
Selects the type of access that triggers the selected breakpoint:
Read
Read from location.
Write
Write to location.
Read/Write
Read from or write to location.
Fetch
At instruction fetch.
Action
Selects the action that occurs when the breakpoint is triggered:
Break
The execution stops when the breakpoint is triggered.
State Storage Trigger
Defines the breakpoint as a state storage trigger. To control the behavior of the
state storage module, see State Storage Control window, page 294.
C-SPY® Debugging Guide
126
for MSP430
AFE1_AFE2-1:1
Breakpoints
Action when
Selects when the action shall occur:
Inside range
The action occurs at an access inside the specified range.
Outside range
The action occurs at an access outside of the specified range.
Conditional breakpoints dialog box
The Conditional breakpoints dialog box is available from the context menu in the
Breakpoints window and the Disassembly window.
Use the Conditional breakpoints dialog box to set a conditional breakpoint.
Conditional breakpoints are available for the C-SPY FET Debugger driver on devices
that support the Enhanced Emulation Module at the required level.
Requirements
The C-SPY FET Debugger driver.
Break At
Specify the location for the breakpoint in the Break At text box. Alternatively, click the
Edit button to open the Enter Location dialog box; see Enter Location dialog box, page
132.
127
AFE1_AFE2-1:1
Reference information on breakpoints
Type
Selects which breakpoint type to use:
Address bus (MAB)
Sets a breakpoint on the address specified in the Break At text box, or anything
that can be evaluated to one. The breakpoint is triggered when the specified
location is accessed. If you have set the breakpoint on a specific machine
instruction, the breakpoint will be triggered and the execution will stop exactly
before the instruction will be executed.
Data bus (MDB)
Sets a breakpoint on a specified value. It is the value on the data bus that triggers
the breakpoint.
Register
Sets a breakpoint on a register. Specify the register, or anything that can be
evaluated to such, in the Break At text box. In the Register Value text box, type
the value that should trigger the breakpoint.
Operator
Selects a condition operator for when the breakpoint should be triggered:
==
Equal to.
>=
Greater than or equal to.
<=
Less than or equal to.
!=
Not equal to.
Access
Selects the type of access that triggers the selected breakpoint:
Read
Read from location.
Write
Write to location.
Read/Write
Read from or write to location.
C-SPY® Debugging Guide
128
for MSP430
AFE1_AFE2-1:1
Breakpoints
Fetch
At instruction fetch.
Mask
Specify a bit mask value that the breakpoint address or value will be masked with. (On
the FET hardware the mask is inverted, but this is not the case in the FET Debugger
driver.)
Condition
Optionally, specify an additional condition to a conditional breakpoint. This means that
a conditional breakpoint can be a single data breakpoint or a combination of two
breakpoints that must occur at the same time. These settings can be specified for the
additional condition:
MDB/Register Value
The extra conditional data value.
Mask
The bit mask value that the breakpoint value will be masked with.
Operator
The operator of condition, either ==, >=, <=, or !=.
Access
The access type of the condition, either Read, Write, or Read/Write.
Action
Selects the action that occurs when the breakpoint is triggered:
Break
The execution stops when the breakpoint is triggered.
State Storage Trigger
State storage starts when the breakpoint is triggered. To control the behavior of
the state storage module, see State Storage Control window, page 294.
Cycle Counter Trigger
Starts, stops, resets, or counts the Cycle counter 1. To control the behavior of the
cycle counter, see The advanced cycle counter, page 283.
129
AFE1_AFE2-1:1
Reference information on breakpoints
Advanced Trigger breakpoints dialog box
The Advanced Trigger breakpoints dialog box is available from the context menu in
the Breakpoints window and the Disassembly window.
Use the Advanced Trigger breakpoints dialog box to set an advanced trigger
breakpoint.
Advanced trigger breakpoints are available for the C-SPY FET Debugger driver on
devices that support the Enhanced Emulation Module at the required level.
Requirements
The C-SPY FET Debugger driver.
Break At
Specify the location for the breakpoint in the Break At text box. Alternatively, click the
Edit button to open the Enter Location dialog box; see Enter Location dialog box, page
132.
Type
Selects which breakpoint type to use:
Address bus (MAB)
Sets a breakpoint on a specified address, or anything that can be evaluated to
one. The breakpoint is triggered when the specified location is accessed. If you
have set the breakpoint on a specific machine instruction, the breakpoint will be
triggered and the execution will stop exactly before the instruction will be
executed.
C-SPY® Debugging Guide
130
for MSP430
AFE1_AFE2-1:1
Breakpoints
Data bus (MDB)
Sets a breakpoint on a specified value. It is the value on the data bus that triggers
the breakpoint.
Register
Sets a breakpoint on a register. Specify the register, or anything that can be
evaluated to such, in the Break At text box. In the Value text box, type the value
that should trigger the breakpoint.
Operator
Selects a condition operator for when the breakpoint should be triggered:
==
Equal to.
>=
Greater than or equal to.
<=
Less than or equal to.
!=
Not equal to.
Mask
Specify a bit mask value that the breakpoint address or value will be masked with. (On
the FET hardware the mask is inverted, but this is not the case in the FET Debugger
driver.)
Value
Specify the data value in the specified register that should be triggered.
Access type
Selects the type of access that triggers the selected breakpoint.
Action
Selects the action that occurs when the breakpoint is triggered:
Break
The execution stops when the breakpoint is triggered.
131
AFE1_AFE2-1:1
Reference information on breakpoints
State Storage Trigger
State storage starts when the breakpoint is triggered. To control the behavior of
the state storage module, see State Storage Control window, page 294.
Cycle Counter Trigger
Starts, stops, resets, or counts the Cycle counter 1. To control the behavior of the
cycle counter, see The advanced cycle counter, page 283.
Enter Location dialog box
The Enter Location dialog box is available from the breakpoints dialog box, either
when you set a new breakpoint or when you edit a breakpoint.
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
80.
C-SPY® Debugging Guide
132
for MSP430
AFE1_AFE2-1:1
Breakpoints
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
138.
Source location
A location in your C source code using the syntax:
{filename}.row.column.
filename specifies the filename and full path.
row specifies the row in which you want the breakpoint.
column specifies the column in which you want the breakpoint.
For example, {C:\src\prog.c}.22.3
sets a breakpoint on the third character position on row 22 in the source file
prog.c. Note that in quoted form, for example in a C-SPY macro, you must
instead write {C:\\src\\prog.c}.22.3.
Note that the Source location type is usually meaningful only for code locations
in code breakpoints. Depending on the C-SPY driver you are using, Source
location might not be available for data and immediate breakpoints.
Breakpoint combiner dialog box
The Breakpoint combiner dialog box is available from the Emulator menu.
Use this dialog box to combine two already defined breakpoints.
133
AFE1_AFE2-1:1
Reference information on breakpoints
Select a breakpoint and right-click to display a list of breakpoints to combine it with.
When two breakpoints have been combined, the defined action will not occur until both
breakpoints have been reached.
Note: Only available for devices that support the Enhanced Emulation Module at the
required level. The settings are not saved when the debug session is closed.
Requirements
The C-SPY FET Debugger driver.
Resolve Source Ambiguity dialog box
The Resolve Source Ambiguity dialog box appears, for example, when you try to set a
breakpoint on templates and the source location corresponds to more than one function.
To resolve a source ambiguity, perform one of these actions:
●
In the text box, select one or several of the listed locations and click Selected.
●
Click All.
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.
C-SPY® Debugging Guide
134
for MSP430
AFE1_AFE2-1:1
Breakpoints
Cancel
No location will be used.
Automatically choose all
Determines that whenever a specified source location corresponds to more than one
function, all locations will be used.
Note that this option can also be specified in the IDE Options dialog box, see Debugger
options in the IDE Project Management and Building Guide.
135
AFE1_AFE2-1:1
Reference information on breakpoints
C-SPY® Debugging Guide
136
for MSP430
AFE1_AFE2-1:1
Memory and registers
●
Introduction to monitoring memory and registers
●
Monitoring memory and registers
●
Reference information on memory and registers
Introduction to monitoring memory and registers
These topics are covered:
●
Briefly about monitoring memory and registers
●
C-SPY memory zones
●
Memory configuration for the C-SPY simulator
BRIEFLY ABOUT MONITORING MEMORY AND REGISTERS
C-SPY provides many windows for monitoring memory and registers, each of them
available from the View menu:
●
The Memory window
Gives an up-to-date display of a specified area of memory—a memory zone—and
allows you to edit it. Data coverage along with execution of your application is
highlighted with different colors. You can fill specified areas with specific values and
you can set breakpoints directly on a memory location or range. You can open several
instances of this window, to monitor different memory areas. The content of the
window can be regularly updated while your application is executing.
●
The Symbolic Memory window
Displays how variables with static storage duration 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 by buffer overruns.
●
The Stack window
Displays the contents of the stack, including how stack variables are laid out in
memory. In addition, integrity checks of the stack can be performed to detect and
warn about problems with stack overflow. For example, the Stack window is useful
for determining the optimal size of the stack. You can open up to two instances of
this window, each showing different stacks or different display modes of the same
stack.
137
AFE1_AFE2-1:1
Introduction to monitoring memory and registers
●
The Registers window
Gives an up-to-date display of the contents of the processor registers and SFRs, and
allows you to edit them. Because of the large amount of registers—memory-mapped
peripheral unit registers and CPU registers—it is inconvenient to show all registers
concurrently in the Registers window. Instead you can divide registers into
application-specific groups. You can choose to load either predefined register groups
or define your own groups. You can open several instances of this window, each
showing a different register group.
●
The SFR Setup window
Displays the currently defined SFRs that C-SPY has information about, both
factory-defined (retrieved from the device description file) and custom-defined
SFRs. If required, you can use the Edit SFR dialog box to customize the SFR
definitions.
To view the memory contents for a specific variable, simply drag the variable to the
Memory window or the Symbolic memory window. The memory area where the
variable is located will appear.
Reading the value of some registers might influence the runtime behavior of your
application. For example, reading the value of a UART status register might reset a
pending bit, which leads to the lack of an interrupt that would have processed a received
byte. To prevent this from happening, make sure that the Registers window containing
any such registers is closed when debugging a running application.
C-SPY MEMORY ZONES
In C-SPY, the term zone is used for a named memory area. A memory address, or
location, is a combination of a zone and a numerical offset into that zone. The MSP430
C-SPY® Debugging Guide
138
for MSP430
AFE1_AFE2-1:1
Memory and registers
architecture has only one zone, Memory, which covers the whole MSP430 memory
range.
0x0000
SFR
0x0000
0x0200
RAM
0x0A00
0x1100
Flash
0xFFFFFFFF
0xFFFF
Default zone Memory
0xFFFF
Additional zones for MSP430F149
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.
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.
These zones are available, depending on the device description file you are using: SFR,
RAM, INFO, and Flash. Some devices have FRAM instead of Flash.
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 44 and Modifying a
device description file, page 48.
MEMORY CONFIGURATION FOR THE C-SPY SIMULATOR
To simulate the target system properly, the C-SPY simulator needs information about
the memory configuration. By default, C-SPY uses a configuration based on
information retrieved from the device description file.
139
AFE1_AFE2-1:1
Monitoring memory and registers
The C-SPY simulator provides various mechanisms to improve the configuration
further:
●
●
If the default memory configuration does not specify the required memory address
ranges, you can specify the memory address ranges shall be based on:
●
The zones predefined in the device description file
●
The section information available in the debug file
●
Or, you can define your own memory address ranges, which you typically might
want to do if the files do not specify memory ranges for the specific device that
you are using, but instead for a family of devices (perhaps with various amounts
of on-chip RAM).
For each memory address range, you can specify an access type. If a memory access
occurs that does not agree with the specified access type, C-SPY will regard this as
an illegal access and warn about it. In addition, an access to memory that is not
defined is regarded as an illegal access. The purpose of memory access checking is
to help you to identify memory access violations.
For more information, see Memory Access Setup dialog box, page 169.
Monitoring memory and registers
These tasks are covered:
C-SPY® Debugging Guide
140
for MSP430
AFE1_AFE2-1:1
●
Defining application-specific register groups, page 141
●
Monitoring stack usage, page 142
Memory and registers
DEFINING APPLICATION-SPECIFIC REGISTER GROUPS
Defining application-specific register groups minimizes the amount of registers
displayed in the Registers windows and makes the debugging easier.
1 Choose View>Registers>Register User Groups Setup during a debug session.
Right-clicking in the window displays a context menu with commands. For information
about these commands, see Register User Groups Setup window, page 162.
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.
Note: If a certain SFR that you need cannot be added to a group, you can register your
own SFRs. For more information, see SFR Setup window, page 164.
141
AFE1_AFE2-1:1
Monitoring memory and registers
MONITORING STACK USAGE
These are the two main use cases for the Stack window:
●
Monitoring stack memory usage
●
Monitoring the stack memory content.
In both cases, C-SPY retrieves information about the defined stack size and its allocation
from the definition in the linker configuration file of the segment holding the stack. If
you, for some reason, have modified the stack initialization in the system startup code,
cstartup, you should also change the segment definition in the linker configuration
file accordingly; otherwise the Stack window cannot track the stack usage. For more
information about this, see the IAR C/C++ Compiler User Guide for MSP430.
To monitor stack memory usage:
1 Before you start C-SPY, choose Tools>Options. On the Stack page:
●
Select Enable graphical stack display and stack usage tracking. This option also
enables the option Warn when exceeding stack threshold. Specify a suitable
threshold value.
●
Notice also the option Warn when stack pointer is out of bounds. Any such
warnings are displayed in the Debug Log window.
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.
C-SPY® Debugging Guide
142
for MSP430
AFE1_AFE2-1:1
Memory and registers
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.
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.
See also the IAR C/C++ Compiler User Guide for MSP430 for information about stack
usage analysis.
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.
143
AFE1_AFE2-1:1
Reference information on memory and registers
4 Start executing your application.
Whenever execution stops, you can monitor the stack memory, for example to see
function parameters that are passed on the stack:
Reference information on memory and registers
Reference information about:
C-SPY® Debugging Guide
144
for MSP430
AFE1_AFE2-1:1
●
Memory window, page 145
●
Memory Save dialog box, page 149
●
Memory Restore dialog box, page 150
●
Fill dialog box, page 151
●
Symbolic Memory window, page 152
●
Stack window, page 155
●
Registers window, page 159
●
Register User Groups Setup window, page 162
●
SFR Setup window, page 164
●
Edit SFR dialog box, page 167
●
Memory Access Setup dialog box, page 169
●
Edit Memory Access dialog box, page 171.
●
Memory Dump dialog box, page 172
Memory and registers
Memory window
The Memory window is available from the View menu.
This window gives an up-to-date display of a specified area of memory—a memory
zone—and allows you to edit it. You can open several instances of this window, which
is very convenient if you want to keep track of several memory or register zones, or
monitor different parts of the memory.
To view the memory corresponding to a variable, you can select it in the editor window
and drag it to the Memory window.
See also Editing in C-SPY windows, page 47.
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 138.
Context menu button
Displays the context menu.
145
AFE1_AFE2-1:1
Reference information on memory and registers
Update Now
Updates the content of the Memory window while your application is
executing. This button is only enabled if the C-SPY driver you are using has
access to the target system memory while your application is executing.
Live Update
Updates the contents of the Memory window regularly while your application
is executing. This button is only enabled if the C-SPY driver you are using has
access to the target system memory while your application is executing. To set
the update frequency, specify an appropriate frequency in the IDE
Options>Debugger dialog box.
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:
Yellow
Indicates data that has been read.
Blue
Indicates data that has been written
Green
Indicates data that has been both read and written.
Note: Data coverage is not supported by all C-SPY drivers. Data coverage is supported
by the C-SPY Simulator.
C-SPY® Debugging Guide
146
for MSP430
AFE1_AFE2-1:1
Memory and registers
Context menu
This context menu is available:
These commands are available:
Copy, Paste
Standard editing commands.
Zone
Selects a memory zone, see C-SPY memory zones, page 138.
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.
147
AFE1_AFE2-1:1
Reference information on memory and registers
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.
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.
Memory Fill
Displays a dialog box, where you can fill a specified area with a value, see Fill
dialog box, page 151.
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 149.
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 150.
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 111.
C-SPY® Debugging Guide
148
for MSP430
AFE1_AFE2-1:1
Memory and registers
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
105 and Getting started using data logging, page 196.
Memory Save dialog box
The Memory Save dialog box is available by choosing Debug>Memory>Save or from
the context menu in the Memory window.
Use this dialog box to save the contents of a specified memory area to a file.
Requirements
None; this dialog box is always available.
Zone
Selects a memory zone, see C-SPY memory zones, page 138.
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 msp430-txt by default.
149
AFE1_AFE2-1:1
Reference information on memory and registers
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.
Memory Restore dialog box
The Memory Restore dialog box is available by choosing Debug>Memory>Restore
or from the context menu in the Memory window.
Use this dialog box to load the contents of a file in Intel-extended, Motorola S-record,
or TI msp430-txt 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 138.
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.
C-SPY® Debugging Guide
150
for MSP430
AFE1_AFE2-1:1
Memory and registers
Fill dialog box
The Fill dialog box is available from the context menu in the Memory window.
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 138.
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.
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.
151
AFE1_AFE2-1:1
Reference information on memory and registers
OR
An OR operation will be performed between Value and the existing contents of
memory before writing the result to memory.
Symbolic Memory window
The Symbolic Memory window is available from the View menu during a debug
session.
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 47.
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 138.
C-SPY® Debugging Guide
152
for MSP430
AFE1_AFE2-1:1
Memory and registers
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.
153
AFE1_AFE2-1:1
Reference information on memory and registers
Context menu
This context menu is available:
These commands are available:
Next Symbol
Highlights the next symbol in the display area.
Previous Symbol
Highlights the previous symbol in the display area.
1x Units
Displays the memory contents as single bytes. This applies only to rows which
do not contain a variable.
2x Units
Displays the memory contents as 2-byte groups.
4x Units
Displays the memory contents as 4-byte groups.
Add to Watch
Adds the selected symbol to the Watch window.
Add to Live Watch
Adds the selected symbol to the Live Watch window.
Default format
Displays the memory contents in the default format.
Binary format
Displays the memory contents in binary format.
C-SPY® Debugging Guide
154
for MSP430
AFE1_AFE2-1:1
Memory and registers
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 107.
For information about options specific to the Stack window, see the IDE Project
Management and Building Guide.
Requirements
None; this window is always available.
155
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.
The graphical stack bar
Displays the state of the stack graphically.
The left end of the stack bar represents the bottom of the stack, in other words, the
position of the stack pointer when the stack is empty. The right end represents the end
of the memory address range reserved for the stack. The graphical stack bar turns red
when the stack usage exceeds a threshold that you can specify.
To enable the stack bar, choose Tools>Options>Stack>Enable graphical stack
display and stack usage tracking. This means that the functionality needed to detect
and warn about stack overflows is enabled.
Place the mouse pointer over the stack bar to get tooltip information about stack usage.
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.
C-SPY® Debugging Guide
156
for MSP430
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:
These commands are available:
Show variables
Displays separate columns named Variables, Value, and Frame in the Stack
window. Variables located at memory addresses listed in the Stack window are
displayed in these columns.
Show offsets
Displays locations in the Location column as offsets from the stack pointer.
When deselected, locations are displayed as absolute addresses.
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.
157
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.
C-SPY® Debugging Guide
158
for MSP430
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 47.
To enable predefined register groups:
1 Select a device description file that suits your device, see Selecting a device description
file, page 44.
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 141.
Requirements
None; this window is always available.
159
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.
Note: When the FET Debugger is used, the cycle counter registers can only be used
while single-stepping in the Disassembly window.
C-SPY® Debugging Guide
160
for MSP430
AFE1_AFE2-1:1
Memory and registers
For the C-SPY Simulator (and some C-SPY hardware debugger drivers), these
additional support registers are available in the group:
CYCLECOUNTER
Cleared when an application is started or reset and is
incremented with the number of used cycles during
execution.
CCSTEP
Shows the number of used cycles during the last performed
C/C++ source or assembler step.
CCTIMER1 and
CCTIMER2
Two trip counts that can be cleared manually at any given
time. They are incremented with the number of used cycles
during execution.
Context menu
This context menu is available:
These commands are available:
View Group
Selects which predefined register group to display, by default CPU Registers.
If some of your SFRs are missing, you can register your own SFRs in a Custom
group, see SFR Setup window, page 164. Additional predefined registers are
defined in a specific register definition file—with the filename extension sfr—
which is included from the register section of the device description file. These
registers are the device-specific memory-mapped control and status registers for
the peripheral units on the MSP430 microcontrollers.
View User Group
Selects which user-defined register group to display. For information about
creating your own user-defined register groups, see Defining
application-specific register groups, page 141.
Format
Changes the display format for the contents of the register you clicked on. The
display format setting affects different types of registers in different ways. Your
selection of display format is saved between debug sessions.
161
AFE1_AFE2-1:1
Reference information on memory and registers
Open User Groups Setup Window
Opens a window where you can create your own user-defined register groups,
see Register User Groups Setup window, page 162.
Save to File
Opens a standard save dialog box to save the contents of the window to a
tab-separated text file.
Register User Groups Setup window
The Register User Groups Setup window is available from the View menu or from the
context menu in the Registers windows.
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.
C-SPY® Debugging Guide
162
for MSP430
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:
These commands are available:
Format
Changes the display format for the contents of the register you clicked on. The
display format setting affects different types of registers in different ways. Your
selection of display format is saved between debug sessions.
Remove
Removes the register or group you clicked on.
Clear Group
Removes all registers from the group you clicked on.
Remove All Groups
Deletes all user-defined register groups from your project.
Save to File
Opens a standard save dialog box to save the contents of the window to a
tab-separated text file.
163
AFE1_AFE2-1:1
Reference information on memory and registers
SFR Setup window
The SFR Setup window is available from the Project menu.
This window displays the currently defined SFRs that C-SPY has information about.
You can choose to display only factory-defined or custom-defined SFRs, or both. If
required, you can use the Edit SFR dialog box to customize the SFR definitions, see
Edit SFR dialog box, page 167. For factory-defined SFRs (that is, retrieved from the ddf
file in use), you can only customize the access type.
To quickly find an SFR, drag a text or hexadecimal number string and drop in this
window. If what you drop starts with a 0 (zero), the Address column is searched,
otherwise the Name column is searched.
Any custom-defined SFRs are added to a dedicated register group called Custom, which
you can choose to display in the Register window. Your custom-defined SFRs are saved
in projectCustomSFR.sfr. This file is automatically loaded in the IDE when you
start C-SPY with a project whose name matches the prefix of the filename of the sfr
file.
You can only add or modify SFRs when the C-SPY debugger is not running.
Requirements
None; this window is always available.
Display area
This area contains these columns:
Status
A character that signals the status of the SFR, which can be one of:
blank, a factory-defined SFR.
C, a factory-defined SFR that has been modified.
+, a custom-defined SFR.
C-SPY® Debugging Guide
164
for MSP430
AFE1_AFE2-1:1
Memory and registers
?, an SFR that is ignored for some reason. An SFR can be ignored when a
factory-defined SFR has been modified, but the SFR is no longer available, or it
is located somewhere else or with a different size. Typically, this might happen
if you change to another device.
Name
A unique name of the SFR.
Address
The memory address of the SFR.
Zone
Selects a memory zone, see C-SPY memory zones, page 138.
Size
The size of the register, which can be any of 8, 16, 32, or 64.
Access
The access type of the register, which can be one of Read/Write, Read only,
Write only, or None.
You can click a name or an address to change the value. The hexadecimal 0x prefix for
the address can be omitted, the value you enter will still be interpreted as hexadecimal.
For example, if you enter 4567, you will get 0x4567.
You can click a column header to sort the SFRs according to the column property.
Color coding used in the display area:
●
Green, which indicates that the corresponding value has changed
●
Red, which indicates an ignored SFR.
165
AFE1_AFE2-1:1
Reference information on memory and registers
Context menu
This context menu is available:
These commands are available:
Show All
Shows all SFR.
Show Custom SFRs only
Shows all custom-defined SFRs.
Show Factory SFRs only
Shows all factory-defined SFRs retrieved from the ddf file.
Add
Displays the Edit SFR dialog box where you can add a new SFR, see Edit SFR
dialog box, page 167.
Edit
Displays the Edit SFR dialog box where you can edit an SFR, see Edit SFR
dialog box, page 167.
Delete
Deletes an SFR. This command only works on custom-defined SFRs.
Delete/revert All Custom SFRs
Deletes all custom-defined SFRs and reverts all modified factory-defined SFRs
to their factory settings.
C-SPY® Debugging Guide
166
for MSP430
AFE1_AFE2-1:1
Memory and registers
Save Custom SFRs
Opens a standard save dialog box to save all custom-defined SFRs.
8|16|32|64 bits
Selects display format for the selected SFR, which can be 8, 16, 32, or 64 bits.
Note that the display format can only be changed for custom-defined SFRs.
Read/Write|Read only|Write only|None
Selects the access type of the selected SFR, which can be Read/Write, Read
only, Write only, or None. Note that for factory-defined SFRs, the default
access type is indicated.
Edit SFR dialog box
The Edit SFR dialog box is available from the context menu in the SFR Setup window.
Definitions of the SFRs are retrieved from the device description file in use. Use this
dialog box to either modify these factory-defined definitions or define new SFRs. See
also SFR Setup window, page 164.
Requirements
None; this dialog box is always available.
Name
Specify the name of the SFR that you want to add or edit.
167
AFE1_AFE2-1:1
Reference information on memory and registers
Address
Specify the address of the SFR that you want to add or edit. The hexadecimal 0x prefix
for the address can be omitted, the value you enter will still be interpreted as
hexadecimal. For example, if you enter 4567, you will get 0x4567.
Zone
Selects the memory zone for the SFR you want to add or edit. The list of zones is
retrieved from the ddf file that is currently used.
Size
Selects the size of the SFR. Choose between 8, 16, 32, or 64 bits. Note that the display
format can only be changed for custom-defined SFRs.
Access
Selects the access type of the SFR. Choose between Read/Write, Read only, Write
only, or None. Note that for factory-defined SFRs, the default access type is indicated.
C-SPY® Debugging Guide
168
for MSP430
AFE1_AFE2-1:1
Memory and registers
Memory Access Setup dialog box
The Memory Access Setup dialog box is available from the C-SPY driver menu.
Use this dialog box to specify which set of memory address ranges to be used by C-SPY
during debugging.
Note: If you enable both the Use ranges based on and the Use manual ranges option,
memory accesses are checked for all defined ranges.
For information about the columns and the properties displayed, see Edit Memory
Access dialog box, page 171. See also Memory configuration for the C-SPY simulator,
page 139
Requirements
The C-SPY simulator.
Use ranges based on
Specify if the memory configuration should be retrieved from a predefined
configuration. Choose between:
Device description file
Retrieves the memory configuration from the device description file that you
have specified. See Selecting a device description file, page 44.
This option is used by default.
169
AFE1_AFE2-1:1
Reference information on memory and registers
Debug file segment information
Retrieves the memory configuration from the debug file, which has retrieved it
from the linker configuration file. This information is only available during a
debug session. The advantage of using this option is that the simulator can catch
memory accesses outside the linked application.
Use manual ranges
Specify your own ranges manually via the Edit Memory Access dialog box. To open
this dialog box, click New to specify a new memory address range, or select an existing
memory address range and choose Edit to modify it. For more information, see Edit
Memory Access dialog box, page 171.
The ranges you define manually are saved between debug sessions.
Memory access checking
Check for determines what to check for:
●
Access type violation
●
Access to unspecified ranges
Action selects the action to be performed if an access violation occurs. Choose between:
●
Log violations
●
Log and stop execution
Any violations are logged in the Debug Log window.
Buttons
These buttons are available for manual ranges:
New
Opens the Edit Memory Access dialog box, where you can specify a new
memory address range and associate an access type with it, see Edit Memory
Access dialog box, page 171.
Edit
Opens the Edit Memory Access dialog box, where you can edit the selected
memory address range. See Edit Memory Access dialog box, page 171.
Delete
Deletes the selected memory address range definition.
Delete All
Deletes all defined memory address range definitions.
C-SPY® Debugging Guide
170
for MSP430
AFE1_AFE2-1:1
Memory and registers
Edit Memory Access dialog box
The Edit Memory Access dialog box is available from the Memory Access Setup
dialog box.
Use this dialog box to specify your memory address ranges for which you want to detect
illegal accesses during the simulation, and assign an access type to each range.
Requirements
The C-SPY simulator.
Memory range
Defines the memory address range specific to your device:
Zone
Selects a memory zone, see C-SPY memory zones, page 138.
Start address
Specify the start address for the memory address range, in hexadecimal
notation.
End address
Specify the end address for the memory address range, in hexadecimal notation.
Access type
Selects an access type to the memory address range. Choose between:
●
Read and write
●
Read only
●
Write only
171
AFE1_AFE2-1:1
Reference information on memory and registers
Memory Dump dialog box
The Memory Dump dialog box is available from the Emulator menu.
Use this dialog box to write memory contents to a file.
Requirements
The C-SPY FET Debugger driver.
Dump File Name
Specify the name of the destination file where the contents of the selected part of the
memory will be saved in text format. You can find the file using the Browse button.
Start Address
Specify the start address for the memory section you want to save to a file.
Dump Length
Specify the length of the memory section you want to save to a file, in hexadecimal
notation. The maximum length is FFFF, which limits the number of bytes that can be
written to 65535. Consequently, you cannot write memory from address 0x0000 to
0xFFFF, inclusive, as this would require a length specifier of 65536 bytes (0x10000).
Add address information
Adds address information to the file.
C-SPY® Debugging Guide
172
for MSP430
AFE1_AFE2-1:1
Memory and registers
Append register contents
Appends register contents to the file. Choose between:
Program Counter (R0)
Stack Pointer (R1)
Status Register (R2)
Register R4 to R15
Format
Selects format for the text that is written to the file. Choose between:
Word
Byte
173
AFE1_AFE2-1:1
Reference information on memory and registers
C-SPY® Debugging Guide
174
for MSP430
AFE1_AFE2-1:1
Part 2. Analyzing your
application
This part of the C-SPY® Debugging Guide for MSP430 includes these chapters:
●
Trace
●
The application timeline
●
Profiling
●
Code coverage
●
Power debugging
175
176
Trace
●
Introduction to using trace
●
Collecting and using trace data
●
Reference information on trace
Introduction to using trace
These topics are covered:
●
Reasons for using trace
●
Briefly about trace
●
Requirements for using trace
See also:
●
Getting started using data logging, page 196
●
Power debugging, page 235
●
Getting started using interrupt logging, page 268
●
Profiling, page 221
●
Using state storage, page 292
REASONS FOR USING TRACE
By using trace, you can inspect the program flow up to a specific state, for instance an
application crash, and use the trace data to locate the origin of the problem. Trace data
can be useful for locating programming errors that have irregular symptoms and occur
sporadically.
BRIEFLY ABOUT TRACE
To use trace in C-SPY requires that your target system can generate trace data. Once
generated, C-SPY can collect it and you can visualize and analyze the data in various
windows and dialog boxes.
Trace data is a continuously collected sequence of every executed instruction for a
selected portion of the execution.
177
AFE1_AFE2-1:1
Collecting and using trace data
Trace features in C-SPY
In C-SPY, you can use the trace-related windows Trace, Function Trace, Timeline, and
Find in Trace.
Depending on your C-SPY driver, you:
●
Can set various types of trace breakpoints to control the collection of trace data.
●
Have access to windows such as the Interrupt Log, Interrupt Log Summary,
Data Log, and Data Log Summary.
In addition, several other features in C-SPY also use trace data, features such as
Profiling, Code coverage, and Instruction profiling.
REQUIREMENTS FOR USING TRACE
The C-SPY simulator supports trace-related functionality, and there are no specific
requirements.
Trace data cannot be collected from the hardware debugger systems.
Collecting and using trace data
These tasks are covered:
●
Getting started with trace
●
Trace data collection using breakpoints
●
Searching in trace data
●
Browsing through trace data.
GETTING STARTED WITH TRACE
1 After you have built your application and started C-SPY, open the Trace window—
available from the driver-specific menu—and click the Activate button to enable
collecting trace data.
2 Start the execution. When the execution stops, for example because a breakpoint is
triggered, trace data is displayed in the Trace window. For more information about the
window, see Trace window, page 180.
C-SPY® Debugging Guide
178
for MSP430
AFE1_AFE2-1:1
Trace
TRACE DATA COLLECTION USING BREAKPOINTS
A convenient way to collect trace data between two execution points is to start and stop
the data collection using dedicated breakpoints. Choose between these alternatives:
●
In the editor or Disassembly window, position your insertion point, right-click, and
toggle a Trace Start or Trace Stop breakpoint from the context menu.
●
In the Breakpoints window, choose Trace Start or Trace Stop.
●
The C-SPY system macros __setTraceStartBreak and
__setTraceStopBreak can also be used.
For more information about these breakpoints, see Trace Start breakpoints dialog box,
page 185 and Trace Stop breakpoints dialog box, page 186, respectively.
SEARCHING IN TRACE DATA
When you have collected trace data, you can perform searches in the collected data to
locate the parts of your code or data that you are interested in, for example, a specific
interrupt or accesses of a specific variable.
You specify the search criteria in the Find in Trace dialog box and view the result in the
Find in Trace window.
The Find in Trace window is very similar to the Trace window, showing the same
columns and data, but only those rows that match the specified search criteria.
Double-clicking an item in the Find in Trace window brings up the same item in the
Trace window.
To search in your trace data:
1 On the Trace window toolbar, click the Find button.
2 In the Find in Trace dialog box, specify your search criteria.
Typically, you can choose to search for:
●
A specific piece of text, for which you can apply further search criteria
●
An address range
●
A combination of these, like a specific piece of text within a specific address range.
For more information about the various options, see Find in Trace dialog box, page 189.
3 When you have specified your search criteria, click Find. The Find in Trace window
is displayed, which means you can start analyzing the trace data. For more information,
see Find in Trace window, page 190.
179
AFE1_AFE2-1:1
Reference information on trace
BROWSING THROUGH TRACE DATA
To follow the execution history, simply look and scroll in the Trace window.
Alternatively, you can enter browse mode.
To enter browse mode, double-click an item in the Trace window, or click the Browse
toolbar button.
The selected item turns yellow and the source and disassembly windows will highlight
the corresponding location. You can now move around in the trace data using the up and
down arrow keys, or by scrolling and clicking; the source and Disassembly windows
will be updated to show the corresponding location. This is like stepping backward and
forward through the execution history.
Double-click again to leave browse mode.
Reference information on trace
Reference information about:
●
Trace window, page 180
●
Function Trace window, page 184
●
Trace Start breakpoints dialog box, page 185
●
Trace Stop breakpoints dialog box, page 186
●
Trace Expressions window, page 187
●
Find in Trace dialog box, page 189
●
Find in Trace window, page 190.
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 178.
Requirements
The C-SPY simulator.
C-SPY® Debugging Guide
180
for MSP430
AFE1_AFE2-1:1
Trace
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.
Find
Displays a dialog box where you can perform a search, see Find in Trace dialog
box, page 189.
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
187.
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.
181
AFE1_AFE2-1:1
Reference information on trace
Display area
This area displays a collected sequence of executed machine instructions. In addition,
the window can display trace data for expressions.
This area contains these columns for the C-SPY simulator:
#
A serial number for each row in the trace buffer. Simplifies the navigation within
the buffer.
Cycles
The number of cycles elapsed to this point.
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 187.
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.
C-SPY® Debugging Guide
182
for MSP430
AFE1_AFE2-1:1
Trace
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.
Find All
Displays a dialog box where you can perform a search in the Trace window, see
Find in Trace dialog box, page 189. The search results are displayed in the Find
in Trace window—available by choosing the View>Messages command, see
Find in Trace window, page 190.
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
187.
183
AFE1_AFE2-1:1
Reference information on trace
Function Trace window
The Function Trace window is available from the C-SPY driver menu during a debug
session.
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 180.
Display area
For information about the columns in the display area, see Trace window, page 180
C-SPY® Debugging Guide
184
for MSP430
AFE1_AFE2-1:1
Trace
Trace Start breakpoints dialog box
The Trace Start dialog box is available from the context menu that appears when you
right-click in the Breakpoints window.
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 186 and Trace data collection using
breakpoints, page 179.
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.
Alternatively, to modify an existing breakpoint, select a breakpoint in the Breakpoints
window and choose Edit on the context menu.
3 In the Trigger At text box, specify an expression, an absolute address, or a source
location. Click OK.
4 When the breakpoint is triggered, the trace data collection starts.
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 132.
185
AFE1_AFE2-1:1
Reference information on trace
Trace Stop breakpoints dialog box
The Trace Stop dialog box is available from the context menu that appears when you
right-click in the Breakpoints window.
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 185 and Trace data collection using
breakpoints, page 179.
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.
2 In the Breakpoints window, right-click and choose New Breakpoint>Trace Stop.
Alternatively, to modify an existing breakpoint, select a breakpoint in the Breakpoints
window and choose Edit on the context menu.
3 In the Trigger At text box, specify an expression, an absolute address, or a source
location. Click OK.
4 When the breakpoint is triggered, the trace data collection stops.
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 132.
C-SPY® Debugging Guide
186
for MSP430
AFE1_AFE2-1:1
Trace
Trace Expressions window
The Trace Expressions window is available from the Trace window toolbar.
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.
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.
187
AFE1_AFE2-1:1
Reference information on trace
Context menu
This context menu is available:
These commands are available:
Move Up
Moves the selected expression upward in the window.
Move Down
Moves the selected expression downward in the window.
Remove
Removes the selected expression from 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:
C-SPY® Debugging Guide
188
for MSP430
AFE1_AFE2-1:1
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.
Trace
Find in Trace dialog box
The Find in Trace dialog box is available by clicking the Find button on the Trace
window toolbar or by choosing Edit>Find and Replace>Find.
Note that the Edit>Find and Replace>Find command is context-dependent. It displays
the Find in Trace dialog box if the Trace window is the current window or the Find
dialog box if the editor window is the current window.
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 190.
See also Searching in trace data, page 179.
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 and Int and so on.
Match whole word
Searches only for the string when it occurs as a separate word. Otherwise int
will also find print, sprintf and so on.
Only search in one column
Searches only in the column you selected from the drop-down list.
189
AFE1_AFE2-1:1
Reference information on 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.
Find in Trace window
The Find in Trace window is available from the View>Messages menu. Alternatively,
it is automatically displayed when you perform a search using the Find in Trace dialog
box or perform a search using the Find in Trace command available from the context
menu in the editor window.
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 189.
See also Searching in trace data, page 179.
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.
C-SPY® Debugging Guide
190
for MSP430
AFE1_AFE2-1:1
The application timeline
●
Introduction to analyzing your application’s timeline
●
Analyzing your application’s timeline
●
Reference information on application timeline
Introduction to analyzing your application’s timeline
These topics are covered:
●
Briefly about analyzing the timeline
●
Requirements for timeline support
See also:
●
Trace, page 177
BRIEFLY ABOUT ANALYZING THE TIMELINE
C-SPY can provide information for various aspects of your application, collected when
the application is running. This can help you to analyze the application’s behavior.
You can view the timeline information in different representations:
●
As different graphs that correlate with the running application in relation to a shared
time axis.
●
As detailed logs
●
As summaries of the logs.
Depending on the capabilities of your hardware, the debug probe, and the C-SPY driver
you are using, t imeline information can be provided for:
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 71 and Function Trace
window, page 184, respectively.
191
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:
Interrupt
logging
●
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.
Based on interrupt logs collected by the trace system. Choose to display
the interrupt logs:
●
In the Timeline window, as a graph of the interrupt events during
the execution of your application.
●
In the Interrupt Log window and the Interrupt Log Summary
window.
Interrupt logging can, for example, help you locate which interrupts you
can fine-tune to make your application more efficient. For more
information, see the chapter Interrupts.
Power
logging
Based on logged power measurement samples generated by the debug
probe or associated hardware. Choose to display the power logs:
●
In the Timeline window, as a graph of the power measurement
samples. You can choose to display graphs for current, voltage, and
energy.
●
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 235.
State logging Based on logged activity—state changes—for peripheral units and
clocks, as well as for CPU modes 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 235.
C-SPY® Debugging Guide
192
for MSP430
AFE1_AFE2-1:1
The application timeline
REQUIREMENTS FOR TIMELINE SUPPORT
Target system
Call Stack
C-SPY simulator
Yes
Data
Interrupt
logging
logging
logging
Yes
—
Yes
—
Power
Table 7: Support for timeline information
Depending on the capabilities of the hardware, the debug probe, and the C-SPY driver
you are using, trace-based timeline information is supported for:
Target system
Call Stack
C-SPY simulator
Yes
C-SPY FET Debugger driver —
Data
Interrupt
State
Power
logging
logging
logging
logging
Yes
Yes
Yes
Yes
—
—
—
Table 8: Supported graphs in the Timeline window
For more information about requirements related to trace data, see Requirements for
using trace, page 178.
Analyzing your application’s timeline
These tasks are covered:
●
Displaying a graph in the Timeline window, page 194
●
Navigating in the graphs, page 194
●
Analyzing performance using the graph data, page 195
●
Getting started using data logging, page 196
●
Getting started using data sampling, page 197
See also:
●
Debugging in the power domain, page 242
●
Using the interrupt system, page 265
193
AFE1_AFE2-1:1
Analyzing your application’s timeline
DISPLAYING A GRAPH IN THE TIMELINE WINDOW
The Timeline window can display several graphs; follow this example procedure to
display any of these graphs. For an overview of the graphs and what they display, see
Briefly about analyzing the timeline, page 191.
1 Choose Project>Options>FET Debugger>Setup and select Enable ULP/LPMx.5
debug.
If you are using the C-SPY simulator, choose Simulator>Simulated Frequency to set
up a frequency that matches the simulated hardware.
2 Start C-SPY.
3 Choose Timeline from the C-SPY driver menu to open the Timeline window.
4 In the Timeline window, right-click in the window and choose Select graphs from the
context menu to select which graphs to be displayed.
5 In the Timeline window, right-click in the graph area and choose Enable from the
context menu to enable a specific graph.
6 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 123.
7 Click Go on the toolbar to start executing your application. The graphs that you have
enabled appear.
NAVIGATING IN THE GRAPHS
After you have performed the steps in Displaying a graph in the Timeline window, page
194, you can use any of these alternatives to navigate in the graph:
C-SPY® Debugging Guide
194
for MSP430
AFE1_AFE2-1:1
●
Right-click and from the context menu choose Zoom In or Zoom Out.
Alternatively, use the + and – keys. The graph zooms in or out depending on which
command you used.
●
Right-click in the graph and from the context menu choose Navigate and the
appropriate command to move backwards and forwards on the graph. Alternatively,
use any of the shortcut keys: arrow keys, Home, End, and Ctrl+End.
●
Double-click on a sample of interest to highlight the corresponding source code in
the editor window and in the Disassembly window.
●
Click on the graph and drag to select a time interval, which will correlate to the
running application. The selection extends vertically over all graphs, but appears
highlighted in a darker color for the selected graph. Press Enter or right-click and
The application timeline
from the context menu choose Zoom>Zoom to Selection. The selection zooms in.
Use the navigation keys in combination with the Shift key to extend the selection.
ANALYZING PERFORMANCE USING THE GRAPH DATA
The Timeline window provides a set of tools for analyzing the graph data.
1 In the Timeline window, right-click and choose Time Axis Unit from the context
menu. Select which unit to be used on the time axis; choose between Seconds and
Cycles. If Cycles is not available, the graphs are based on different clock sources.
2 Execute your application to display a graph, following the steps described in
Displaying a graph in the Timeline window, page 194.
3 Whenever execution stops, point at the graph with the mouse pointer to get detailed
tooltip information for that location.
Note that if you have enabled several graphs, you can move the mouse pointer over the
different graphs to get graph-specific information.
195
AFE1_AFE2-1:1
Analyzing your application’s timeline
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.
GETTING STARTED USING DATA LOGGING
1 To set a data log breakpoint, use one of these methods:
●
In the Breakpoints window, right-click and choose New Breakpoint>Data Log to
open the breakpoints dialog box. Set a breakpoint on the memory location that you
want to collect log information for. This can be specified either as a variable or as an
address.
●
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 105.
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.
C-SPY® Debugging Guide
196
for MSP430
AFE1_AFE2-1:1
The application timeline
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.
GETTING STARTED USING DATA SAMPLING
1 Choose C-SPY driver>Data Sample Setup to open the Data Sample Setup window.
2 In the Data Sample Setup window, perform these actions:
●
In the Expression column, type the name of the variable for which you want to
sample data. The variable must be an integral type with a maximum size of 32 bits
and you can specify up to four variables. Make sure that the checkbox is selected for
the variable that you want to sample.
●
In the Sampling interval column, type the number of milliseconds to pass between
the samples.
3 To view the result of data sampling, you must enable it in the window in question:
●
Choose C-SPY driver>Data Sample to open the Data Sample window. From the
context menu, choose Enable.
●
Choose C-SPY driver>Sampled Graphs to open the Sampled Graphs window.
From the context menu, choose Enable.
4 Start executing your application program. This starts the data sampling. When the
execution stops, for example because a breakpoint is triggered, you can view the result
either in the Data Sample window or as the Data Sample graph in the Sampled
Graphs window
5 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.
6 To disable data sampling, choose Disable from the context menu in each window
where you have enabled it.
Reference information on application timeline
Reference information about:
●
Timeline window—Call Stack graph, page 198
●
Timeline window—Data Log graph, page 201
●
Data Log window, page 205
●
Data Log Summary window, page 208
197
AFE1_AFE2-1:1
Reference information on application timeline
●
Viewing Range dialog box, page 218
See also:
●
Timeline window—Interrupt Log graph, page 280
●
Interrupt Log window, page 275
●
Interrupt Log Summary window, page 277
●
Power graph in the Timeline window, page 251
●
Power Log window, page 248
●
Timeline window—State Log graph, page 257
●
State Log window, page 252
●
State Log Summary window, page 254
Timeline window—Call Stack graph
The Timeline window is available from the C-SPY driver menu during a debug session.
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.
C-SPY® Debugging Guide
198
for MSP430
AFE1_AFE2-1:1
The application timeline
Requirements
The C-SPY simulator.
Display area for the Call Stack graph
Each function invocation is displayed as a horizontal bar which extends from the time
of entry until the return. Called functions are displayed above its caller. The horizontal
bars use four different colors:
●
Medium green for normal C functions with debug information
●
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.
199
AFE1_AFE2-1:1
Reference information on application timeline
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.
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.
C-SPY® Debugging Guide
200
for MSP430
AFE1_AFE2-1:1
The application timeline
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.
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.
Profile Selection
Enables profiling time intervals in the Function Profiler window. Note that this
command is only available if the C-SPY driver supports PC Sampling.
Timeline window—Data Log graph
The Timeline window is available from the C-SPY driver menu during a debug session.
201
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.
Display area for the Data Log graph
Where:
●
The label area at the left end of the graph displays the variable name or the address
for which you have specified the Data Log breakpoint.
●
The graph itself displays how the value of the variable changes over time. The label
area also displays the limits, or range, of the Y-axis for a variable. You can use the
context menu to change these limits. The graph is a graphical representation of the
information in the Data Log window, see Data Log window, page 205.
●
The graph can be displayed either as a thin line between consecutive logs or as a
rectangle for every log (optionally color-filled).
●
A red vertical line indicates overflow, which means that the communication channel
failed to transmit all data logs from the target system. A red question mark indicates
a log without a value.
At the bottom of the window, there is a shared time axis that uses seconds or cycles as
the time unit.
C-SPY® Debugging Guide
202
for MSP430
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.
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.
203
AFE1_AFE2-1:1
Reference information on application timeline
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.
Data Log
A heading that shows that the Data 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.
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 218.
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.
C-SPY® Debugging Guide
204
for MSP430
AFE1_AFE2-1:1
The application timeline
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.
Data Log window
The Data Log window is available from the C-SPY driver menu.
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 196.
205
AFE1_AFE2-1:1
Reference information on application timeline
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.
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 105.
C-SPY® Debugging Guide
206
for MSP430
AFE1_AFE2-1:1
The application timeline
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).
Context menu
This context menu is available:
These commands are available:
Enable
Enables the logging system. The system will log information also when the
window is closed.
Clear
Deletes the log information. Note that this will happen also when you reset the
debugger.
Hexadecimal
Toggles between displaying the selected value in decimal or hexadecimal
format. Note that this setting also affects the log window.
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.
207
AFE1_AFE2-1:1
Reference information on application timeline
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.
Data Log Summary window
The Data Log Summary window is available from the C-SPY driver menu.
This window displays a summary of data accesses to specific memory location or areas.
See also Getting started using data logging, page 196.
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 105.
Total Accesses
The total number of accesses.
C-SPY® Debugging Guide
208
for MSP430
AFE1_AFE2-1:1
The application timeline
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.
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.
209
AFE1_AFE2-1:1
Reference information on application timeline
Context menu
This context menu is available:
These commands are available:
Enable
Enables the logging system. The system will log information also when the
window is closed.
Clear
Deletes the log information. Note that this will happen also when you reset the
debugger.
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 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.
C-SPY® Debugging Guide
210
for MSP430
AFE1_AFE2-1:1
The application timeline
Sampled Graphs window
The Sampled Graphs window is available from the C-SPY driver menu.
Use this window to display graphs for up to four different variables, and where:
●
The graph displays how the value of the variable changes over time. The area on the
left displays the limits, or range, of the Y-axis for the variable. You can use the
context menu to change these limits. The graph is a graphical representation of the
information in the Data Sample window, see Data Sample window, page 216.
●
The graph can be displayed as levels, where a horizontal line—optionally
color-filled—shows the value until the next sample. Alternatively, the graph can be
linear, where a line connects consecutive samples.
●
A red vertical line indicates the time of application execution stops.
At the bottom of the window, there is a shared time axis that uses seconds as the time
unit.
To navigate in the graph, use any of these alternatives:
●
Right-click and choose Zoom In or Zoom Out from the context menu.
Alternatively, use the + and – keys to zoom.
●
Right-click in the graph and choose Navigate and the appropriate command to
move backward and forward on the graph. Alternatively, use any of the shortcut
keys: arrow keys, Home, End, and Ctrl+End.
●
Double-click on a sample to highlight the corresponding source code in the editor
window and in the Disassembly window.
●
Click on the graph and drag to select a time interval. Press Enter or right-click and
choose Zoom>Zoom to Selection from the context menu. The selection zooms in.
Hover with the mouse pointer in the graph to get detailed tooltip information for that
location.
211
AFE1_AFE2-1:1
Reference information on application timeline
See also Getting started using data sampling, page 197.
The graphs require hardware breakpoints. To preserve the required hardware
breakpoints, use the option Use only emulated breakpoints, see Breakpoints, page 398.
Requirements
A device that supports the trace buffer.
Context menu
This context menu is available:
These commands are available:
Navigate
Commands for navigating in the graphs. Choose between:
Next moves the selection to the next relevant point in the graph. Shortcut key:
right arrow.
Previous moves the selection 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.
C-SPY® Debugging Guide
212
for MSP430
AFE1_AFE2-1:1
The application timeline
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: -.
1us, 10us, 100us makes an interval of 1 microseconds, 10 microseconds, or 100
microseconds, respectively, fit the window.
1ms, 10ms, 100ms makes an interval of 1 millisecond, 10 milliseconds, or 100
milliseconds, respectively, fit the window.
1s, 10s, 100s makes an interval of 1 second, 10 seconds, or 100 seconds,
respectively, fit the window.
1k s, 10k s, 100k s makes an interval of 1,000 seconds, 10,000 seconds, or
100,000 seconds, respectively, fit the window.
1M s, 10M s, makes an interval of 1,000,000 seconds or 10,000,000 seconds,
respectively, fit the window.
Data Sample
A menu item that shows that the Data Sample-specific commands below are
available.
Open Setup window (Data Sample Graph)
Opens the Data Sample Setup window.
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
Clears the sampled data.
213
AFE1_AFE2-1:1
Reference information on application timeline
Variable
The name of the variable for which the Data Sample-specific commands below
apply. This menu item is context-sensitive, which means it reflects the Data
Sample graph you selected in the Sampled Graphs window (one of up to four).
Viewing Range
Displays a dialog box, see Viewing Range dialog box, page 218.
Size
Controls the vertical size of the graph; choose between Small, Medium, and
Large.
Style
Choose how to display the graph. Choose between:
Levels, where a horizontal line—optionally color-filled—shows the value until
the next sample.
Linear, where a line connects consecutive samples.
Solid Graph
Displays the graph as a color-filled solid graph instead of as a thin line. This is
only possible if the graph is displayed as Levels.
Hexadecimal
Toggles between displaying the selected value in decimal or hexadecimal
format. Note that this setting also affects the log window.
Show Numerical Value
Shows the numerical value of the variable, in addition to the graph.
Select Graphs
Selects which graphs to display in the Sampled Graphs window.
C-SPY® Debugging Guide
214
for MSP430
AFE1_AFE2-1:1
The application timeline
Data Sample Setup window
The Data Sample Setup window is available from the C-SPY driver menu.
Use this window to specify up to four variables to sample data for. You can view the
sampled data for the variables either in the Data Sample window or as graphs in the
Sampled Graphs window.
See also Getting started using data sampling, page 197.
Requirements
A device that supports the trace buffer.
Display area
This area contains these columns:
Expression
Type the name of the variable which must be an integral type with a maximum
size of 32 bits. Click the check box to enable or disable data sampling for the
variable.
Alternatively, drag an expression from the editor window and drop it in the
display area.
Variables in the expressions must be statically located, for example global
variables.
Address
The actual memory address that is accessed. The column cells cannot be edited.
Size
The size of the variable, either 1, 2, or 4 bytes. The column cells cannot be
edited.
Sampling interval [ms]
Type the number of milliseconds to pass between the samples. The shortest
allowed interval is 10 ms and the interval you specify must be a multiple of that.
215
AFE1_AFE2-1:1
Reference information on application timeline
Note that the sampling time you specify is just the interval (according to the
Microsoft Windows calculations) for how often C-SPY checks with the C-SPY
driver (which in turn must check with the MCU for a value). If this takes longer
than the sampling interval you have specified, the next sampling will be omitted.
If this occurs, you might want to consider increasing the sampling time.
Context menu
This context menu is available:
These commands are available:
Remove
Removes the selected variable.
Remove All
Removes all variables.
Data Sample window
The Data Sample window is available from the C-SPY driver menu.
Use this window to view the result of the data sampling for the variables you have
selected in the Data Sample Setup window.
Choose Enable from the context menu to enable data sampling.
See also Getting started using data sampling, page 197.
Requirements
A device that supports the trace buffer.
C-SPY® Debugging Guide
216
for MSP430
AFE1_AFE2-1:1
The application timeline
Display area
This area contains these columns:
Sampling Time
The time when the data sample was collected. Time starts at zero after a reset.
Every time the execution stops, a red Stop indicates when the stop occurred.
The selected expression
The column headers display the names of the variables that you selected in the
Data Sample Setup window. The column cells display the sampling values for
the variable.
* You can double-click a row in the display area. If you have enabled the data sample
graph in the Sampled Graphs window, the selection line will be moved to reflect the
time of the row you double-clicked.
Context menu
This context menu is available:
These commands are available:
Enable
Enables data sampling.
Clear
Clears the sampled data.
Hexadecimal
Toggles between displaying the selected value in decimal or hexadecimal
format. Note that this setting also affects the log window.
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.
Open setup window
Opens the Data Sample Setup window.
217
AFE1_AFE2-1:1
Reference information on application timeline
Viewing Range dialog box
The Viewing Range dialog box is available from the context menu that appears when
you right-click in any graph in the Timeline window that uses the linear, levels or
columns style.
Use this dialog box to specify the value range, that is, the range for the Y-axis for the
graph.
Requirements
The C-SPY FET Debugger driver.
Range for ...
Selects the viewing range for the displayed values:
Auto
Uses the range according to the range of the values that are actually collected,
continuously keeping track of minimum or maximum values. The currently
computed range, if any, is displayed in parentheses. The range is rounded to
reasonably even limits.
Factory
For the Power Log graph: Uses the range according to the properties of the
measuring hardware (only if supported by the product edition you are using).
For the other graphs: Uses the range according to the value range of the variable,
for example 0–65535 for an unsigned 16-bit integer.
Custom
Use the text boxes to specify an explicit range.
C-SPY® Debugging Guide
218
for MSP430
AFE1_AFE2-1:1
The application timeline
Scale
Selects the scale type of the Y-axis:
●
Linear
●
Logarithmic.
219
AFE1_AFE2-1:1
Reference information on application timeline
C-SPY® Debugging Guide
220
for MSP430
AFE1_AFE2-1:1
Profiling
●
Introduction to the profiler
●
Using the profiler
●
Reference information on the profiler
Introduction to the profiler
These topics are covered:
●
Reasons for using the profiler
●
Briefly about the profiler
●
Requirements for using the profiler
REASONS FOR USING THE PROFILER
Function profiling can help you find the functions in your source code where the most
time is spent during execution. You should focus on those functions when optimizing
your code. A simple method of optimizing a function is to compile it using speed
optimization. Alternatively, you can move the data used by the function into more
efficient memory. For detailed information about efficient memory usage, see the IAR
C/C++ Compiler User Guide for MSP430.
Alternatively, you can use filtered profiling, which means that you can exclude, for
example, individual functions from being profiled. To profile only a specific part of your
code, you can select a time interval—using the Timeline window—for which C-SPY
produces profiling information.
Instruction profiling can help you fine-tune your code on a very detailed level, especially
for assembler source code. Instruction profiling can also help you to understand where
your compiled C/C++ source code spends most of its time, and perhaps give insight into
how to rewrite it for better performance.
BRIEFLY ABOUT THE PROFILER
Function profiling information is displayed in the Function Profiler window, that is,
timing information for the functions in an application. Profiling must be turned on
explicitly using a button on the window’s toolbar, and will stay enabled until it is turned
off.
221
AFE1_AFE2-1:1
Introduction to 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. 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.
REQUIREMENTS FOR USING THE PROFILER
The C-SPY simulator supports the profiler; there are no specific requirements.
The function profiler is available in the hardware debugger system if your device and
debug probe support it. The instruction profiler is not available in the hardware debugger
system.
C-SPY® Debugging Guide
222
for MSP430
AFE1_AFE2-1:1
Profiling
This table lists the C-SPY driver profiling support:
C-SPY driver
Trace (calls)
Trace (flat)
Power
C-SPY simulator
X
X
--
C-SPY FET Debugger driver
--
--
X
Table 9: C-SPY driver profiling support
Using the profiler
These tasks are covered:
●
Getting started using the profiler on function level
●
Analyzing the profiling data
●
Getting started using the profiler on instruction level
GETTING STARTED USING THE PROFILER ON FUNCTION
LEVEL
To display function profiling information in the Function Profiler window:
1 Build your application using these options:
Category
Setting
C/C++ Compiler
Output>Generate debug information
Linker
Output>Format>Debug information for C-SPY
Table 10: Project options for enabling the profiler
2 To set up the profiler for function profiling, choose Options>Debugger>FET
Debugger>Setup and select Enable ULP/LPMx.5 debug.
3 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.
4 Start executing your application to collect the profiling information.
5 Profiling information is displayed in the Function Profiler window. To sort, click on
the relevant column header.
6 When you start a new sampling, you can click the Clear button—alternatively, use the
context menu—to clear the data.
223
AFE1_AFE2-1:1
Using the profiler
ANALYZING THE PROFILING DATA
Here follow some examples of how to analyze the data.
The first figure shows the result of profiling using Source: Trace (calls). The profiler
follows the program flow and detects function entries and exits.
●
For the InitFib function, Flat Time 231 is the time spent inside the function itself.
●
For the InitFib function, Acc Time 487 is the time spent inside the function itself,
including all functions InitFib calls.
●
For the InitFib/GetFib function, Acc Time 256 is the time spent inside GetFib (but
only when called from InitFib), including any functions GetFib calls.
●
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.
C-SPY® Debugging Guide
224
for MSP430
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.
GETTING STARTED USING THE PROFILER ON INSTRUCTION
LEVEL
To display instruction profiling information in the Disassembly window:
1 To set up the profiler for function profiling, choose Options>Debugger>FET
Debugger>Setup and select Enable ULP/LPMx.5 debug.
2 When you have built your application and started C-SPY, choose View>Disassembly
to open the Disassembly window, and choose Instruction Profiling>Enable from the
context menu that is available when you right-click in the left-hand margin of the
Disassembly window.
3 Make sure that the Show command on the context menu is selected, to display the
profiling information.
4 Start executing your application to collect the profiling information.
5 When the execution stops, for instance because the program exit is reached or a
breakpoint is triggered, you can view instruction level profiling information in the
left-hand margin of the window.
225
AFE1_AFE2-1:1
Reference information on the profiler
For each instruction, the number of times it has been executed is displayed.
Reference information on the profiler
Reference information about:
●
Function Profiler window, page 226
See also:
●
Disassembly window, page 67
Function Profiler window
The Function Profiler window is available from the C-SPY driver menu.
This figure reflects the C-SPY simulator driver.
This window displays function profiling information.
C-SPY® Debugging Guide
226
for MSP430
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 223.
Requirements
One of these alternatives:
●
The C-SPY simulator
●
The C-SPY FET Debugger driver and an MSP430 device with JSTATE register and
an eZFET or MSP-FET debug probe.
Note that if you are using the C-SPY FET Debugger driver, the profiling sources
Trace (flat) and Trace (calls) are not available.
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.
227
AFE1_AFE2-1:1
Reference information on the profiler
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
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 222.
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 in 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 in 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.
C-SPY® Debugging Guide
228
for MSP430
AFE1_AFE2-1:1
Profiling
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.
Avg Current [mA] (Power Sampling)
The average measured value for all samples associated with that function.
Min Current [mA] (Power Sampling)
The minimum measured value for all samples associated with that function.
Max Current [mA] (Power Sampling)
The maximum measured value for all samples associated with that function.
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.
229
AFE1_AFE2-1:1
Reference information on the profiler
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).
Source*
Selects which source to be used for the profiling information. See also Profiling
sources, page 222. 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.
C-SPY® Debugging Guide
230
for MSP430
AFE1_AFE2-1:1
Code coverage
●
Introduction to code coverage
●
Reference information on code coverage.
Introduction to code coverage
These topics are covered:
●
Reasons for using code coverage
●
Briefly about code coverage
●
Requirements and restrictions for using code coverage.
REASONS FOR USING CODE COVERAGE
The code coverage functionality is useful when you design your test procedure to verify
whether all parts of the code have been executed. It also helps you identify parts of your
code that are not reachable.
BRIEFLY ABOUT CODE COVERAGE
The Code Coverage window reports the status of the current code coverage analysis for
C code. 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.
Note: Assembler code is not covered by the code coverage analysis. To view assembler
code, use the Disassembly window.
REQUIREMENTS AND RESTRICTIONS FOR USING CODE
COVERAGE
Code coverage is supported by the C-SPY Simulator and there are no specific
requirements or restrictions.
Reference information on code coverage
Reference information about:
●
Code Coverage window, page 232.
231
AFE1_AFE2-1:1
Reference information on code coverage
See also Single stepping, page 60.
Code Coverage window
The Code Coverage window is available from the View menu.
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 11: 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.
C-SPY® Debugging Guide
232
for MSP430
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:
Red diamond
Signifies that 0% of the modules or functions has been
executed.
Green diamond
Signifies that 100% of the modules or functions has been
executed.
Red and green diamond
Signifies that some of the modules or functions have been
executed.
Yellow diamond
Signifies a statement that has not been executed.
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
233
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:
These commands are available:
Activate
Switches code coverage on and off during execution.
Clear
Clears the code coverage information. All step points are marked as not
executed.
Refresh
Updates the code coverage information and refreshes the window. All step
points that have been executed since the last refresh are removed from the tree.
Auto-refresh
Toggles the automatic reload of code coverage information on and off. When
turned on, the code coverage information is reloaded automatically when
C-SPY stops at a breakpoint, at a step point, and at program exit.
Save As
Saves the current code coverage result in a text file.
Save session
Saves your code coverage session data to a *.dat file. This is useful if you for
some reason must abort your debug session, but want to continue the session
later on. This command is available on the toolbar. This command might not be
supported by the C-SPY driver you are using.
Restore session
Restores previously saved code coverage session data. This is useful if you for
some reason must abort your debug session, but want to continue the session
later on. This command is available on the toolbar. This command might not be
supported by the C-SPY driver you are using.
C-SPY® Debugging Guide
234
for MSP430
AFE1_AFE2-1:1
Power debugging
●
Introduction to power debugging
●
Optimizing your source code for power consumption
●
Debugging in the power domain
●
Reference information on power debugging.
Introduction to power debugging
These topics are covered:
●
Reasons for using power debugging
●
Briefly about power debugging
●
Requirements and restrictions for power debugging.
REASONS FOR USING POWER DEBUGGING
Long battery lifetime is a very important factor for many embedded systems in almost
any market segment: medical, consumer electronics, home automation, etc. The power
consumption in these systems does not only depend on the hardware design, but also on
how the hardware is used. The system software controls how it is used.
For examples of when power debugging can be useful, see Optimizing your source code
for power consumption, page 237.
BRIEFLY ABOUT POWER DEBUGGING
Power debugging is based on the ability to sample the power consumption—more
precisely, the power being consumed by the CPU and the peripheral units—and
correlate each sample with the application’s instruction sequence and hence with the
source code and various events in the program execution.
Traditionally, the main software design goal has been to use as little memory as possible.
However, by correlating your application’s power consumption with its source code you
can get insight into how the software affects the power consumption, and thus how it can
be minimized.
Power debugging in C-SPY supports the EnergyTraceTM Technology provided by Texas
Instruments.
235
AFE1_AFE2-1:1
Introduction to power debugging
Measuring power consumption
Debug probes with EnergyTraceTM Technology support measure the power supplied to
a target microcontroller. A software-controlled DC–DC converter generates the target
power supply. The time density of the DC–DC converter charge pulses equals the power
consumption of the target microcontroller. A built-in on-the-fly calibration circuit
defines the energy equivalent of a single DC–DC charge pulse.
For more information about the debug probes, see the MSP430 Hardware Tools User’s
Guide on the Texas Instruments website.
Power debugging using C-SPY
C-SPY provides an interface for configuring your power debugging and a set of
windows for viewing the power values:
C-SPY® Debugging Guide
236
for MSP430
AFE1_AFE2-1:1
●
The Power Setup window is where you can specify a threshold and an action to be
executed when the threshold is reached. This means that you can enable or disable
the power measurement or you can stop the application’s execution and determine
the cause of unexpected power values.
●
The Power Log window displays all logged power values. This window can be used
for finding peaks in the power logging and because the values are correlated with
the executed code, you can double-click on a value in the Power Log window to get
the corresponding 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.
●
The Power graph in the Timeline window displays power values on a time scale.
This provides a convenient way of viewing the power consumption in relation to the
other information displayed in the window. The Timeline window is correlated to
both the Power Log window, the source code window, and the Disassembly
window, which means you are just a double-click away from the source code that
corresponds to the values you see on the timeline.
●
The State Log window logs activity—state changes—for peripheral units and
clocks, as well as for CPU modes. The State Log Summary window displays a
summary of the logged activity. The State Log graphs display a graphical view of
the activity. The information is useful for tracing the activity on the target system.
●
The Function Profiler window combines the function profiling with the power
logging to display the power consumption per function—power profiling. You will
get a list of values per function and also the average values together with max and
min values. Thus, you will find the regions in the application that you should focus
when optimizing for power consumption.
Power debugging
REQUIREMENTS AND RESTRICTIONS FOR POWER
DEBUGGING
Power debugging in C-SPY support two capture modes, with different capabilities:
●
EnergyTraceTM, which can output timestamps, voltage, current, and energy
information. This mode is available for all MSP430 devices with both MSP-FET
(black box) and eZ-FET.
●
EnergyTrace++TM, which can output timestamps, state log information for
peripheral units, clocks, and CPU modes (64-bit JSTATE register content), voltage,
current, and energy information. This mode is available for all MSP430 devices
with the JSTATE register, currently the MSP430FR59xx device family, together
with both the MSP-FET (black box) and the eZ-FET debugger probe. The
respective device-specific .menu file includes an <energytrace>1</energytrace>
tag.
To use the features in C-SPY for power debugging, you also need:
●
The C-SPY FET Debugger driver.
Note: The MSP-FET430UIF (gray box) and the eZ430 debug probes do not support
power debugging.
Optimizing your source code for power consumption
This section gives some examples where power debugging can be useful and thus
hopefully help you identify source code constructions that can be optimized for low
power consumption.
These topics are covered:
●
Waiting for device status
●
Software delays
●
DMA versus polled I/O
●
Low-power mode diagnostics
●
CPU frequency
●
Detecting mistakenly unattended peripherals
●
Peripheral units in an event-driven system
●
Finding conflicting hardware setups
●
Analog interference
237
AFE1_AFE2-1:1
Optimizing your source code for power consumption
WAITING FOR DEVICE STATUS
One common construction that could cause unnecessary power consumption is to use a
poll loop for waiting for a status change of, for example a peripheral device.
Constructions like this example execute without interruption until the status value
changes into the expected state.
while (USBD_GetState() < USBD_STATE_CONFIGURED);
while ((BASE_PMC->PMC_SR & MC_MCKRDY) != PMC_MCKRDY);
To minimize power consumption, rewrite polling of a device status change to use
interrupts if possible, or a timer interrupt so that the CPU can sleep between the polls.
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);
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.
DMA VERSUS POLLED I/O
DMA has traditionally been used for increasing transfer speed. For MCUs there are
plenty of DMA techniques to increase flexibility, speed, and to lower power
consumption. Sometimes, CPUs can even be put into sleep mode during the DMA
transfer. Power debugging lets you experiment and see directly in the debugger what
effects these DMA techniques will have on power consumption compared to a
traditional CPU-driven polled solution.
LOW-POWER MODE DIAGNOSTICS
Many embedded applications spend most of their time waiting for something to happen:
receiving data on a serial port, watching an I/O pin change state, or waiting for a time
delay to expire. If the processor is still running at full speed when it is idle, battery life
is consumed while very little is being accomplished. So in many applications, the
microcontroller is only active during a very small amount of the total time, and by
placing it in a low-power mode during the idle time, the battery life can be extended
considerably.
A good approach is to have a task-oriented design. In a task-oriented design, a task can
be defined with the lowest priority, and it will only execute when there is no other task
that needs to be executed. This idle task is the perfect place to implement power
C-SPY® Debugging Guide
238
for MSP430
AFE1_AFE2-1:1
Power debugging
management. In practice, every time the idle task is activated, it sets the microcontroller
into a low-power mode. All MSP430 devices have a number of different low-power
modes, in which different parts of the microcontroller can be turned off when they are
not needed. The oscillator can for example either be turned off or switched to a lower
frequency. In addition, individual peripheral units, timers, and the CPU can be stopped.
The different low-power modes have different power consumption based on which
peripherals are left turned on. A power debugging tool can be very useful when
experimenting with different low-level modes.
You can use the Function profiler in C-SPY to compare power measurements for the task
or function that sets the system in a low-power mode when different low-power modes
are used. Both the mean value and the percentage of the total power consumption can be
useful in the comparison.
CPU FREQUENCY
Power consumption in a CMOS MCU is theoretically given by the formula:
P = f * U2 * k
where f is the clock frequency, U is the supply voltage, and k is a constant.
Power debugging lets you verify the power consumption as a factor of the clock
frequency. A system that spends very little time in sleep mode at 10 MHz is expected to
spend 50% of the time in sleep mode when running at 20 MHz. You can use the power
data collected in C-SPY to verify the expected behavior, and if there is a non-linear
dependency on the clock frequency, make sure to choose the operating frequency that
gives the lowest power consumption.
DETECTING MISTAKENLY UNATTENDED PERIPHERALS
Peripheral units can consume much power even when they are not actively in use. If you
are designing for low power, it is important that you disable the peripheral units and not
just leave them unattended when they are not in use. But for different reasons, a
peripheral unit can be left with its power supply on; it can be a careful and correct design
decision, or it can be an inadequate design or just a mistake. If not the first case, then
more power than expected will be consumed by your application. This will be easily
revealed by the Power graph in the Timeline window. Double-clicking in the Timeline
window where the power consumption is unexpectedly high will take you to the
corresponding source code and disassembly code. In many cases, it is enough to disable
the peripheral unit when it is inactive, for example by turning off its clock which in most
cases will shut down its power consumption completely.
However, there are some cases where clock gating will not be enough. Analog
peripherals like converters or comparators can consume a substantial amount of power
239
AFE1_AFE2-1:1
Optimizing your source code for power consumption
even when the clock is turned off. The Timeline window will reveal that turning off the
clock was not enough and that you need to turn off the peripheral completely.
PERIPHERAL UNITS IN AN EVENT-DRIVEN SYSTEM
Consider a system where one task uses an analog comparator while executing, but the
task is suspended by a higher-priority task. Ideally, the comparator should be turned off
when the task is suspended and then turned on again once the task is resumed. This
would minimize the power being consumed during the execution of the high-priority
task.
This is a schematic diagram of the power consumption of an assumed event-driven
system where the system at the point of time t0 is in an inactive mode and the current is
I0:
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
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.
C-SPY® Debugging Guide
240
for MSP430
AFE1_AFE2-1:1
Power debugging
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.
FINDING CONFLICTING HARDWARE SETUPS
To avoid floating inputs, it is a common design practice to connect unused MCU I/O
pins to ground. If your source code by mistake configures one of the grounded I/O pins
as a logical 1 output, a high current might be drained on that pin. This high unexpected
current is easily observed by reading the current value from the Power graph in the
Timeline window. It is also possible to find the corresponding erratic initialization code
by looking at the Power graph at application startup.
A similar situation arises if an I/O pin is designed to be an input and is driven by an
external circuit, but your code incorrectly configures the input pin as output.
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
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. All data presented in the Timeline window
241
AFE1_AFE2-1:1
Debugging in the power domain
is correlated to the executed code. Simply double-clicking on a suspicious power value
will bring up the corresponding C source code.
Debugging in the power domain
These tasks are covered:
●
Displaying a power profile and analyzing the result
●
Displaying the power profile on a device without EnergyTrace++
●
Detecting unexpected power usage during application execution
●
Measuring low power currents
●
Changing the graph resolution.
See also:
●
Power graph in the Timeline window, page 251
DISPLAYING A POWER PROFILE AND ANALYZING THE
RESULT
To view the power profile on a device with EnergyTrace++:
1 Before you start the debug session, choose Project>Options>Debugger>FET
Debugger>Setup>Enable ULP/LPMx.5 debug.
2 Start the debugger.
3 Choose C-SPY driver>Power Log Setup. In the ID column, make sure to select the
alternatives for which you want to enable power logging: Current, Voltage, or
Energy.
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. Repeat this for each 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 peripheral units,
clocks, and CPU modes, 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 graphs. See Viewing Range dialog box, page 218.
C-SPY® Debugging Guide
242
for MSP430
AFE1_AFE2-1:1
Power debugging
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 peripheral units and clocks, as well as CPU modes if you
enabled the State Log graph. For information about how to navigate on the graph, see
Power graph in the Timeline window, page 251.
10 To analyze power consumption:
●
Double-click on an interesting power value to highlight the corresponding source
code in the editor window and in the Disassembly window. The corresponding log
is highlighted in the Power Log window. For examples of when this can be useful,
see Optimizing your source code for power consumption, page 237.
●
You can identify peripheral units to disable if they are not used. You can detect this
by analyzing the power graph in combination with the State Log Graph in the
Timeline window. See also Detecting mistakenly unattended peripherals, page 239.
DISPLAYING THE POWER PROFILE ON A DEVICE WITHOUT
ENERGYTRACE++
To view the power profile on a device without EnergyTrace++:
1 Start the debugger.
2 Choose C-SPY driver>Power Log Setup. In the ID column, make sure to select the
alternatives for which you want to enable power logging: Current, Voltage, or
Energy.
3 Choose C-SPY driver>Timeline to open the Timeline window.
4 Right-click in the graph area and choose Enable from the context menu to enable the
power graph you want to view. Repeat this for each graph you want to view.
5 Choose C-SPY driver>Power Log to open the Power Log window.
243
AFE1_AFE2-1:1
Debugging in the power domain
6 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. For information about how to navigate on the
graph, see Power graph in the Timeline window, page 251.
DETECTING UNEXPECTED POWER USAGE DURING
APPLICATION EXECUTION
To detect unexpected power consumption on a device with
EnergyTrace++:
1 Choose C-SPY driver>Power Log Setup to open the Power Setup window.
2 In the Power Setup window, specify a threshold value and the appropriate action, for
example Log All and Halt CPU Above Threshold.
3 Choose C-SPY driver>Power Log to open the Power Log window. If you
continuously want to save the power values to a file, choose Choose Live Log File
from the context menu. In this case you also need to choose Enable Live Logging to.
4 Start the execution.
When the power consumption passes the threshold value, the execution will stop and
perform the action you specified.
If you saved your logged power values to a file, you can open that file in an external tool
for further analysis.
MEASURING LOW POWER CURRENTS
During the capture of the internal states or even when simply executing until a
breakpoint stops the execution, the target microcontroller is constantly accessed via
JTAG or Spy-Bi-Wire debug logic. These debug accesses consume energy that will be
included in the numbers displayed in the Power Log window and graphs. To measure
the power numbers of just the application, it is therefore recommended to use the
C-SPY® Debugging Guide
244
for MSP430
AFE1_AFE2-1:1
Power debugging
Release JTAG on Go option, which means that the debug logic of the target
microcontroller is not accessed while measuring the power consumption.
To measure low power currents:
1 Before you start the debug session, choose Project>Options>Debugger>FET
Debugger>Setup>Enable ULP/LPMx.5 debug.
2 Start the debugger.
3 Choose C-SPY driver>Release JTAG on Go.
4 Choose C-SPY driver>Power Log Setup. In the ID column, select the alternatives for
which you want to enable power logging: Current, Voltage, or Energy.
5 To enable the graphs in the Timeline window, choose Emulator>Timeline to open the
Timeline window. Right-click in the graph area for each graph that you have enabled
power logging for and choose Enable from the context menu.
6 Start the execution.
Power logging is enabled and you can now see the graphs appear in the Timeline
window.
CHANGING THE GRAPH RESOLUTION
To change the resolution of a Power graph in the Timeline window:
1 In the Timeline window, select the Power graph, right-click and choose Open Setup
Window to open the Power Log Setup window.
2 From the context menu in the Power Log Setup window, choose a suitable unit of
measurement.
3 In the Timeline window, select the Power graph, right-click and choose Viewing
Range from the context menu.
4 In the Viewing Range dialog box, select Custom and specify range values in the
Lowest value and the Highest value text boxes. Click OK.
5 The graph is automatically updated accordingly.
Reference information on power debugging
Reference information about:
●
Power Log Setup window, page 246
●
Power graph in the Timeline window, page 251.
●
Power Log window, page 248.
245
AFE1_AFE2-1:1
Reference information on power debugging
●
Timeline window—State Log graph, page 257.
●
State Log window, page 252.
●
State Log Summary window, page 254.
See also:
●
Trace window, page 180
●
Viewing Range dialog box, page 218
●
Function Profiler window, page 226.
Power Log Setup window
The Power Log Setup window is available from the C-SPY driver menu during a debug
session.
Use this window to configure the power measurement.
Note: To enable power logging, choose Enable from the context menu in the Power Log
window or from the context menu in the power graph in the Timeline window.
Requirements
An eZFET or MSP-FET debug probe.
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.
C-SPY® Debugging Guide
246
for MSP430
AFE1_AFE2-1:1
Power debugging
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:
These commands are available:
nA, uA, mA
Selects the unit for the power display. These alternatives are available for
channels that measure current.
uV, mV, V
Selects the unit for power display. These alternatives are available for channels
that measure voltage.
uWs, mWs, Ws
Selects the unit for power display. These alternatives are available for channels
that measure energy.
Log All
Logs all values.
Log Above Threshold
Logs all values above the threshold.
Log Below Threshold
Logs all values below the threshold.
247
AFE1_AFE2-1:1
Reference information on power debugging
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.
Power Log window
The Power Log window is available from the C-SPY driver menu during a debug
session.
This window displays collected power values.
A row with only Time/Cycles and Program Counter displayed in grey denotes a logged
power value for a channel that was active during the actual collection of data but
currently is disabled in the Power Log Setup window.
Note: The number of logged power values is limited. When this limit is exceeded, the
oldest entries in the buffer are erased.
Requirements
An eZFET or MSP-FET debug probe.
Display area
This area contains these columns:
Time
The time from the application reset until the event, based on time stamps.
This column is available when you have selected Show Time from the context
menu.
Program Counter
Displays one of these:
An address, which is the content of the PC, that is, the address of an instruction
close to where the power value was collected.
---, the target system failed to provide the debugger with any information.
C-SPY® Debugging Guide
248
for MSP430
AFE1_AFE2-1:1
Power debugging
Overflow in red, the communication channel failed to transmit all data from the
target system.
Note that the Program Counter column is available only if your device
supports it.
Name [unit]
The power measurement value expressed in the unit you specified in the Power
Setup window.
Context menu
This context menu is available:
These commands are available:
Enable
Enables the logging system, which means that power values are saved internally
within the IDE. The values are displayed in the Power Log window and in the
Power graph in the Timeline window (if enabled). The system will log
information also when the window is closed.
Clear
Deletes the log information. Note that this will also happen when you reset the
debugger.
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.
249
AFE1_AFE2-1:1
Reference information on power debugging
Choose Live Log File
Displays a standard file selection dialog box where you can choose a destination
file for the logged power values. The power values are continuously saved to that
file during execution. The content of the live log file is never automatically
cleared, the logged values are simply added at the end of the file.
Enable Live Logging to
Toggles live logging on or off. The logs are saved in the specified file.
Clear log file
Clears the content of the live log file.
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.
The format of the log file
The log file has a tab-separated format. The entries in the log file are separated by TAB
and line feed. The logged power values are displayed in these columns:
Time/Cycles
The time from the application reset until the power value was logged.
Approx
An x in the column indicates that the power value has an approximative value
for time/cycle.
PC
The value of the program counter close to the point where the power value was
logged.
Name[unit]
The corresponding value from the Power Log window, where Name and unit
are according to your settings in the Power Log Setup window.
C-SPY® Debugging Guide
250
for MSP430
AFE1_AFE2-1:1
Power debugging
Power graph in the Timeline window
The power graph in the Timeline window is available from the C-SPY driver menu
during a debug session.
The power graph displays a graphical view of power measurement samples.
Depending on the abilities in hardware, the debug probe, and the C-SPY driver you are
using, this window can display a Power Log graph that shows power measurement
samples generated by the debug probe or associated hardware in relation to a common
time axis.
For more information about the Timeline window, how to display a graph, and the other
supported graphs, see Reference information on application timeline, page 197.
See also Requirements and restrictions for power debugging, page 237.
Requirements
An eZFET or MSP-FET debug probe.
Display area
Where:
●
The label area at the left end of the graph displays the name of the measurement
channel.
●
The Voltage and the Current graphs show power measurement samples generated by
the debug probe or associated hardware. The Energy graph shows accumulated
energy since the last time the CPU was stopped.
●
The graphs 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 graphs can be changed.
251
AFE1_AFE2-1:1
Reference information on power debugging
At the bottom of the window, there is a common time axis that uses seconds as the time
unit.
State Log window
The State Log window is available from the C-SPY driver menu.
This window logs activity—state changes—for peripheral units and clocks, as well as
for CPU modes.
The information is useful for tracing the activity on the target system. When the State
Log window is open, it is updated continuously at runtime.
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 Displaying a power profile and analyzing the result, page 242 and Timeline
window—State Log graph, page 257.
Requirements
An MSP430 device with JSTATE register and an eZFET or MSP-FET debug probe.
Display area
This area contains these columns:
Time
The time for the state change, based on the sampling frequency.
If a time is displayed in italics, the target system has not been able to collect a
correct time, but instead had to approximate it.
Source
The name of the peripheral unit, clock, or CPU mode.
Status
The status at the given time.
C-SPY® Debugging Guide
252
for MSP430
AFE1_AFE2-1:1
Power debugging
Program Counter*
The address of the program counter when the status changed, or shows idle if
the log was taken during CPU idle mode, or shows --- for an unknown PC value.
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.
* You can double-click an address. If it is available in the source code, the editor window
displays the corresponding source code, for example for the interrupt handler (this does
not include library source code).
Context menu
This context menu is available:
These commands are available:
Enable
Enables the logging system. The system will log information also when the
window is closed.
Clear
Deletes the log information. Note that this will happen also when you reset the
debugger.
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.
253
AFE1_AFE2-1:1
Reference information on power debugging
If the C-SPY driver you are using does not support the Cycles column, this
menu command is not available.
State Log Summary window
The State Log Summary window is available from the C-SPY driver menu.
This window displays a summary of logged activity—state changes—for peripheral
units and clocks, as well as for CPU modes.
Click a column to sort it according to the values. Click again to reverse the sort order.
At the bottom of the display area, the current time or cycles is displayed—the number
of cycles or the execution time since the start of execution.
See also Displaying a power profile and analyzing the result, page 242 and Timeline
window—State Log graph, page 257.
Requirements
An MSP430 device with JSTATE register and an eZFET or MSP-FET debug probe.
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 peripheral unit, clock, or CPU mode.
Count
The number of times the source was activated.
First time
The first time the source was activated.
C-SPY® Debugging Guide
254
for MSP430
AFE1_AFE2-1:1
Power debugging
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.
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.
255
AFE1_AFE2-1:1
Reference information on power debugging
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.
** Calculated in the same way as for the Execution time/cycles in the State Log
window.
Context menu
This context menu is available:
These commands are available:
Enable
Enables the logging system. The system will log information also when the
window is closed.
Clear
Deletes the log information. Note that this will happen also when you reset the
debugger.
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.
C-SPY® Debugging Guide
256
for MSP430
AFE1_AFE2-1:1
Power debugging
Timeline window—State Log graph
The State Log graph in the Timeline window is available from the C-SPY driver menu
during a debug session.
The State Log graph displays a graphical view of logged activity—state changes—for
peripheral units and clocks, as well as CPU modes 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 Reference information on application timeline, page 197.
See also, Requirements and restrictions for power debugging, page 237.
Requirements
An MSP430 device with JSTATE register and an eZFET or MSP-FET debug 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 peripheral units, clocks, and CPU modes
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 252.
At the bottom of the window, there is a shared time axis that uses seconds as the time
unit.
257
AFE1_AFE2-1:1
Reference information on power debugging
C-SPY® Debugging Guide
258
for MSP430
AFE1_AFE2-1:1
Part 3. Advanced
debugging
This part of the C-SPY® Debugging Guide for MSP430 includes these chapters:
●
Interrupts
●
The advanced cycle counter
●
State storage
●
The sequencer
●
C-SPY macros
●
The C-SPY command line utility—cspybat
259
260
Interrupts
●
Introduction to interrupts
●
Using the interrupt system
●
Reference information on interrupts
Introduction to interrupts
These topics are covered:
●
Briefly about the interrupt simulation system
●
Interrupt characteristics
●
Interrupt simulation states
●
C-SPY system macros for interrupt simulation
●
Target-adapting the interrupt simulation system
●
Briefly about interrupt logging
See also:
●
Reference information on C-SPY system macros, page 319
●
Breakpoints, page 103
●
The IAR C/C++ Compiler User Guide for MSP430
BRIEFLY ABOUT THE INTERRUPT SIMULATION SYSTEM
By simulating interrupts, you can test the logic of your interrupt service routines and
debug the interrupt handling in the target system long before any hardware is available.
If you use simulated interrupts in conjunction with C-SPY macros and breakpoints, you
can compose a complex simulation of, for instance, interrupt-driven peripheral devices.
The C-SPY Simulator includes an interrupt simulation system where you can simulate
the execution of interrupts during debugging. You can configure the interrupt simulation
system so that it resembles your hardware interrupt system.
The interrupt system has the following features:
●
Simulated interrupt support for the MSP430 microcontroller
●
Single-occasion or periodical interrupts based on the cycle counter
●
Predefined interrupts for various devices
261
AFE1_AFE2-1:1
Introduction to interrupts
●
Configuration of hold time, probability, and timing variation
●
State information for locating timing problems
●
Configuration of interrupts using a dialog box or a C-SPY system macro—that is,
one interactive and one automating interface. In addition, you can instantly force an
interrupt.
●
A log window that continuously displays events for each defined interrupt.
●
A status window that shows the current interrupt activities.
All interrupts you define using the Interrupt Setup dialog box are preserved between
debug sessions, unless you remove them. A forced interrupt, on the other hand, exists
only until it has been serviced and is not preserved between sessions.
The interrupt simulation system is activated by default, but if not required, you can turn
off the interrupt simulation system to speed up the simulation. To turn it off, use either
the or a system macro.
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—
C-SPY® Debugging Guide
262
for MSP430
AFE1_AFE2-1:1
Interrupts
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. If the hold time is set to infinite, the corresponding pending bit will be set
until the interrupt is acknowledged or removed.
INTERRUPT SIMULATION STATES
The interrupt simulation system contains status information that you can use for locating
timing problems in your application. The Interrupt Status window displays the
available status information. For an interrupt, these states can be displayed: Idle,
Pending, Executing, or Suspended.
Normally, a repeatable interrupt has a specified repeat interval that is longer than the
execution time. In this case, the status information at different times looks like this:
Note: The interrupt activation signal—also known as the pending bit—is automatically
deactivated the moment the interrupt is acknowledged by the interrupt handler.
263
AFE1_AFE2-1:1
Introduction to interrupts
However, if the interrupt repeat interval is shorter than the execution time, and the
interrupt is reentrant (or non-maskable), the status information at different times looks
like this:
An execution time that is longer than the repeat interval might indicate that you should
rewrite your interrupt handler and make it faster, or that you should specify a longer
repeat interval for the interrupt simulation system.
C-SPY SYSTEM MACROS FOR INTERRUPT SIMULATION
Macros are useful when you already have sorted out the details of the simulated interrupt
so that it fully meets your requirements. If you write a macro function containing
definitions for the simulated interrupts, you can execute the functions automatically
when C-SPY starts. Another advantage is that your simulated interrupt definitions will
be documented if you use macro files, and if you are several engineers involved in the
development project you can share the macro files within the group.
The C-SPY Simulator provides these predefined system macros related to interrupts:
__enableInterrupts
__disableInterrupts
__orderInterrupt
__cancelInterrupt
__cancelAllInterrupts
__popSimulatorInterruptExecutingStack
The parameters of the first five macros correspond to the equivalent entries of the
Interrupt Setup dialog box.
C-SPY® Debugging Guide
264
for MSP430
AFE1_AFE2-1:1
Interrupts
For more information about each macro, see Reference information on C-SPY system
macros, page 319.
TARGET-ADAPTING THE INTERRUPT SIMULATION SYSTEM
The interrupt simulation system is easy to use. However, to take full advantage of the
interrupt simulation system you should be familiar with how to adapt it for the processor
you are using.
The interrupt simulation has the same behavior as the hardware. This means that the
execution of an interrupt is dependent on the status of the global interrupt enable bit. The
execution of maskable interrupts is also dependent on the status of the individual
interrupt enable bits.
To simulate device-specific interrupts, the interrupt system must have detailed
information about each available interrupt. This information is provided in the device
description files.
For information about device description files, see Selecting a device description file,
page 44.
BRIEFLY ABOUT INTERRUPT LOGGING
Interrupt logging provides you with comprehensive information about the interrupt
events. This might be useful for example, to help you locate which interrupts you can
fine-tune to become faster. You can log entrances and exits to and from interrupts. You
can also log internal interrupt status information, such as triggered, expired, etc. In the
IDE:
●
The logs are displayed in the Interrupt Log window
●
A summary is available in the Interrupt Log Summary window
●
The Interrupt graph in the Timeline window provides a graphical view of the
interrupt events during the execution of your application.
Requirements for interrupt logging
Interrupt logging is supported by the C-SPY simulator.
See also Getting started using interrupt logging, page 268.
Using the interrupt system
These tasks are covered:
●
Simulating a simple interrupt
●
Simulating an interrupt in a multi-task system
265
AFE1_AFE2-1:1
Using the interrupt system
●
Getting started using interrupt logging.
See also:
●
Using C-SPY macros, page 307 for details about how to use a setup file to define
simulated interrupts at C-SPY startup
●
The tutorial Simulating an interrupt in the Information Center.
SIMULATING A SIMPLE INTERRUPT
This example demonstrates the method for simulating a timer interrupt. However, the
procedure can also be used for other types of interrupts.
To simulate and debug an interrupt:
1 Assume this simple application which contains an interrupt service routine for the
BasicTimer, which increments a tick variable. The main function sets the necessary
status registers. The application exits when 100 interrupts have been generated.
#include "io430x41x.h"
#include <intrinsics.h>
volatile int ticks = 0;
void main (void)
{
/* Timer setup code */
WDTCTL = WDTPW + WDTHOLD;
/* Stop WDT */
IE2 |= BTIE;
/* Enable BT interrupt */
BTCTL = BTSSEL+BTIP2+BTIP1+BTIP0;
__enable_interrupt();
/* Enable interrupts */
while (ticks < 100);
printf("Done\n");
/* Endless loop */
}
/* Timer interrupt service routine */
#pragma vector = BASICTIMER_VECTOR
__interrupt void basic_timer(void)
{
ticks += 1;
}
2 Add your interrupt service routine to your application source code and add the file to
your project.
3 Choose Project>Options>Debugger>Setup and select a device description file. The
device description file contains information about the interrupt that C-SPY needs to be
able to simulate it. Use the Use device description file browse button to locate the ddf
file.
C-SPY® Debugging Guide
266
for MSP430
AFE1_AFE2-1:1
Interrupts
4 Build your project and start the simulator.
5 Choose Simulator>Interrupt Setup to open the Interrupts Setup dialog box. Select
the Enable interrupt simulation option to enable interrupt simulation. Click New to
open the Edit Interrupt dialog box. For the timer example, verify these settings:
Option
Settings
Interrupt
BASICTIMER_VECTOR
First activation
4000
Repeat interval
2000
Hold time
10
Probability (%)
100
Variance (%)
0
Table 12: Timer interrupt settings
Click OK.
6 Execute your application. If you have enabled the interrupt properly in your application
source code, C-SPY will:
●
Generate an interrupt when the cycle counter has passed 4000
●
Continuously repeat the interrupt after approximately 2000 cycles.
7 To watch the interrupt in action, choose Simulator>Interrupt Log to open the
Interrupt Log window.
8 From the context menu, available in the Interrupt Log window, choose Enable to
enable the logging. If you restart program execution, status information about
entrances and exits to and from interrupts will now appear in the Interrupt Log window.
For information about how to get a graphical representation of the interrupts correlated
with a time axis, see Timeline window—Interrupt Log graph, page 280.
SIMULATING AN INTERRUPT IN A MULTI-TASK SYSTEM
If you are using interrupts in such a way that the normal instruction used for returning
from an interrupt handler is not used, for example in an operating system with
task-switching, the simulator cannot automatically detect that the interrupt has finished
executing. The interrupt simulation system will work correctly, but the status
information in the Interrupt Setup dialog box might not look as you expect. If too
many interrupts are executing simultaneously, a warning might be issued.
To simulate a normal interrupt exit:
1 Set a code breakpoint on the instruction that returns from the interrupt function.
267
AFE1_AFE2-1:1
Reference information on interrupts
2 Specify the __popSimulatorInterruptExecutingStack macro as a condition to
the breakpoint.
When the breakpoint is triggered, the macro is executed and then the application
continues to execute automatically.
GETTING STARTED USING INTERRUPT LOGGING
1 Choose C-SPY driver>Interrupt Log to open the Interrupt Log window. Optionally,
you can also choose:
●
C-SPY driver>Interrupt Log Summary to open the Interrupt Log Summary
window
●
C-SPY driver>Timeline to open the Timeline window and view the Interrupt
graph.
2 From the context menu in the Interrupt Log window, choose Enable to enable the
logging.
3 Start executing your application program to collect the log information.
4 To view the interrupt log information, look in any of the Interrupt Log, Interrupt Log
Summary, or the Interrupt graph in the Timeline window.
5 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.
6 To disable interrupt logging, from the context menu in the Interrupt Log window,
toggle Enable off.
Reference information on interrupts
Reference information about:
C-SPY® Debugging Guide
268
for MSP430
AFE1_AFE2-1:1
●
Interrupt Setup dialog box, page 269
●
Edit Interrupt dialog box, page 271
●
Forced Interrupt window, page 272
●
Interrupt Status window, page 273
●
Interrupt Log window, page 275
●
Interrupt Log Summary window, page 277.
●
Timeline window—Interrupt Log graph, page 280.
Interrupts
Interrupt Setup dialog box
The Interrupt Setup dialog box is available by choosing Simulator>Interrupt Setup.
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.
See also Using the interrupt system, page 265.
Requirements
The C-SPY simulator.
Enable interrupt simulation
Enables or disables interrupt simulation. If the interrupt simulation is disabled, the
definitions remain but no interrupts are generated. Note that you can also enable and
disable installed interrupts individually by using the check box to the left of the interrupt
name in the list of installed interrupts.
Display area
This area contains these columns:
Interrupt
Lists all interrupts. Use the checkbox to enable or disable the interrupt.
ID
A unique interrupt identifier.
Type
Shows the type of the interrupt. The type can be one of:
Forced, a single-occasion interrupt defined in the Forced Interrupt Window.
269
AFE1_AFE2-1:1
Reference information on interrupts
Single, a single-occasion interrupt.
Repeat, a periodically occurring interrupt.
If the interrupt has been set from a C-SPY macro, the additional part (macro) is
added, for example: Repeat(macro).
Timing
The timing of the interrupt. For a Single and Forced interrupt, the activation
time is displayed. For a Repeat interrupt, the information has the form:
Activation Time + n*Repeat Time. For example, 2000 + n*2345. This
means that the first time this interrupt is triggered, is at 2000 cycles and after that
with an interval of 2345 cycles.
Buttons
These buttons are available:
New
Opens the Edit Interrupt dialog box, see Edit Interrupt dialog box, page 271.
Edit
Opens the Edit Interrupt dialog box, see Edit Interrupt dialog box, page 271.
Delete
Removes the selected interrupt.
Delete All
Removes all interrupts.
C-SPY® Debugging Guide
270
for MSP430
AFE1_AFE2-1:1
Interrupts
Edit Interrupt dialog box
The Edit Interrupt dialog box is available from the Interrupt Setup dialog box.
Use this dialog box to interactively fine-tune the interrupt parameters. You can add the
parameters and quickly test that the interrupt is generated according to your needs.
Note: You can only edit or remove non-forced interrupts.
See also Using the interrupt system, page 265.
Requirements
The C-SPY simulator.
Interrupt
Selects the interrupt that you want to edit. The drop-down list contains 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.
Description
A description of the selected interrupt, if available. The description is retrieved from the
selected device description file and consists of a string describing the vector address, the
default priority, enable bit, and pending bit, separated by space characters. For interrupts
specified using the system macro __orderInterrupt, the Description box is empty.
First activation
Specify the value of the cycle counter after which the specified type of interrupt will be
generated.
Repeat interval
Specify the periodicity of the interrupt in cycles.
271
AFE1_AFE2-1:1
Reference information on interrupts
Variance %
Selects a timing variation range, as a percentage of the repeat interval, in which the
interrupt might 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.
Hold time
Specify how long, in cycles, the interrupt remains pending until removed if it has not
been processed. If you select Infinite, the corresponding pending bit will be set until the
interrupt is acknowledged or removed.
Probability %
Selects the probability, in percent, that the interrupt will actually occur within the
specified period.
Forced Interrupt window
The Forced Interrupt window is available from the C-SPY driver menu.
Use this window to force an interrupt instantly. This is useful when you want to check
your interrupt logic and interrupt routines. Just start typing an interrupt name and focus
shifts to the first line found with that name.
The hold time for a forced interrupt is infinite, and the interrupt exists until it has been
serviced or until a reset of the debug session.
To sort the window contents, click on either the Interrupt or the Description column
header. A second click on the same column header reverses the sort order.
To force an interrupt:
1 Enable the interrupt simulation system, see Interrupt Setup dialog box, page 269.
2 Double-click the interrupt in the Forced Interrupt window, or activate it by using the
Force command available on the context menu.
Requirements
The C-SPY simulator.
C-SPY® Debugging Guide
272
for MSP430
AFE1_AFE2-1:1
Interrupts
Display area
This area lists all available interrupts and their definitions. The description field is
editable and the information is retrieved from the selected device description file. See
this file for a detailed description.
Context menu
This context menu is available:
This command is available:
Force
Triggers the interrupt you selected in the display area.
Interrupt Status window
The Interrupt Status window is available from the C-SPY driver menu.
This window shows the status of all the currently active interrupts, in other words
interrupts that are either executing or waiting to be executed.
Requirements
The C-SPY simulator.
Display area
This area contains these columns:
Interrupt
Lists all interrupts.
ID
A unique interrupt identifier.
273
AFE1_AFE2-1:1
Reference information on interrupts
Type
The type of the interrupt. The type can be one of:
Forced, a single-occasion interrupt defined in the Forced Interrupt window.
Single, a single-occasion interrupt.
Repeat, a periodically occurring interrupt.
If the interrupt has been set from a C-SPY macro, the additional part (macro) is
added, for example: Repeat(macro).
Status
The state of the interrupt:
Idle, the interrupt activation signal is low (deactivated).
Pending, the interrupt activation signal is active, but the interrupt has not been
yet acknowledged by the interrupt handler.
Executing, the interrupt is currently being serviced, that is the interrupt handler
function is executing.
Suspended, the interrupt is currently suspended due to execution of an interrupt
with a higher priority.
(deleted) is added to Executing and Suspended if you have deleted a currently
active interrupt. (deleted) is removed when the interrupt has finished executing.
Next Time
The next time an idle interrupt is triggered. Once a repeatable interrupt stats
executing, a copy of the interrupt will appear with the state Idle and the next time
set. For interrupts that do not have a next time—that is pending, executing, or
suspended—the column will show --.
Timing
The timing of the interrupt. For a Single and Forced interrupt, the activation
time is displayed. For a Repeat interrupt, the information has the form:
Activation Time + n*Repeat Time. For example, 2000 + n*2345. This
means that the first time this interrupt is triggered, is at 2000 cycles and after that
with an interval of 2345 cycles.
C-SPY® Debugging Guide
274
for MSP430
AFE1_AFE2-1:1
Interrupts
Interrupt Log window
The Interrupt Log window is available from the C-SPY driver menu.
This window logs entrances to and exits from interrupts. The C-SPY simulator also logs
internal state changes.
The information is useful for debugging the interrupt handling in the target system.
When the Interrupt Log window is open, it is updated continuously at runtime.
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, see Getting started using interrupt logging, page 268.
For information about how to get a graphical view of the interrupt events during the
execution of your application, see Timeline window—Interrupt Log graph, page 280.
Display area
This area contains these columns:
Time
The point in time, measured in seconds, when the event occurred.
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.
275
AFE1_AFE2-1:1
Reference information on interrupts
This column is available when you have selected Show Cycles from the context
menu.
Interrupt
The interrupt as defined in the device description file.
Status
Shows the event status of the interrupt:
Triggered, the interrupt has passed its activation time.
Forced, the same as Triggered, but the interrupt was forced from the Forced
Interrupt window.
Enter, the interrupt is currently executing.
Leave, the interrupt has been executed.
Expired, the interrupt hold time has expired without the interrupt being
executed.
Rejected, the interrupt has been rejected because the necessary interrupt
registers were not set up to accept the interrupt.
Program Counter
The value of the program counter when the event occurred.
Execution Time/Cycles
The time spent in the interrupt, calculated using the Enter and Leave
timestamps. This includes time spent in any subroutines or other interrupts that
occurred in the specific interrupt.
Context menu
This context menu is available:
These commands are available:
Enable
Enables the logging system. The system will log information also when the
window is closed.
C-SPY® Debugging Guide
276
for MSP430
AFE1_AFE2-1:1
Interrupts
Clear
Deletes the log information. Note that this will happen also when you reset the
debugger.
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 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.
Interrupt Log Summary window
The Interrupt Log Summary window is available from the C-SPY driver menu.
This window displays a summary of logs of entrances to and exits from interrupts.
For more information, see Getting started using interrupt logging, page 268.
For information about how to get a graphical view of the interrupt events during the
execution of your application, see Timeline window—Interrupt Log graph, page 280.
Requirements
The C-SPY simulator.
277
AFE1_AFE2-1:1
Reference information on interrupts
Display area
Each row in this area displays statistics about the specific interrupt based on the log
information in these columns:
Interrupt
The type of interrupt that occurred.
At the bottom of the column, the current time or cycles is displayed—the
number of cycles or the execution time since the start of execution.
Count
The number of times the interrupt occurred.
First time
The first time the interrupt was executed.
Total (Time)**
The accumulated time spent in the interrupt.
Total (%)
The time in percent of the current time.
Fastest**
The fastest execution of a single interrupt of this type.
Slowest**
The slowest execution of a single interrupt of this type.
Min interval
The shortest time between two interrupts of this type.
The interval is specified as the time interval between the entry time for two
consecutive interrupts.
Max interval
The longest time between two interrupts of this type.
The interval is specified as the time interval between the entry time for two
consecutive interrupts.
** Calculated in the same way as for the Execution time/cycles in the Interrupt Log
window.
C-SPY® Debugging Guide
278
for MSP430
AFE1_AFE2-1:1
Interrupts
Context menu
This context menu is available:
These commands are available:
Enable
Enables the logging system. The system will log information also when the
window is closed.
Clear
Deletes the log information. Note that this will happen also when you reset the
debugger.
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 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.
279
AFE1_AFE2-1:1
Reference information on interrupts
Timeline window—Interrupt Log graph
The Interrupt Log graph displays interrupts collected by the trace system. In other
words, the graph provides a graphical view of the interrupt events during the execution
of your application.
Note: There is a limit on the number of saved logs. When this limit is exceeded, the
oldest entries in the buffer are erased.
Display area
●
The label area at the left end of the graph displays the names of the interrupts.
●
The graph itself shows active interrupts as a thick green horizontal bar where the
white figure indicates the time spent in the interrupt. This graph is a graphical
representation of the information in the Interrupt Log window, see Interrupt Log
window, page 275.
●
If the bar is displayed without horizontal borders, there are two possible causes:
●
The interrupt is reentrant and has interrupted itself. Only the innermost interrupt
will have borders.
●
There are irregularities in the interrupt enter-leave sequence, probably due to
missing logs.
●
If the bar is displayed without a vertical border, the missing border indicates an
approximate time for the log.
●
A red vertical line indicates overflow, which means that the communication channel
failed to transmit all interrupt logs from the target system.
At the bottom of the window, there is a common time axis that uses seconds as the time
unit.
C-SPY® Debugging Guide
280
for MSP430
AFE1_AFE2-1:1
Interrupts
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.
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.
281
AFE1_AFE2-1:1
Reference information on interrupts
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.
Interrupt
A heading that shows that the Interrupt 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.
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.
C-SPY® Debugging Guide
282
for MSP430
AFE1_AFE2-1:1
The advanced cycle
counter
●
Introduction to the advanced cycle counter
●
Using the cycle counter applications
●
Reference information on the advanced cycle counter.
Introduction to the advanced cycle counter
This section introduces the advanced cycle counter.
These topics are covered:
●
Reasons for using the advanced cycle counter
●
Briefly about the advanced cycle counter
●
Requirements for using the advanced cycle counter.
For related information, see Registers window, page 159.
REASONS FOR USING THE ADVANCED CYCLE COUNTER
The advanced cycle counter for MSP430 devices can help you, for example, to measure
the DMA load, to profile a part of your application, or to measure how long some tasks
take.
BRIEFLY ABOUT THE ADVANCED CYCLE COUNTER
The advanced cycle counter provides one or two 40-bit counters to count the number of
cycles used by the CPU to execute certain tasks. On some devices, the cycle counter
operation can be controlled using triggers. This allows, for example, conditional
profiling, such as profiling a specific section of code.
The Advanced Cycle Counter Control window contains preconfigured applications,
as well as the opportunity to customize your own use of the cycle counter.
REQUIREMENTS FOR USING THE ADVANCED CYCLE
COUNTER
The advanced cycle counter is only available if you are using the C-SPY FET Debugger
driver and an MSP430 device that supports the Enhanced Emulation Module at the
283
AFE1_AFE2-1:1
Using the cycle counter applications
required level. Some devices have one cycle counter and some have two. If your device
has one cycle counter, it is referred to as Cycle counter 0. If your device has two cycle
counters, they are referred to as Cycle counter 0 and Cycle counter 1.
Using the cycle counter applications
This section gives you descriptions of the Cycle counter 1 applications available in the
Advanced Cycle Counter Control window; that is, step-by-step descriptions of how to
use the extra cycle counter.
More specifically, you will get information about:
●
Counting all CPU cycles
●
Measuring the DMA load versus the CPU load
●
Profiling a specific part of your application
●
Measuring the Trigger hits
●
Measuring the number of CPU cycles for a task.
COUNTING ALL CPU CYCLES
The Cycle counter application in the Advanced Cycle Counter Control window
makes Cycle counter 1 behave like an ordinary cycle counter, counting all CPU cycles.
To count all CPU cycles:
1 Choose Emulator>Advanced Cycle Counter to open the Advanced Cycle Counter
Control window.
2 Select the Cycle counter option.
3 Click the Reset Counter 1 button to reset Cycle counter 1.
4 Execute your program and then stop the execution.
Cycle counter 1 in the Cycle Counter Values area now shows the number of CPU
cycles that were executed.
MEASURING THE DMA LOAD VERSUS THE CPU LOAD
The DMA load vs. CPU load application in the Advanced Cycle Counter Control
window measures the DMA load versus the CPU load by comparing the number of
DMA bus cycles with the total number of bus cycles.
To measure the DMA load versus the CPU load:
1 Choose Emulator>Advanced Cycle Counter to open the Advanced Cycle Counter
Control window.
C-SPY® Debugging Guide
284
for MSP430
AFE1_AFE2-1:1
The advanced cycle counter
2 Select the DMA load vs. CPU load option.
3 Click the Reset Counter 1 button to reset Cycle counter 1.
4 Execute your program and then stop the execution.
In the Cycle Counter Values area, Cycle counter 1 now shows the number of DMA bus
cycles, which can be compared with the number of CPU cycles shown by cycle counter
0.
PROFILING A SPECIFIC PART OF YOUR APPLICATION
The Profiling application in the Advanced Cycle Counter Control window lets you
profile a specific part of your program. Two reaction triggers or breakpoints define the
start and stop points for the cycle counter. Cycle counter 1 starts to count cycles at the
first trigger point and stops counting cycles at the second trigger.
Note: You cannot define which trigger point should be used as the start point or stop
point; the first of the two that is reached will start the cycle counter. The execution does
not stop at any of the triggers. You can compare the amount of time spent in a specific
function with the result for cycle counter 0, which counts all cycles for the entire
application.
To profile a section of your application:
1 Set up an advanced trigger at the start point of the code section that you want to
measure. For information about setting advanced trigger breakpoints, see Advanced
trigger breakpoints, page 105.
2 Set up a second advanced trigger at the stop point of the code section that you want to
measure.
3 Choose Emulator>Advanced Cycle Counter to open the Advanced Cycle Counter
Control window.
4 Select the Profiling option.
5 Select the start trigger point from the drop-down list Reaction trigger 1.
6 Select the stop trigger point from the drop-down list Reaction trigger 2.
7 Click the Reset Counter 1 button to reset Cycle counter 1.
8 Execute your program and then stop the execution.
In the Cycle Counter Values area, Cycle counter 1 shows the number of CPU cycles
spent in the selected code section or function. Cycle counter 0 shows all counted CPU
cycles.
285
AFE1_AFE2-1:1
Using the cycle counter applications
MEASURING THE TRIGGER HITS
The Trigger hits application in the Advanced Cycle Counter Control window
measures the number of times a certain point in your program has been reached. Cycle
counter 1 counts the number of times a trigger point has been triggered.
To measure how many times a point in your application is reached:
1 Set up an advanced trigger at the trigger point that you want to measure. For
information about setting advanced trigger breakpoints, see Advanced Trigger
breakpoints dialog box, page 130.
2 Choose Emulator>Advanced Cycle Counter to open the Advanced Cycle Counter
Control window.
3 Select the Trigger hits option.
4 Select the trigger point from the drop-down list Reaction trigger 1.
5 Click the Reset Counter 1 button to reset Cycle counter 1.
6 Execute your program and then stop the execution.
In the Cycle Counter Values area, Cycle counter 1 now shows the number of times the
trigger point has been triggered.
MEASURING THE NUMBER OF CPU CYCLES FOR A TASK
The Trip counter application in the Advanced Cycle Counter Control window
measures the number of CPU cycles required to execute a certain task or function. Cycle
counter 1 starts to count cycles at the start trigger and stops counting cycles at the stop
trigger. The execution stops when the stop trigger is reached.
To measure the number of cycles required to execute a task or function:
1 Set up an advanced trigger at the start point of the code section that you want to
measure. For information about setting advanced trigger breakpoints, see Advanced
Trigger breakpoints dialog box, page 130.
2 Set up a second advanced trigger at the stop point of the code section that you want to
measure.
3 Choose Emulator>Advanced Cycle Counter to open the Advanced Cycle Counter
Control window.
4 Select the Trip counter option.
5 Select the start trigger point from the drop-down list Reaction trigger 1.
6 Select the stop trigger point from the drop-down list Reaction trigger 2.
7 Click the Reset Counter 1 button to reset Cycle counter 1.
C-SPY® Debugging Guide
286
for MSP430
AFE1_AFE2-1:1
The advanced cycle counter
8 Execute your program. The execution stops when the stop trigger is reached.
In the Cycle Counter Values area, Cycle counter 1 now shows the number of CPU
cycles required to execute the task or function.
Reference information on the advanced cycle counter
This section gives reference information about the Advanced Cycle Counter Control
window.
Advanced Cycle Counter Control window
The Advanced Cycle Counter Control window is available from the Emulator menu
when the debugger is running.
Use this window to set the behavior of Cycle counter 0 and Cycle counter 1, the extra
cycle counter for some MSP430 devices.
Requirements
The C-SPY FET Debugger driver.
Applications
The Advanced Cycle Counter Control window contains preconfigured applications
for Cycle counter 1, as well as the opportunity to customize your own use of the cycle
counter. Use the cycle counter Applications to configure for what purpose to use the
cycle counter. Choose between:
Cycle counter
Makes Cycle counter 1 count all CPU cycles; see Counting all CPU cycles, page
284.
287
AFE1_AFE2-1:1
Reference information on the advanced cycle counter
DMA load vs. CPU load
Compares the number of DMA bus cycles with the total number of bus cycles;
see Measuring the DMA load versus the CPU load, page 284.
Profiling
Profiles a specific part of your program; see Profiling a specific part of your
application, page 285.
Trigger hits
Measures the number of times a certain point in your program has been reached;
see Measuring the Trigger hits, page 286.
Trip counter
Measures the number of CPU cycles required to execute a certain task or
function; see Measuring the number of CPU cycles for a task, page 286.
Custom
Make a custom application using the options in the Cycle Counter 1 area.
Cycle counter values
Cycle counter 0
The value of cycle counter 0. Cycle counter 0 is the same cycle counter as the
one displayed in the Register window.
Cycle counter 1
The value of Cycle counter 1. Cycle counter 1 is controlled by the settings in the
Advanced Cycle Counter Control window.
Mode
Reaction
Increments the counter on reactions. This option is only available for Cycle
counter 1.
Fetch
Increments the counter on all instruction fetch cycles.
Bus incl. DMA
Increments the counter on all bus cycles (including DMA cycles).
CPU excl. DMA
Increments the counter on all CPU bus cycles (excluding DMA cycles).
DMA
Increments the counter on all DMA bus cycles.
C-SPY® Debugging Guide
288
for MSP430
AFE1_AFE2-1:1
The advanced cycle counter
Start
Reaction
Uses the cycle counter reaction to start the cycle counter. This option is only
available for Cycle counter 1.
CPU starts
Starts counting cycles when the CPU starts to execute.
Act as counter 0/1
Starts counting when the other counter starts. This option is only available for
devices with two cycle counters.
Stop
Reaction
Uses the cycle counter reaction to stop the cycle counter. This option is only
available for Cycle counter 1.
CPU stops
Stops counting when the CPU stops the execution.
Act as counter 0/1
Stops counting when the other counter stops. This option is only available for
devices with two cycle counters.
Clear
Reaction
Clears the cycle counter on the cycle count reaction. This option is only
available for Cycle counter 1.
No event
Does not clear the counter.
Act as counter 0/1
Clears the cycle counter when the other automatically resets.
Combinations of start, stop, and clear reactions
Start
Reaction
Stop
Clear
Description
Reaction
The cycle counter reaction starts the cycle counter and
clears it at start.
Table 13: Cycle Counter 1, combinations of start, stop, and clear reactions
289
AFE1_AFE2-1:1
Reference information on the advanced cycle counter
Start
Stop
Clear
Description
Reaction
Reaction
The cycle counter reaction stops and clears the cycle
counter.
Reaction
Reaction
Reaction
Reaction
If the cycle counter is stopped, the cycle counter
reaction starts the counter. If the counter is running, the
cycle counter reaction stops the counter.
Reaction
If the cycle counter is stopped, the cycle counter
reaction starts the counter and clears it at start. If the
counter is running, the cycle counter reaction stops the
counter.
Table 13: Cycle Counter 1, combinations of start, stop, and clear reactions
Reaction trigger 1, Reaction trigger 2
Selects breakpoints to act as a reaction triggers.
Reset Counter 0/1
Resets the value and state of the cycle counter.
C-SPY® Debugging Guide
290
for MSP430
AFE1_AFE2-1:1
State storage
●
Introduction to state storage
●
Using state storage
●
Reference information on state storage.
Introduction to state storage
This section introduces the state storage module, a limited variant of a traditional trace
module available for the C-SPY FET Debugger driver.
These topics are covered:
●
Reasons for using state storage
●
Briefly about state storage
●
Requirements.
For related information, see also:
●
The sequencer, page 299.
REASONS FOR USING STATE STORAGE
State storage allows you to examine the last eight states or instructions that were
executed before a specific point was reached or a specific event occurred, or the next
eight states that will be executed after a specific point is reached or a specific event
occurs.
BRIEFLY ABOUT STATE STORAGE
The state storage module is a limited variant of a traditional trace module. It can store
eight states and can be used for monitoring program states or program flow, without
interfering with the execution. It uses a built-in buffer to store MAB, MDB, and CPU
control signal information.
REQUIREMENTS
The state storage module is only available if you are using the C-SPY FET Debugger
driver and a device that supports the Enhanced Emulation Module at the required level.
291
AFE1_AFE2-1:1
Using state storage
Using state storage
This section gives you step-by-step descriptions about how to use certain features
related to state storage.
●
More specifically, you will get information about:
Setting up state storage.
SETTING UP STATE STORAGE
To use the state storage module, you must:
1 Define one or several range breakpoints or conditional breakpoints.
2 In the breakpoints dialog box, select the action State Storage Trigger for these
breakpoints. This means that the breakpoint is defined as a state storage trigger. (State
storage can also be triggered from the Sequencer Control window.)
Note: Depending on the behavior you want when the state storage module is triggered,
it is useful to consider the combination of the Action options and the options available
in the State Storage Control window. See the examples following immediately after
these steps.
3 Choose Emulator>State Storage Control to open the State Storage Control window.
4 Select the option Enable state storage. Set the options Buffer wrap around, Trigger
action, and Storage action according to your preferences.
In the list State Storage Triggers, all breakpoints defined as state storage triggers are
listed.
For more details about the options, see State Storage Control window, page 294.
5 Click Apply.
6 Choose Emulator>State Storage window to open the State Storage window.
7 Choose Debug>Go to execute your application. Before you can view the state storage
information, you must stop the execution. You can do this, for instance, by using the
Break command.
For information about the window contents, see State Storage window, page 296.
Example
As an example, assume the following setup:
●
C-SPY® Debugging Guide
292
for MSP430
AFE1_AFE2-1:1
There is a conditional breakpoint which has both of the action options selected—
Break and State Storage Trigger
State storage
●
The state storage options Instruction fetch and Buffer wrap around are selected
in the State Storage Control window.
This will start the state storage immediately when you start executing your application.
When the breakpoint is triggered, the execution will stop and the last eight states can be
inspected in the State Storage window.
However, if you do not want the state storage module to start until a specific state is
reached, you would usually not want the execution to stop, because no state information
has been stored yet.
In this case, select the State Storage Trigger action in the Conditional breakpoints
dialog box (making sure that Break is deselected), and deselect the option Buffer wrap
around in the State Storage Control window.
When the breakpoint is triggered, the execution will not stop, but the state storage will
start. Because the option Buffer wrap around is deselected, you have ensured that the
data in the buffer will not be overwritten.
When another breakpoint (which has Break selected) is triggered, or if you stop the
execution by clicking the Break button, the State Storage window will show eight states
starting with the breakpoint that was used for starting the state storage module.
Reference information on state storage
This section gives reference information about these windows:
●
State Storage Control window, page 294
●
State Storage window, page 296.
293
AFE1_AFE2-1:1
Reference information on state storage
State Storage Control window
The State Storage Control window is available from the Emulator menu.
Use this window to define how to use the state storage module. The window is only
available for devices that support the Enhanced Emulation Module at the required level.
Requirements
The C-SPY FET Debugger driver.
Enable state storage
Enables the state storage module.
Buffer wrap around
Determines whether the state storage buffer should wrap around. If you select this
option, the state storage buffer is continuously overwritten until the execution is stopped
or a breakpoint is triggered. Only the eight last states are stored.
Alternatively, in order not to overwrite the information in the state storage buffer,
deselect this option. To guarantee that the eight first states will be stored, you should also
click Reset.
Reset
Resets the state storage module.
C-SPY® Debugging Guide
294
for MSP430
AFE1_AFE2-1:1
State storage
Trigger action
Selects which action to take when breakpoints defined as state storage triggers are
triggered:
Start on trigger
Starts state storage when the breakpoint is triggered.
Stop on trigger
Starts state storage immediately when execution starts. State storage stops when
the breakpoint is triggered.
None
Starts state storage immediately when execution starts. State storage does not
stop when the breakpoint is triggered. However, if execution stops, state storage
also stops but it will resume when execution resumes.
Storage action on
Selects when the state information should be collected:
Triggers
Stores state information at the time when the state storage trigger is triggered.
That is, when the breakpoint defined as a state storage trigger is triggered.
Instruction fetch
Stores state information at all instruction fetches.
All cycles
Stores state information for all cycles.
State storage triggers
Lists all the breakpoints that are defined as state storage triggers. That is, the breakpoints
that have the action State Storage Trigger selected.
295
AFE1_AFE2-1:1
Reference information on state storage
State Storage window
The State Storage window is available from the Emulator menu.
This window displays state storage information for eight states. Invalid data is displayed
in red color.
Requirements
The C-SPY FET Debugger driver.
Toolbar
The toolbar contains:
Update
Refreshes the data in the State Storage window, alternatively appends new data.
Automatic update
Updates the data in the state storage window automatically each time new data
is available in the state storage buffer.
Automatic restart
Resets the state storage module for consecutive data readouts after each readout.
Append data
Appends collected data from the state storage buffer to the data that is already
present in the State Storage window. The new data is added below the data that
is already present.
Display area
This area contains these columns:
Address bus
The stored value of the address bus.
C-SPY® Debugging Guide
296
for MSP430
AFE1_AFE2-1:1
State storage
Instruction
The instruction.
Mnemonic
The mnemonic.
Data bus
The stored content of the data bus.
297
AFE1_AFE2-1:1
Reference information on state storage
C-SPY® Debugging Guide
298
for MSP430
AFE1_AFE2-1:1
The sequencer
●
Introduction to the sequencer
●
Using the sequencer
●
Reference information on the sequencer.
Introduction to the sequencer
This section introduces the sequencer module.
These topics are covered:
●
Reasons for using the sequencer, page 299
●
Briefly about the sequencer, page 299
●
Requirements for using the sequencer, page 300.
For related information, see also:
●
State storage, page 291.
REASONS FOR USING THE SEQUENCER
The sequencer is useful if you, for instance, want to stop the execution or start the state
storage module under certain conditions, for instance a specific program flow. If you
combine this with letting the state storage module continuously store information, you
will have useful state information logged in the State Storage window when the
execution stops.
BRIEFLY ABOUT THE SEQUENCER
The sequencer module is a simple state machine that lets you break the execution or
trigger the state storage module using a more complex method than a standard
breakpoint.
In a simple setup, you can define three transition triggers, where the last one triggers an
action. In an advanced setup, the state machine can have four states (0-3). State 0 is the
starting state, and state 3 is the state that triggers a breakpoint (the action state). This
breakpoint can be designed either to stop execution, or to trigger the state storage
module.
299
AFE1_AFE2-1:1
Using the sequencer
REQUIREMENTS FOR USING THE SEQUENCER
The sequencer module is only available for the C-SPY FET Debugger driver and if you
are using a device that supports the Enhanced Emulation Module at the required level.
Using the sequencer
This section gives you step-by-step descriptions about how to use certain features of the
sequencer module.
More specifically, you will get information about:
●
Setting up the sequencer (simple setup)
●
Setting up the sequencer (advanced setup)
●
Using the sequencer to locate a problem.
SETTING UP THE SEQUENCER (SIMPLE SETUP)
In a simple setup, you can define three transition triggers, where the last one triggers an
action.
To define a simple sequencer setup:
1 Choose Emulator>Sequencer Control to open the Sequencer Control window.
2 Select the option Enable Sequencer.
3 Use the Transition trigger drop-down lists to define three breakpoints, where the last
breakpoint should act as a transition trigger.
SETTING UP THE SEQUENCER (ADVANCED SETUP)
In an advanced setup, the state machine can have four states (0-3). State 0 is the starting
state, and state 3 is the state that triggers a breakpoint (the action state). This breakpoint
can be designed either to stop execution, or to trigger the state storage module.
To define an advanced sequencer setup:
1 Choose Emulator>Sequencer Control to open the Sequencer Control window.
2 Select the option Enable Sequencer.
3 Click the Advanced button. This will let you define 4 states (0-3) with two transition
triggers each (a and b).
From the eight available hardware breakpoints (0-7) of the device, breakpoint number 7
will be reserved for state 3. The Transition trigger drop-down lists let you define one
breakpoint each, where the breakpoint should act as a transition trigger.
C-SPY® Debugging Guide
300
for MSP430
AFE1_AFE2-1:1
The sequencer
4 For each transition trigger, define which state should be the next state after the
transition.
Use the following options:
State Storage Trigger Select a breakpoint from the drop-down list to move the state
machine from one state to another. Note: to do this you must
first define the required conditional breakpoints.
Next state
Select a state to define which state should be the next state after
the transition.
5 Select an action to determine the result of the final transition trigger. If you select the
option Break, the execution will stop. If you select the option State Storage Trigger,
the state storage module will be triggered.
USING THE SEQUENCER TO LOCATE A PROBLEM
Consider this example:
void my_putchar(char c)
{
...
/* Code suspected to be erroneous */
...
}
void my_function(void)
{
...
my_putchar('a');
...
my_putchar('x');
...
my_putchar('@');
...
}
In this example, the customized putchar function my_putchar has for some reason a
problem with special characters. To locate the problem, it might be useful to stop
execution when the function is called, but only when it is called with one of the
problematic characters as the argument.
To locate the problem:
1 Set a hardware breakpoint on the statement my_putchar('@');.
2 Set another breakpoint on the suspected code within the function my_putchar().
301
AFE1_AFE2-1:1
Using the sequencer
3 Define these breakpoints as transition triggers. Choose Emulator>Sequencer Control
to open the Sequencer Control window. Select the option Enable sequencer.
4 In this simple example you will only need two transition triggers. Make sure the
following options are selected:
Option
Setting
Transition trigger 0
The breakpoint which is set on the function call
my_putchar('@');
Transition trigger 1
The breakpoint which is set on the suspected code within the function
my_putchar()
Action
Break
Table 14: Sequencer settings - example
The transition trigger 1 depends on the transition trigger 0. This means that the execution
will stop only when the function my_putchar() is called by the function call
my_putchar('@');
Click OK.
5 Set up the state storage module. Choose Emulator>State Storage Control to open the
State Storage Control window. Make sure the following options are selected:
Option
Setting
Enable state storage
Selected
Buffer wrap around
Selected
Storage action
Instruction fetch
Trigger action
None
Table 15: State Storage Control settings—example
Click OK.
6 Start the program execution. The state storage module will continuously store trace
information. Execution stops when the function my_putchar() has been called by the
function call my_putchar('@');
7 Choose Emulator>State Storage Window to open the State Storage window. You
can now examine the stored trace information. For more information, see State Storage
window, page 296.
8 When the sequencer is in state 3, the C-SPY breakpoint mechanism—which is used for
all breakpoints, not only transition triggers—can be locked. Therefore, you should
always end the session with one of these steps:
●
C-SPY® Debugging Guide
302
for MSP430
AFE1_AFE2-1:1
Disabling the sequencer module. This will restore all breakpoint actions.
The sequencer
●
Resetting the state machine by clicking the Reset States button. The sequencer will
still be active and trigger on the defined setup during the program execution.
Reference information on the sequencer
This section gives reference information about the Sequencer Control window.
Sequencer Control window
The Sequencer Control window is available from the Emulator menu.
Use this window to break the execution or trigger the state storage module, using a more
complex method than a standard breakpoint. The window is only available for devices
that support the Enhanced Emulation Module at the required level.
For related information about state storage, see State storage, page 291.
Requirements
The C-SPY FET Debugger driver.
Enable Sequencer
Enables the sequencer.
Action
Controls the result of the final transition trigger:
303
AFE1_AFE2-1:1
Reference information on the sequencer
Break
Stops the execution.
State Storage Trigger
Triggers to move the state machine from one state to another and activates the
state storage module. Requires that you select a conditional breakpoint, that you
have defined, from the Transition trigger drop-down list.
Current state
Displays the current state of the state machine.
Reset Trigger
Selects a trigger that will reset the state machine.
Reset States
Sets the state machine to state 0.
Advanced
Displays the advanced setup options. This will let you define 4 states (numbered 0–3)
with two transition triggers each (a and b). For each transition trigger, you can define
which state should be the next state after the transition.
State 0–3
Controls the transition triggers and the state that follows the transitions.
Transition trigger a
Selects a breakpoint to act as a transition trigger.
Transition trigger b
Selects a breakpoint to act as a transition trigger.
Next state
Select the next state after the transition.
For state 3—the final transition trigger—you must also define an Action: Break or
State Storage Trigger.
C-SPY® Debugging Guide
304
for MSP430
AFE1_AFE2-1:1
C-SPY macros
●
Introduction to C-SPY macros
●
Using C-SPY macros
●
Reference information on the macro language
●
Reference information on reserved setup macro function names
●
Reference information on C-SPY system macros
●
Graphical environment for macros
Introduction to C-SPY macros
These topics are covered:
●
Reasons for using C-SPY macros
●
Briefly about using C-SPY macros
●
Briefly about setup macro functions and files
●
Briefly about the macro language
REASONS FOR USING C-SPY MACROS
You can use C-SPY macros either by themselves or in conjunction with complex
breakpoints and interrupt simulation to perform a wide variety of tasks. Some examples
where macros can be useful:
●
Automating the debug session, for instance with trace printouts, printing values of
variables, and setting breakpoints.
●
Hardware configuring, such as initializing hardware registers.
●
Feeding your application with simulated data during runtime.
●
Simulating peripheral devices, see the chapter Interrupts. This only applies if you
are using the simulator driver.
●
Developing small debug utility functions, for instance calculating the stack depth.
305
AFE1_AFE2-1:1
Introduction to C-SPY macros
BRIEFLY ABOUT USING C-SPY MACROS
To use C-SPY macros, you should:
●
Write your macro variables and functions and collect them in one or several macro
files
●
Register your macros
●
Execute your macros.
For registering and executing macros, there are several methods to choose between.
Which method you choose depends on which level of interaction or automation you
want, and depending on at which stage you want to register or execute your macro.
BRIEFLY ABOUT SETUP MACRO FUNCTIONS AND FILES
There are some reserved setup macro function names that you can use for defining
macro functions which will be called at specific times, such as:
●
Once after communication with the target system has been established but before
downloading the application software
●
Once after your application software has been downloaded
●
Each time the reset command is issued
●
Once when the debug session ends.
To define a macro function to be called at a specific stage, you should define and register
a macro function with one of the reserved names. For instance, if you want to clear a
specific memory area before you load your application software, the macro setup
function execUserPreload should be used. This function is also suitable if you want
to initialize some CPU registers or memory-mapped peripheral units before you load
your application software.
You should define these functions in a setup macro file, which you can load before
C-SPY starts. Your macro functions will then be automatically registered each time you
start C-SPY. This is convenient if you want to automate the initialization of C-SPY, or
if you want to register multiple setup macros.
For more information about each setup macro function, see Reference information on
reserved setup macro function names, page 317.
BRIEFLY ABOUT THE MACRO LANGUAGE
The syntax of the macro language is very similar to the C language. There are:
C-SPY® Debugging Guide
306
for MSP430
AFE1_AFE2-1:1
●
Macro statements, which are similar to C statements.
●
Macro functions, which you can define with or without parameters and return
values.
C-SPY macros
●
Predefined built-in system macros, similar to C library functions, which perform
useful tasks such as opening and closing files, setting breakpoints, and defining
simulated interrupts.
●
Macro variables, which can be global or local, and can be used in C-SPY
expressions.
●
Macro strings, which you can manipulate using predefined system macros.
For more information about the macro language components, see Reference information
on the macro language, page 312.
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.
Using C-SPY macros
These tasks are covered:
●
Registering C-SPY macros—an overview
●
Executing C-SPY macros—an overview
●
Registering and executing using setup macros and setup files
●
Executing macros using Quick Watch
●
Executing a macro by connecting it to a breakpoint
●
Aborting a C-SPY macro
For more examples using C-SPY macros, see:
●
The tutorial about simulating an interrupt, which you can find in the Information
Center
●
Initializing target hardware before C-SPY starts, page 49.
307
AFE1_AFE2-1:1
Using C-SPY macros
REGISTERING C-SPY MACROS—AN OVERVIEW
C-SPY must know that you intend to use your defined macro functions, and thus you
must register your macros. There are various ways to register macro functions:
●
You can register macro functions during the C-SPY startup sequence, see
Registering and executing using setup macros and setup files, page 309.
●
You can register macros interactively in the Macro Registration window, see
Macro Registration window, page 357. Registered macros appear in the Debugger
Macros window, see Debugger Macros window, page 359.
●
You can register a file containing macro function definitions, using the system
macro __registerMacroFile. This means that you can dynamically select which
macro files to register, depending on the runtime conditions. Using the system
macro also lets you register multiple files at the same moment. For information
about the system macro, see __registerMacroFile, page 338.
Which method you choose depends on which level of interaction or automation you
want, and depending on at which stage you want to register your macro.
EXECUTING C-SPY MACROS—AN OVERVIEW
There are various ways to execute macro functions:
●
You can execute macro functions during the C-SPY startup sequence and at other
predefined stages during the debug session by defining setup macro functions in a
setup macro file, see Registering and executing using setup macros and setup files,
page 309.
●
The Quick Watch window lets you evaluate expressions, and can thus be used for
executing macro functions. For an example, see Executing macros using Quick
Watch, page 309.
●
The Macro Quicklaunch window is similar to the Quick Watch window, but is
more specified on designed for C-SPY macros. See Macro Quicklaunch window,
page 361.
●
A macro can be connected to a breakpoint; when the breakpoint is triggered the
macro is executed. For an example, see Executing a macro by connecting it to a
breakpoint, page 310.
Which method you choose depends on which level of interaction or automation you
want, and depending on at which stage you want to execute your macro.
C-SPY® Debugging Guide
308
for MSP430
AFE1_AFE2-1:1
C-SPY macros
REGISTERING AND EXECUTING USING SETUP MACROS AND
SETUP FILES
It can be convenient to register a macro file during the C-SPY startup sequence. To do
this, specify a macro file which you load before starting the debug session. Your macro
functions will be automatically registered each time you start the debugger.
If you use the reserved setup macro function names to define the macro functions, you
can define exactly at which stage you want the macro function to be executed.
To define a setup macro function and load it during C-SPY startup:
1 Create a new text file where you can define your macro function.
For example:
execUserSetup()
{
...
_ _registerMacroFile("MyMacroUtils.mac");
_ _registerMacroFile("MyDeviceSimulation.mac");
}
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.
EXECUTING MACROS USING QUICK WATCH
The Quick Watch window lets you dynamically choose when to execute a macro
function.
1 Consider this simple macro function that checks the status of a timer enable bit:
TimerStatus()
{
if ((TimerStatreg & 0x01) != 0)/* Checks the status of reg */
return "Timer enabled"; /* C-SPY macro string used */
else
return "Timer disabled"; /* C-SPY macro string used */
}
309
AFE1_AFE2-1:1
Using C-SPY macros
2 Save the macro function using the filename extension mac.
3 To load the macro file, choose View>Macros>Macro Registration. The Macro
Registration window is displayed. Click Add and locate the file using the file browser.
The macro file appears in the list of macros in the Macro Registration window.
4 Select the macro you want to register and your macro will appear in the Debugger
Macros window.
5 Choose View>Quick Watch to open the Quick Watch window, type the macro call
TimerStatus() in the text field and press Return,
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.
The macro will automatically be displayed in the Quick Watch window.
For more information, see Quick Watch window, page 97.
EXECUTING A MACRO BY CONNECTING IT TO A
BREAKPOINT
You can connect a macro to a breakpoint. The macro will then be executed when the
breakpoint is triggered. The advantage is that you can stop the execution at locations of
particular interest and perform specific actions there.
For instance, you can easily produce log reports containing information such as how the
values of variables, symbols, or registers change. To do this you might set a breakpoint
on a suspicious location and connect a log macro to the breakpoint. After the execution
you can study how the values of the registers have changed.
To create a log macro and connect it to a breakpoint:
1 Assume this skeleton of a C function in your application source code:
int fact(int x)
{
...
}
C-SPY® Debugging Guide
310
for MSP430
AFE1_AFE2-1:1
C-SPY macros
2 Create a simple log macro function like this example:
logfact()
{
__message "fact(" ,x, ")";
}
The __message statement will log messages to the Log window.
Save the macro function in a macro file, with the filename extension mac.
3 To register the macro, choose View>Macros>Macro Registration to open the Macro
Registration window and add your macro file to the list. Select the file to register it.
Your macro function will appear in the Debugger Macros window.
4 To set a code breakpoint, click the Toggle Breakpoint button on the first statement
within the function fact in your application source code. Choose View>Breakpoints
to open the Breakpoints window. Select your breakpoint in the list of breakpoints and
choose the Edit command from the context menu.
5 To connect the log macro function to the breakpoint, type the name of the macro
function, logfact(), in the Action field and click Apply. Close the dialog box.
6 Execute your application source code. When the breakpoint is triggered, the macro
function will be executed. You can see the result in the Log window.
●
Note that the expression in the Action field is evaluated only when the breakpoint
causes the execution to really stop. If you want to log a value and then automatically
continue execution, you can either:
●
Use the Condition field instead of the Action field. For an example, see Performing
a task and continuing execution, page 113.
Use a Log breakpoint, see Log breakpoints dialog box, page 119
7 You can easily enhance the log macro function by, for instance, using the __fmessage
statement instead, which will print the log information to a file. For information about
the __fmessage statement, see Formatted output, page 315.
For an example where a serial port input buffer is simulated using the method of
connecting a macro to a breakpoint, see the tutorial Simulating an interrupt in the
Information Center.
ABORTING A C-SPY MACRO
To abort a C-SPY macro:
1 Press Ctrl+Shift+. (period) for a short while.
2 A message that says that the macro has terminated is displayed in the Debug Log
window.
311
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.
Reference information on the macro language
Reference information about:
●
Macro functions, page 312
●
Macro variables, page 312
●
Macro parameters, page 313
●
Macro strings, page 313
●
Macro statements, page 314
●
Formatted output, page 315.
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
}
where parameterList is a list of macro parameters separated by commas, and
macroBody is any series of C-SPY variable definitions and C-SPY statements.
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 80.
The syntax for defining one or more macro variables is:
__var nameList;
where nameList is a list of C-SPY variable names separated by commas.
C-SPY® Debugging Guide
312
for MSP430
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 16: 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 380.
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
313
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";
Then examine these macro examples:
__var str;
/* A macro variable */
str = cstr
/* str is now just a pointer to char */
sizeof str
/* same as sizeof (char*), typically 2 or 4 */
str = __toString(cstr,512) /* str is now a macro string */
sizeof str
/* 5, the length of the string */
str[1]
/* 101, the ASCII code for 'e' */
str += " World!"
/* str is now "Hello World!" */
See also Formatted output, page 315.
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 80.
Conditional statements
if (expression)
statement
if (expression)
statement
else
statement
C-SPY® Debugging Guide
314
for MSP430
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:
__message argList;
Prints the output to the Debug Log window.
__fmessage file, argList; Prints the output to the designated file.
__smessage argList;
Returns a string containing the formatted output.
where argList is a comma-separated list of C-SPY expressions or strings, and file is
the result of the __openFile system macro, see __openFile, page 332.
315
AFE1_AFE2-1:1
Reference information on the macro language
To produce messages in the Debug Log window:
var1 = 42;
var2 = 37;
__message "This line prints the values ", var1, " and ", var2,
" in the Log window.";
This produces this message in the Log window:
This line prints the values 42 and 37 in the Log window.
To write the output to a designated file:
__fmessage myfile, "Result is ", res, "!\n";
To produce strings:
myMacroVar = __smessage 42, " is the answer.";
myMacroVar now contains the string "42 is the answer.".
Specifying display format of arguments
To override the default display format of a scalar argument (number or pointer) in
argList, suffix it with a : followed by a format specifier. Available specifiers are:
%b
for binary scalar arguments
%o
for octal scalar arguments
%d
for decimal scalar arguments
%x
for hexadecimal scalar arguments
%c
for character scalar arguments
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;
Depending on the value of the variables, this produces this message:
The character 'A' has the decimal value 65
Note: A character enclosed in single quotes (a character literal) is an integer constant
and is not automatically formatted as a character. For example:
__message 'A', " is the numeric value of the character ",
'A':%c;
C-SPY® Debugging Guide
316
for MSP430
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.
Reference information on reserved setup macro function names
There are reserved setup macro function names that you can use for defining your setup
macro functions. By using these reserved names, your function will be executed at
defined stages during execution. For more information, see Briefly about setup macro
functions and files, page 306.
Reference information about:
●
execUserPreload
●
execUserExecutionStarted
●
execUserExecutionStopped
●
execUserSetup
●
execUserPreReset
●
execUserReset
●
execUserExit
execUserPreload
Syntax
execUserPreload
For use with
All C-SPY drivers.
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.
317
AFE1_AFE2-1:1
Reference information on reserved setup macro function names
execUserExecutionStarted
Syntax
execUserExecutionStarted
For use with
All C-SPY drivers.
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
For use with
All C-SPY drivers.
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
For use with
All C-SPY drivers.
Description
Called once after the target application is downloaded.
Implement this macro to set up the memory map, breakpoints, interrupts, register macro
files, etc.
If you define interrupts or breakpoints in a macro file that is executed at system start
(using execUserSetup) we strongly recommend that you also make sure that they are
removed at system shutdown (using execUserExit). An example is available in
SetupSimple.mac, see the tutorials in the Information Center.
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.
C-SPY® Debugging Guide
318
for MSP430
AFE1_AFE2-1:1
C-SPY macros
execUserPreReset
Syntax
execUserPreReset
For use with
All C-SPY drivers.
Description
Called each time just before the reset command is issued.
Implement this macro to set up any required device state.
execUserReset
Syntax
execUserReset
For use with
All C-SPY drivers.
Description
Called each time just after the reset command is issued.
Implement this macro to set up and restore data.
execUserExit
Syntax
execUserExit
For use with
All C-SPY drivers.
Description
Called once when the debug session ends.
Implement this macro to save status data etc.
Reference information on C-SPY system macros
This section gives reference information about each of the C-SPY system macros.
This table summarizes the pre-defined system macros:
Macro
Description
__abortLaunch
Aborts the launch of the debugger
__cancelAllInterrupts
Cancels all ordered interrupts
__cancelInterrupt
Cancels an interrupt
__clearBreak
Clears a breakpoint
Table 17: Summary of system macros
319
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.
__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
__memorySave
Saves the contents of a specified memory area 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
__popSimulatorInterruptExec Informs the interrupt simulation system that an
utingStack
interrupt handler has finished executing
__readFile
Reads from the specified file
__readFileByte
Reads one byte from the specified file
__readMemory8,
__readMemoryByte
Reads one byte from the specified memory location
__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
__setAdvancedTriggerBreak
Sets an advanced trigger breakpoint
__setCodeBreak
Sets a code breakpoint
__setConditionalBreak
Sets a conditional breakpoint
Table 17: Summary of system macros
C-SPY® Debugging Guide
320
for MSP430
AFE1_AFE2-1:1
C-SPY macros
Macro
Description
__setDataBreak
Sets a data breakpoint
__setDataLogBreak
Sets a data log breakpoint
__setLogBreak
Sets a log breakpoint
__setRangeBreak
Sets a range 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,
__writeMemoryByte
Writes one byte to the specified memory location
__writeMemory16
Writes a two-byte word to the specified memory
location
__writeMemory32
Writes a four-byte word to the specified memory
location
Table 17: Summary of system macros
__abortLaunch
Syntax
__abortLaunch(message)
Parameters
message
A string that is printed as an error message when the macro executes.
321
AFE1_AFE2-1:1
Reference information on C-SPY system macros
Return value
None.
For use with
All C-SPY drivers.
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().
Example
if (!__messageBoxYesCancel("Do you want to mass erase to unlock
the device?", "Unlocking device"))
{ __abortLaunch("Unlock canceled. Debug session cannot
continue."); }
__cancelAllInterrupts
Syntax
__cancelAllInterrupts()
Return value
int 0
For use with
The C-SPY Simulator.
Description
Cancels all ordered interrupts.
__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 18: __cancelInterrupt return values
For use with
The C-SPY Simulator.
Description
Cancels the specified interrupt.
C-SPY® Debugging Guide
322
for MSP430
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.
Return value
int 0
For use with
All C-SPY drivers.
Description
Clears a user-defined breakpoint.
See also
Breakpoints, page 103.
__closeFile
Syntax
__closeFile(fileHandle)
Parameters
fileHandle
A macro variable used as filehandle by the __openFile macro.
Return value
int 0
For use with
All C-SPY drivers.
Description
Closes a file previously opened by __openFile.
__delay
Syntax
__delay(value)
Parameters
value
The number of milliseconds to delay execution.
Return value
int 0
For use with
All C-SPY drivers.
Description
Delays execution the specified number of milliseconds.
323
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 19: __disableInterrupts return values
For use with
The C-SPY Simulator.
Description
Disables the generation of interrupts.
__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.
"fet" corresponds to the C-SPY FET Debugger driver.
Return value
Result
Value
Successful
1
Unsuccessful
0
Table 20: __driverType return values
For use with
Description
All C-SPY drivers
Checks to see if the current C-SPY driver is identical to the driver type of the
driver_id parameter.
Example
__driverType("sim")
If the simulator is the current driver, the value 1 is returned. Otherwise 0 is returned.
C-SPY® Debugging Guide
324
for MSP430
AFE1_AFE2-1:1
C-SPY macros
__enableInterrupts
Syntax
__enableInterrupts()
Return value
Result
Value
Successful
int 0
Unsuccessful
Non-zero error number
Table 21: __enableInterrupts return values
For use with
The C-SPY Simulator.
Description
Enables the generation of interrupts.
__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 22: __evaluate return values
For use with
All C-SPY drivers.
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)
The macro variable myVar is assigned the value 8.
325
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 138.
length
An integer that specifies how many bytes are affected.
format
One of these alternatives:
Copy
value will be copied to the specified memory area.
AND
An AND 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.
XOR
An XOR operation will be performed between value and the
existing contents of memory before writing the result to memory.
Return value
int 0
For use with
All C-SPY drivers.
Description
Fills a specified memory area with a byte value.
Example
__fillMemory8(0x80, 0x700, "Memory", 0x10, "OR");
__fillMemory16
Syntax
__fillMemory16(value, address, zone, length, format)
Parameters
value
An integer that specifies the value.
C-SPY® Debugging Guide
326
for MSP430
AFE1_AFE2-1:1
C-SPY macros
address
An integer that specifies the memory start address.
zone
A string that specifies the memory zone, see C-SPY memory zones, page 138.
length
An integer that defines how many 2-byte entities to be affected.
format
One of these alternatives:
Copy
value will be copied to the specified memory area.
AND
An AND 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.
XOR
An XOR operation will be performed between value and the
existing contents of memory before writing the result to memory.
Return value
int 0
For use with
All C-SPY drivers.
Description
Fills a specified memory area with a 2-byte value.
Example
__fillMemory16(0xCDCD, 0x7000, "Memory", 0x200, "Copy");
__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.
zone
A string that specifies the memory zone, see C-SPY memory zones, page 138.
327
AFE1_AFE2-1:1
Reference information on C-SPY system macros
length
An integer that defines how many 4-byte entities to be affected.
format
One of these alternatives:
Copy
value will be copied to the specified memory area.
AND
An AND 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.
XOR
An XOR operation will be performed between value
and the existing contents of memory before writing
the result to memory.
Return value
int 0
For use with
All C-SPY drivers.
Description
Fills a specified memory area with a 4-byte value.
Example
__fillMemory32(0x0000FFFF, 0x4000, "Memory", 0x1000, "XOR");
__isBatchMode
Syntax
__isBatchMode()
Return value
Result
Value
True
int 1
False
int 0
Table 23: __isBatchMode return values
For use with
All C-SPY drivers.
Description
This macro returns True if the debugger is running in batch mode, otherwise it returns
False.
C-SPY® Debugging Guide
328
for MSP430
AFE1_AFE2-1:1
C-SPY macros
__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.
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 24: __loadImage return values
For use with
All C-SPY drivers.
Description
Loads an image (debug file).
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
329
AFE1_AFE2-1:1
Reference information on C-SPY system macros
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 391 and Loading multiple images, page 47.
__memoryRestore
Syntax
__memoryRestore(zone, filename)
Parameters
zone
A string that specifies the memory zone, see C-SPY memory zones, page 138.
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.
Return value
int 0
For use with
All C-SPY drivers.
Description
Reads the contents of a file and saves it to the specified memory zone.
Example
__memoryRestore("Memory", "c:\\temp\\saved_memory.hex");
See also
Memory Restore dialog box, page 150.
__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.
C-SPY® Debugging Guide
330
for MSP430
AFE1_AFE2-1:1
C-SPY macros
format
A string that specifies the format to be used for the saved memory. Choose
between:
intel-extended
motorola
motorola-s19
motorola-s28
motorola-s37
msp430-txt.
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.
Return value
int 0
For use with
All C-SPY drivers.
Description
Saves the contents of a specified memory area to a file.
Example
__memorySave("Memory:0x00", "Memory:0xFF", "intel-extended",
"c:\\temp\\saved_memory.hex");
See also
Memory Save dialog box, page 149.
__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.
331
AFE1_AFE2-1:1
Reference information on C-SPY system macros
Return value
Result
Value
Yes
1
No
0
Table 25: __messageBoxYesCancel return values
For use with
All C-SPY drivers.
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 26: __messageBoxYesNo return values
For use with
All C-SPY drivers.
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.
__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.
C-SPY® Debugging Guide
332
for MSP430
AFE1_AFE2-1:1
C-SPY macros
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)
These are optional and mutually exclusive:
"b" binary, opens the file in binary mode
"t" ASCII text, opens the file in text mode
This access type is optional:
"+" together with r, w, or a; r+ or w+ is read and write, while a+ is read and
append
Return value
Result
Value
Successful
The file handle
Unsuccessful
An invalid file handle, which tests as False
Table 27: __openFile return values
For use with
All C-SPY drivers.
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.
Example
__var myFileHandle;
See also
For information about argument variables, see the IDE Project Management and
Building Guide.
/* The macro variable to contain */
/* the file handle */
myFileHandle = __openFile("$PROJ_DIR$\\Debug\\Exe\\test.tst",
"r");
if (myFileHandle)
{
/* successful opening */
}
333
AFE1_AFE2-1:1
Reference information on C-SPY system macros
__orderInterrupt
Syntax
__orderInterrupt(specification, first_activation,
repeat_interval, variance, infinite_hold_time,
hold_time, probability)
Parameters
specification
The interrupt (string). The specification can either be the full specification used
in the device description file (ddf) or only the name. In the latter case 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)
infinite_hold_time
1 if infinite, otherwise 0.
hold_time
The hold time (integer)
probability
The probability in percent (integer between 0 and 100)
Return value
The macro returns an interrupt identifier (unsigned long).
If the syntax of specification is incorrect, it returns -1.
For use with
The C-SPY Simulator.
Description
Generates an interrupt.
Example
This example generates a repeating interrupt using an infinite hold time first activated
after 4000 cycles:
__orderInterrupt( "USART0RX_VECTOR", 4000, 2000, 0, 1, 0, 100 );
C-SPY® Debugging Guide
334
for MSP430
AFE1_AFE2-1:1
C-SPY macros
__popSimulatorInterruptExecutingStack
Syntax
__popSimulatorInterruptExecutingStack(void)
Return value
int 0
For use with
The C-SPY Simulator.
Description
Informs the interrupt simulation system that an interrupt handler has finished executing,
as if the normal instruction used for returning from an interrupt handler was executed.
This is useful if you are using interrupts in such a way that the normal instruction for
returning from an interrupt handler is not used, for example in an operating system with
task-switching. In this case, the interrupt simulation system cannot automatically detect
that the interrupt has finished executing.
See also
Simulating an interrupt in a multi-task system, page 267.
__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 28: __readFile return values
For use with
Description
All C-SPY drivers.
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.
335
AFE1_AFE2-1:1
Reference information on C-SPY system macros
Example
__var number;
if (__readFile(myFileHandle, &number) == 0)
{
// Do something with number
}
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.
__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.
For use with
All C-SPY drivers.
Description
Reads one byte from a file.
Example
__var byte;
while ( (byte = __readFileByte(myFileHandle)) != -1 )
{
/* Do something with byte */
}
__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 138.
Return value
The macro returns the value from memory.
For use with
All C-SPY drivers.
C-SPY® Debugging Guide
336
for MSP430
AFE1_AFE2-1:1
C-SPY macros
Description
Reads one byte from a given memory location.
Example
__readMemory8(0x0108, "Memory");
__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 138.
Return value
The macro returns the value from memory.
For use with
All C-SPY drivers.
Description
Reads a two-byte word from a given memory location.
Example
__readMemory16(0x0108, "Memory");
__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 138.
Return value
The macro returns the value from memory.
For use with
All C-SPY drivers.
Description
Reads a four-byte word from a given memory location.
Example
__readMemory32(0x0108, "Memory");
337
AFE1_AFE2-1:1
Reference information on C-SPY system 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.
Return value
int 0
For use with
All C-SPY drivers.
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");
See also
Using C-SPY macros, page 307.
__resetFile
Syntax
__resetFile(fileHandle)
Parameters
fileHandle
A macro variable used as filehandle by the __openFile macro.
Return value
int 0
For use with
All C-SPY drivers.
Description
Rewinds a file previously opened by __openFile.
C-SPY® Debugging Guide
338
for MSP430
AFE1_AFE2-1:1
C-SPY macros
__setAdvancedTriggerBreak
Syntax
__setAdvancedTriggerBreak(type, condition, access, action, mask
cond_value)
Parameters
All parameters are strings.
type
The breakpoint type; either "Address", "Data", or "Register".
condition
The breakpoint condition operator, either "==", ">=", "<=", or
"!=".
access
The memory access type. Choose between:
"Read"
"Write"
"ReadWrite"
"Fetch"
"FetchHold"
"NoFetch"
"NoFetchRead"
"NoFetchNoDMA"
"DMA"
"NoDMA"
"WriteNoDMA"
"NoFetchReadNoDMA"
"ReadNoDMA"
"ReadDMA"
"WriteDMA"
action
The action type: "Break", "Trigger", or "BreakTrigger".
mask
A 16-bit value that the breakpoint address or value will be masked
with.
cond_value
An extra conditional data value.
339
AFE1_AFE2-1:1
Reference information on C-SPY system 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 29: __setAdvancedTriggerBreak return values
For use with
The C-SPY FET Debugger driver.
Description
Sets an advanced trigger breakpoint.
Example
__var brk;
brk = __setAdvancedTriggerBreak("Register", ">=", "Write",
"Trigger", "0x0000", "0x4000");
...
__clearBreak(brk);
See also
Breakpoints, page 103.
__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 132.
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.
C-SPY® Debugging Guide
340
for MSP430
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 30: __setCodeBreak return values
For use with
All C-SPY drivers.
Description
Sets a code breakpoint, that is, a breakpoint which is triggered just before the processor
fetches an instruction at the specified location.
Examples
__setCodeBreak("{D:\\src\\prog.c}.12.9", 3, "d>16", "TRUE",
"ActionCode()");
This example sets a code breakpoint on the label main in your source:
__setCodeBreak("main", 0, "1", "TRUE", "");
See also
Breakpoints, page 103.
__setConditionalBreak
Syntax
__setConditionalBreak(location, type, operator, access, action,
mask, cond_value, cond_operator,
cond_access, cond_mask)
Parameters
All parameters are strings.
location
The breakpoint location. Choose between:
A source location on the form "{filename}.line.col" (for
example "{D:\\src\\prog.c}.12.9")
An absolute location on the form "zone:hexaddress" or simply
"hexaddress" (for example "Memory:0x42")
An expression whose value designates a location (for example
"my_global_variable").
A register (for example "R10")
type
The breakpoint type: "Address", "Data", or "Register".
operator
The breakpoint operator: "==", ">=", "<=", or "!=".
341
AFE1_AFE2-1:1
Reference information on C-SPY system macros
access
The memory access type: "Read", "Write", "ReadWrite", or
"Fetch".
action
The action type: "Break", "Trigger", or "BreakTrigger".
mask
A 16-bit value that the breakpoint address or value will be masked
with.
cond_value
An extra conditional data value.
cond_operator
The condition operator: "==", ">=", "<=", or "!=".
cond_access
The access type of the condition: "Read" or "Write".
cond_mask
The mask value of the condition.
Return value
Result
Value
Successful
An unsigned integer uniquely identifying the breakpoint. This value
must be used to clear the breakpoint.
Unsuccessful
0
Table 31: __setConditionalBreak return values
For use with
The C-SPY FET Debugger driver.
Description
Sets a conditional breakpoint.
Example
__var brk;
brk = __setConditionalBreak("R10", "Register", "0x5000", ">=",
"Write", "Trigger", "0x0000", "0x4000", "<=", "Write",
“0x00FF”);
...
__clearBreak(brk);
See also
Breakpoints, page 103.
C-SPY® Debugging Guide
342
for MSP430
AFE1_AFE2-1:1
C-SPY macros
__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
132.
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 32: __setDataBreak return values
For use with
The C-SPY Simulator.
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.
Example
__var brk;
brk = __setDataBreak("Memory:0x4710", 3, "d>6", "TRUE",
"W", "ActionData()");
...
__clearBreak(brk);
343
AFE1_AFE2-1:1
Reference information on C-SPY system macros
See also
Breakpoints, page 103.
__setDataLogBreak
Syntax
__setDataLogBreak(variable, access)
Parameters
variable
A string that defines the variable the breakpoint is set on, a variable of integer
type with static storage duration. The microcontroller must also be able to
access the variable with a single-instruction memory access, which means that
you can only set data log breakpoints on 8-bit variables.
access
The memory access type: "R", for read, "W" for write, or "RW" for read/write.
Return value
Result
Value
Successful
An unsigned integer uniquely identifying the breakpoint. This value
must be used to clear the breakpoint.
Unsuccessful
0
Table 33: __setDataLogBreak return values
For use with
The C-SPY Simulator.
Description
Sets a data log breakpoint, that is, a breakpoint which is triggered when a specified
variable is accessed. Note that a data log breakpoint does not stop the execution, it just
generates a data log.
Example
__var brk;
brk = __setDataLogBreak("MyVar", "R");
...
__clearBreak(brk);
See also
Breakpoints, page 103 and Getting started using data logging, page 196.
C-SPY® Debugging Guide
344
for MSP430
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 132.
message
The message text.
msg_type
The message type; choose between:
TEXT, the message is written word for word.
ARGS, the message is interpreted as a comma-separated list of C-SPY
expressions or strings.
condition
The breakpoint condition (string).
cond_type
The condition type; either "CHANGED" or "TRUE" (string).
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 34: __setLogBreak return values
For use with
All C-SPY drivers.
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.
345
AFE1_AFE2-1:1
Reference information on C-SPY system macros
Example
__var logBp1;
__var logBp2;
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 315 and Breakpoints, page 103.
__setRangeBreak
Syntax
__setRangeBreak(start_loc, end_loc, end_cond, type, access,
action, action_when)
Parameters
All parameters are strings.
start_loc
The start location. Choose between:
A source location on the form "{filename}.line.col" (for
example "{D:\\src\\prog.c}.12.9")
An absolute location on the form "zone:hexaddress" or simply
"hexaddress" (for example "Memory:0x42")
An expression whose value designates a location (for example
"my_global_variable").
C-SPY® Debugging Guide
346
for MSP430
AFE1_AFE2-1:1
end_loc
The end location. This can be either the same as for start_loc
above or the length of the range.
end_cond
The type of end condition: "Location", "Length", or
"Automatic".
type
The breakpoint type: "Address" or "Data".
access
The memory access type: "Read", "Write", "ReadWrite", or
"Fetch".
C-SPY macros
action
The action type: "Break", "Trigger", or "BreakTrigger".
action_when
Specifies if the action should happen at an access inside or outside of
the specified range: "Inside" or "Outside".
Return value
Result
Value
Successful
An unsigned integer uniquely identifying the breakpoint. This value
must be used to clear the breakpoint.
Unsuccessful
0
Table 35: __setRangeBreak return values
For use with
The C-SPY FET Debugger driver.
Description
Sets a range breakpoint.
Example
__var brk;
brk = __setRangeBreak("Memory:0x1240", "Memory:0x1360",
"Location", "Address", "Fetch", "Trigger", "Inside");
...
__clearBreak(brk);
See also
Breakpoints, page 103.
__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
132.
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.
347
AFE1_AFE2-1:1
Reference information on C-SPY system 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 36: __setSimBreak return values
For use with
The C-SPY Simulator.
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 132.
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 37: __setTraceStartBreak return values
For use with
The C-SPY Simulator.
Description
Sets a breakpoint at the specified location. When that breakpoint is triggered, the trace
system is started.
C-SPY® Debugging Guide
348
for MSP430
AFE1_AFE2-1:1
C-SPY macros
Example
__var startTraceBp;
__var stopTraceBp;
traceOn()
{
startTraceBp = __setTraceStartBreak
("{C:\\TEMP\\Utilities.c}.23.1");
stopTraceBp = __setTraceStopBreak
("{C:\\temp\\Utilities.c}.30.1");
}
traceOff()
{
__clearBreak(startTraceBp);
__clearBreak(stopTraceBp);
}
See also
Breakpoints, page 103.
__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 132.
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 38: __setTraceStopBreak return values
For use with
The C-SPY Simulator.
Description
Sets a breakpoint at the specified location. When that breakpoint is triggered, the trace
system is stopped.
Example
See __setTraceStartBreak, page 348.
349
AFE1_AFE2-1:1
Reference information on C-SPY system macros
See also
Breakpoints, page 103.
__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 39: __sourcePosition return values
For use with
All C-SPY drivers.
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.
For use with
All C-SPY drivers.
C-SPY® Debugging Guide
350
for MSP430
AFE1_AFE2-1:1
C-SPY macros
Description
This macro searches a given string (macroString) for the occurrence of another string
(pattern).
Example
__strFind("Compiler", "pile", 0)
__strFind("Compiler", "foo", 0)
See also
Macro strings, page 313.
= 3
= -1
__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
Return value
A substring extracted from the given macro string.
For use with
All C-SPY drivers.
Description
This macro extracts a substring from another string (macroString).
Example
__subString("Compiler", 0, 2)
The resulting macro string contains Co.
__subString("Compiler", 3, 4)
The resulting macro string contains pile.
See also
Macro strings, page 313.
__targetDebuggerVersion
Syntax
__targetDebuggerVersion()
Return value
A string that represents the version number of the C-SPY debugger processor module.
For use with
All C-SPY drivers.
351
AFE1_AFE2-1:1
Reference information on C-SPY system macros
Description
This macro returns the version number of the C-SPY debugger processor module.
Example
__var toolVer;
toolVer = __targetDebuggerVersion();
__message "The target debugger version is, ", toolVer;
__toLower
Syntax
__toLower(macroString)
Parameters
macroString
A macro string.
Return value
The converted macro string.
For use with
All C-SPY drivers.
Description
This macro returns a copy of the parameter macroString where all the characters have
been converted to lower case.
Example
__toLower("IAR")
The resulting macro string contains iar.
__toLower("Mix42")
The resulting macro string contains mix42.
See also
Macro strings, page 313.
__toString
Syntax
__toString(C_string, maxlength)
Parameters
C_string
Any null-terminated C string.
maxlength
The maximum length of the returned macro string.
Return value
Macro string.
For use with
All C-SPY drivers.
C-SPY® Debugging Guide
352
for MSP430
AFE1_AFE2-1:1
C-SPY macros
Description
This macro is used for converting C strings (char* or char[]) into macro strings.
Example
Assuming your application contains this definition:
char const * hptr = "Hello World!";
this macro call:
__toString(hptr, 5)
would return the macro string containing Hello.
See also
Macro strings, page 313.
__toUpper
Syntax
__toUpper(macroString)
Parameters
macroString
A macro string.
Return value
The converted string.
For use with
All C-SPY drivers.
Description
This macro returns a copy of the parameter macroString where all the characters have
been converted to upper case.
Example
__toUpper("string")
The resulting macro string contains STRING.
See also
Macro strings, page 313.
__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.
353
AFE1_AFE2-1:1
Reference information on C-SPY system macros
Return value
Value
Result
module_id
A unique module identification (the same as the input
parameter).
int 0
The unloading failed.
Table 40: __unloadImage return values
For use with
All C-SPY drivers.
Description
Unloads debug information from an already downloaded image.
See also
Loading multiple images, page 47 and Images, page 391.
__writeFile
Syntax
__writeFile(fileHandle, value)
Parameters
fileHandle
A macro variable used as filehandle by the __openFile macro.
value
An integer.
Return value
int 0
For use with
All C-SPY drivers.
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.
C-SPY® Debugging Guide
354
for MSP430
AFE1_AFE2-1:1
C-SPY macros
Return value
int 0
For use with
All C-SPY drivers.
Description
Writes one byte to the file fileHandle.
__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 138.
Return value
int 0
For use with
All C-SPY drivers.
Description
Writes one byte to a given memory location.
Example
__writeMemory8(0x2F, 0x8020, "Memory");
__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 138.
Return value
int 0
355
AFE1_AFE2-1:1
Graphical environment for macros
For use with
All C-SPY drivers.
Description
Writes two bytes to a given memory location.
Example
__writeMemory16(0x2FFF, 0x8020, "Memory");
__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 138.
Return value
int 0
For use with
All C-SPY drivers.
Description
Writes four bytes to a given memory location.
Example
__writeMemory32(0x5555FFFF, 0x8020, "Memory");
Graphical environment for macros
Reference information about:
C-SPY® Debugging Guide
356
for MSP430
AFE1_AFE2-1:1
●
Macro Registration window, page 357
●
Debugger Macros window, page 359
●
Macro Quicklaunch window, page 361
C-SPY macros
Macro Registration window
The Macro Registration window is available from the View>Macros submenu during
a debug session.
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 308.
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.
357
AFE1_AFE2-1:1
Graphical environment for macros
Context menu
This context menu is available:
These commands are available:
Add
Opens a file browser where you can locate the macro file that you want to add
to the list. This menu command is also available as a function button at the top
of the window.
Remove
Removes the selected debugger macro file from the list. This menu command is
also available as a function button at the top of the window.
Remove All
Removes all macro files from the list. This menu command is also available as
a function button at the top of the window.
Reload
Registers the selected macro file. Typically, this is useful when you have edited
a macro file. This menu command is also available as a function button at the
top of the window.
Open File
Opens the selected macro file in the editor window.
Open Debugger Macros Window
Opens the Debugger Macros window.
C-SPY® Debugging Guide
358
for MSP430
AFE1_AFE2-1:1
C-SPY macros
Debugger Macros window
The Debugger Macros window is available from the View>Macros submenu during a
debug session.
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.
359
AFE1_AFE2-1:1
Graphical environment for macros
Context menu
This context menu is available:
These commands are available:
Open File
Opens the selected debugger macro file in the editor window.
Add to Quicklaunch Window
Adds the selected macro to the Macro Quicklaunch window.
User Macros
Lists only the debugger macros that you have defined yourself.
System Macros
Lists only the predefined system macros.
All Macros
Lists all debugger macros, both predefined system macros and your own.
Open Macro Registration Window
Opens the Macro Registration window.
C-SPY® Debugging Guide
360
for MSP430
AFE1_AFE2-1:1
C-SPY macros
Macro Quicklaunch window
The Macro Quicklaunch window is available from the View menu.
Use this window to evaluate expressions, typically C-SPY macros.
For some devices, there are predefined C-SPY macros available with device support,
typically provided by the chip manufacturer. These macros are useful for performing
certain device-specific tasks. The macros are available in the Macro Quicklaunch
window and are easily identified by their green icon,
The Macro Quicklaunch window is similar to the Quick Watch window, but is
primarily designed for evaluating C-SPY macros. The window gives you precise control
over when to evaluate an expression.
See also Executing C-SPY macros—an overview, page 308.
To add an expression:
1 Choose one of these alternatives:
●
Drag the expression to the window
●
In the Expression column, type the expression you want to examine.
If the expression you add and want to evaluate is a C-SPY macro, the macro must first
be registered, see Registering C-SPY macros—an overview, page 308.
To evaluate an expression:
1 Double-click the Recalculate icon to calculate the value of that expression.
Requirements
None; this window is always available.
361
AFE1_AFE2-1:1
Graphical environment for 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:
These commands are available:
Evaluate Now
Evaluates the selected expression.
Remove
Removes the selected expression.
Remove All
Removes all selected expressions.
C-SPY® Debugging Guide
362
for MSP430
AFE1_AFE2-1:1
The C-SPY command line
utility—cspybat
●
Using C-SPY in batch mode
●
Summary of C-SPY command line options
●
Reference information on C-SPY command line options.
Using C-SPY in batch mode
You can execute C-SPY in batch mode if you use the command line utility cspybat,
installed in the directory common\bin.
These topics are covered:
●
Starting cspybat
●
Output
●
Invocation syntax
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]
363
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 381.
●
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 430\bin.
driver_DLL
The C-SPY driver DLL file; available in 430\bin.
debug_file
The object file that you want to debug (filename extension d43). See
also --debugfile, page 371.
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 367.
Table 41: cspybat parameters
C-SPY® Debugging Guide
364
for MSP430
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 367.
Table 41: cspybat parameters (Continued)
Summary of C-SPY command line options
Reference information about:
●
General cspybat options
●
Options available for all C-SPY drivers
●
Options available for the simulator driver
●
Options available for the C-SPY FET Debugger driver
GENERAL CSPYBAT OPTIONS
--attach_to_running_ta Makes the debugger attach to a running application at
its current location, without resetting the target system.
rget
--backend
Marks the beginning of the parameters to be sent to the
C-SPY driver (mandatory).
--code_coverage_file
Enables the generation of code coverage information
and places it in a specified file.
--cycles
Specifies the maximum number of cycles to run.
--debugfile
Specifies an alternative debug file.
--downloadonly
Downloads a code image without starting a debug
session afterwards.
-f
Extends the command line.
--leave_target_running Makes the debugger leave the application running on
the target hardware after the debug session is closed.
--macro
Specifies a macro file to be used.
--macro_param
Assigns a value to a C-SPY macro parameter.
365
AFE1_AFE2-1:1
Summary of C-SPY command line options
--plugin
Specifies a plugin file to be used.
--silent
Omits the sign-on message.
--timeout
Limits the maximum allowed execution time.
OPTIONS AVAILABLE FOR ALL C-SPY DRIVERS
--core
Specifies the core to be used.
-d
Specifies the C-SPY driver to be used.
-p
Specifies the device description file to be used.
OPTIONS AVAILABLE FOR THE SIMULATOR DRIVER
--disable_interrupts
Disables the interrupt simulation.
--function_profiling
Analyzes your source code to find where the most time is
spent during execution.
--mapu
Activates memory access checking.
--odd_word_check
Stops the execution if an access to an odd address is
found.
OPTIONS AVAILABLE FOR THE C-SPY FET DEBUGGER
DRIVER
--allow_access_to_BSL Enables erase/write access to BSL flash memory.
--allow_locked_flash_ Enables erase/write access to locked flash memory.
access
--connection
Specifies the communication channel to be used.
--derivative
Specifies the device.
--disable_memory_cach Disables the memory cache in the FET debugger.
e
C-SPY® Debugging Guide
366
for MSP430
AFE1_AFE2-1:1
--eem
Specifies the level of Enhanced Emulation Mode.
--erase_exclude
Excludes a memory segment from erase.
--erase_ip_protected
Erases main and Information flash memories, including
the IP protected area before download.
The C-SPY command line utility—cspybat
--erase_main
Erases main flash memory before download.
--erase_main_and_info Erases the main and Information flash memories before
download.
--erase_retain_file
Retains unchanged memory during download.
--erase_retain_target Retains unchanged memory during download.
--hardware_multiplier Generates code for the hardware multiplier peripheral
unit.
--hwmult_type
Specifies the type of hardware multiplier to be used.
--jtag_speed
Specifies the JTAG communication speed.
--lptx
Specifies the parallel port to be used.
--port
Specifies the serial port to be used.
--protocol
Specifies the debug protocol to be used.
--set_exit_breakpoint Sets a system breakpoint on exit.
--set_getchar_breakpo Sets a system breakpoint on getchar.
int
--set_putchar_breakpo Sets a system breakpoint on putchar.
int
--settlingtime
Specifies the delay after setting the voltage.
--use_emulated_breakp Allows C-SPY to use emulated breakpoints.
oints
--use_virtual_breakpo Allows C-SPY to use virtual breakpoints.
ints
--vccvoltage
Specifies the voltage provided by the USB interface.
--verify_all
Verifies the download of your application.
Reference information on C-SPY command line options
This section gives detailed reference information about each cspybat option and each
option available to the C-SPY drivers.
367
AFE1_AFE2-1:1
Reference information on C-SPY command line options
--allow_access_to_BSL
Syntax
--allow_access_to_BSL
For use with
The C-SPY FET Debugger driver.
Description
Use this option to enable erase/write access to BSL flash memory.
Project>Options>Debugger>FET Debugger>Download>Allow erase/write access
to BSL flash memory
--allow_locked_flash_access
Syntax
--allow_locked_flash_access
For use with
The C-SPY FET Debugger driver.
Description
Use this option to enable erase/write access to locked flash memory.
Project>Options>Debugger>FET Debugger>Download>Allow erase/write access
to locked flash memory
--attach_to_running_target
Syntax
--attach_to_running_target
For use with
cspybat.
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
C-SPY® Debugging Guide
368
for MSP430
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
--backend
Syntax
--backend {driver options}
Parameters
driver options
Any option available to the C-SPY driver you are using.
For use with
cspybat (mandatory).
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.
--connection
Syntax
--connection Port
Parameters
Port
The communication channel to be used; choose between: ti_usb, ti_lpt,
jlink, olimex, olimex_parallel, elprotonic, softbaugh_lpt,
softbaugh_usb, and softbaugh_usb_pro.
For use with
The C-SPY FET Debugger driver.
Description
Use this option to specify the communication channel to be used between C-SPY and
the target system.
Project>Options>Debugger>FET Debugger>Setup>Connection
--core
Syntax
--core {430X|430Xv2}
Parameters
430X|430Xv2
The core you are using. This option reflects the corresponding compiler option.
For use with
All C-SPY drivers.
Description
Use this option to specify the core you are using.
369
AFE1_AFE2-1:1
Reference information on C-SPY command line options
See also
The IAR C/C++ Compiler User Guide for MSP430 for information about the cores.
Project>Options>General Options>Target>Device
--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.
For use with
cspybat
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 231, --cycles, page 370, --timeout, page 384.
To set this option, choose View>Code Coverage, right-click and choose Save As when
the C-SPY debugger is running.
--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.
For use with
cspybat
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.
C-SPY® Debugging Guide
370
for MSP430
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
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.
-d
Syntax
-d {sim|fet}
Parameters
sim
Specifies the simulator driver.
fet
Specifies the FET debugger driver.
For use with
All C-SPY drivers.
Description
Use this option to specify the C-SPY driver to be used.
Project>Options>Debugger>Setup>Driver
--debugfile
Syntax
--debugfile filename
Parameters
filename
The name of the debug file to use.
For use with
cspybat
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 debugfile instead of the one used in
the generated cpsybat.bat file.
This option is not available in the IDE.
371
AFE1_AFE2-1:1
Reference information on C-SPY command line options
--derivative
Syntax
--derivative device
Parameters
device
Specifies the device to be used.
For use with
The C-SPY FET Debugger driver.
Description
Use this option to select the device for which you will build your application.
Project>Options>General Options>Target>Device
--disable_interrupts
Syntax
--disable_interrupts
For use with
The C-SPY Simulator driver.
Description
Use this option to disable the interrupt simulation.
To set this option, choose Simulator>Interrupt Setup and deselect the Enable
interrupt simulation option.
--disable_memory_cache
Syntax
--disable_memory_cache
For use with
The C-SPY FET Debugger driver.
Description
Use this option to disable the memory cache in the FET debugger.
Project>Options>Debugger>FET Debugger>Setup>Disable memory cache
--downloadonly
Syntax
--downloadonly
Note that this option must be placed before the --backend option on the command line.
C-SPY® Debugging Guide
372
for MSP430
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
For use with
cspybat
Description
Use this option to download the code image without starting a debug session afterwards.
Project>Download>Download active application
--eem
Syntax
--eem {level}
Parameters
level
Implementation level of Enhanced Emulation Module. Choose
between:
EMEX_LOW
EMEX_MEDIUM
EMEX_HIGH
EMEX_EXTRA_SMALL_5XX
EMEX_SMALL_5XX
EMEX_MEDIUM_5XX
EMEX_LARGE_5XX
EMEX_NONE
For use with
The C-SPY FET Debugger driver.
Description
Use this option to specify the implementation level of Enhanced Emulation Module for
a MSP430 device. The default value is EMEX_NONE. The value of this option depends on
the device you are using.
This option is automatically set when you are using the IDE.
373
AFE1_AFE2-1:1
Reference information on C-SPY command line options
--erase_exclude
Syntax
--erase_exclude range
Parameters
range
The memory range of the segment, in the form
startaddress-endaddress.
For use with
The C-SPY FET Debugger driver.
Description
Use this option to exclude a memory segment from erase. The segments that overlap
with the specified area will not be erased.
Example
--erase_exclude 0x2180-0x2220
To set this option, use Project>Options>Debugger>Extra Options.
--erase_ip_protected
Syntax
--erase_ip_protected
For use with
The C-SPY FET Debugger driver.
Description
Use this option to erase the main and Information flash memories, including the IP
protected area before download.
Project>Options>Debugger>FET Debugger>Download>Erase main and
Information memory inc. IP PROTECTED area
--erase_main
Syntax
--erase_main
For use with
The C-SPY FET Debugger driver.
Description
Use this option to erase the main flash memory before download. The Information
memory is not erased.
Project>Options>Debugger>FET Debugger>Download>Erase main memory
C-SPY® Debugging Guide
374
for MSP430
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
--erase_main_and_info
Syntax
--erase_main_and_info
For use with
The C-SPY FET Debugger driver.
Description
Use this option to erase both flash memories—main and Information memory—before
download.
Project>Options>Debugger>FET Debugger>Download>Erase main and
Information memory
--erase_retain_file
Syntax
--erase_retain_file
For use with
The C-SPY FET Debugger driver.
Description
Use this option to make C-SPY read the main and Information memories into a buffer.
Only the flash segments that are needed are erased. If data that is to be written into a
segment matches the data in the image that is cached on the host computer, the data in
the image is left as is, and no download is performed. The new data effectively replaces
the old data, and unchanged old data is retained.
Project>Options>Debugger>FET Debugger>Download>Retain unchanged
memory>Compare with image cached on PC
--erase_retain_target
Syntax
--erase_retain_target
For use with
The C-SPY FET Debugger driver.
Description
Use this option to make C-SPY read the main and Information memories into a buffer.
Only the flash segments that are needed are erased. If data that is to be written into a
segment matches the data on the target, the data on the target is left as is, and no
download is performed. The new data effectively replaces the old data, and unchanged
old data is retained.
Project>Options>Debugger>FET Debugger>Download>Retain unchanged
memory>Compare with image on target
375
AFE1_AFE2-1:1
Reference information on C-SPY command line options
-f
Syntax
-f filename
Parameters
filename
A text file that contains the command line options (default filename extension
xcl).
For use with
cspybat
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.
For use with
The C-SPY simulator driver.
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 221.
C-SPY driver>Function Profiling
C-SPY® Debugging Guide
376
for MSP430
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
--hardware_multiplier
Syntax
--hardware_multiplier {16|32}
Parameters
16
The size of the multiplicands in bits.
Note that this parameter can only be used in combination with the
--hwmult_type parameters 1 and 2.
32
The size of the multiplicands in bits.
Note that this parameter can only be used in combination with the
--hwmult_type parameters 4 and 8.
For use with
The C-SPY FET Debugger driver.
Description
Use this option to generate code for the MSP430 hardware multiplier peripheral unit.
Use this option only when you have chosen a device with a hardware multiplier.
Note: This option requires that you also specify the --hwmult_type option.
To set related options, choose:
Project>Options>General Options>Target>Hardware multiplier
--hwmult_type
Syntax
--hwmult_type {1|2|4|8}
Parameters
1
16 bits
Note that this parameter can only be combined with the
--hardware_multiplier parameter 16.
2
16 bits, the 2xx Family
Note that this parameter can only be combined with the
--hardware_multiplier parameter 16.
4
32 bits
Note that this parameter can only be combined with the
--harware_multiplier parameter 32.
377
AFE1_AFE2-1:1
Reference information on C-SPY command line options
8
32 bits, the 5xx Families
Note that this parameter can only be combined with the
--hardware_multiplier parameter 32.
For use with
The C-SPY FET Debugger driver.
Description
Use this option to generate code for the MSP430 hardware multiplier peripheral unit.
Use this option only when you have chosen a device with a hardware multiplier.
Note: This option requires that you also specify the --hardware_multiplier option.
To set related options, choose:
Project>Options>General Options>Target>Hardware multiplier
--jtag_speed
Syntax
--jtag_speed{fast|medium|slow}
Parameters
fast
The fast communication speed.
medium
The medium communication speed.
slow
The slow communication speed.
For use with
The C-SPY FET Debugger driver.
Description
Use this option to set the JTAG communication speed.
Project>Options>Debugger>Fet Debugger>Setup>Jtag speed
--leave_target_running
Syntax
--leave_target_running
For use with
cspybat.
The C-SPY FET Debugger driver.
Note: Even if this option is supported by the C-SPY driver you are using, there might
be device-specific limitations.
C-SPY® Debugging Guide
378
for MSP430
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
Description
Use this option to make the debugger leave the application running on the target
hardware after the debug session is closed.
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
--lptx
Syntax
--lptx
For use with
The C-SPY FET Debugger driver.
Description
Use this option to specify which parallel port the FET Debugger is connected to. x can
be 1, 2, or 3.
Project>Options>Debugger>FET Debugger>Setup>Parallel port
--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).
For use with
cspybat
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.
See also
Briefly about using C-SPY macros, page 306.
Project>Options>Debugger>Setup>Setup macros>Use macro file
379
AFE1_AFE2-1:1
Reference information on C-SPY command line options
--macro_param
Syntax
--macro_param [param=value]
Note that this option must be placed before the --backend option on the command line.
Parameters
param = value
param is a parameter defined using the __param C-SPY macro construction.
value is a value.
For use with
cspybat
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.
See also
Macro parameters, page 313.
Project>Options>Debugger>Extra Options
--mapu
Syntax
--mapu
For use with
The C-SPY simulator driver.
Description
Specify this option to use the segment information in the debug file for memory access
checking. During the execution, the simulator will then check for accesses to
unspecified memory ranges. If any such access is found, the C function call stack and a
message will be printed on stderr and the execution will stop.
See also
Monitoring memory and registers, page 140.
To set related options, choose:
Simulator>Memory Access Setup
--odd_word_check
Syntax
--odd_word_check
For use with
The C-SPY simulator driver.
C-SPY® Debugging Guide
380
for MSP430
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
Description
Use this option to make the simulator issue a warning if there is a word access to an odd
address.
Project>Options>Debugger>Simulator>Setup>Check for word access on odd
address
-p
Syntax
-p filename
Parameters
filename
The device description file to be used.
For use with
All C-SPY drivers.
Description
Use this option to specify the device description file to be used.
See also
Selecting a device description file, page 44.
Project>Options>Debugger>Setup>Device description file
--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).
For use with
cspybat
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
430bat.dll located in the 430\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
381
AFE1_AFE2-1:1
Reference information on C-SPY command line options
plugin modules located in the common\plugin directory cannot normally be used with
cspybat.
Project>Options>Debugger>Plugins
--port
Syntax
--port port
Parameters
port
The serial port to be used, can be COMx or Automatic. x is
the number of the COM port.
For use with
The C-SPY FET Debugger driver.
Description
Use this option to specify which serial port the FET Debugger is connected to.
Project>Options>Debugger>FET Debugger>Setup>Connection
--protocol
Syntax
--protocol {spy-bi-wire|spy-bi-wire-jtag|4wire}
Parameters
spy-bi-wire
The Spy-Bi-Wire JTAG protocol.
spy-bi-wire-jtag
4-wire JTAG protocol for devices that also support
Spy-Bi-Wire.
4wire
The ordinary 4-wire JTAG protocol.
For use with
The C-SPY FET Debugger driver.
Description
Use this option to specify the debug protocol. Spy-Bi-Wire works for the parallel port
FET module and the TI USB FET module.
Project>Options>Debugger>FET Debugger>Setup>Debug protocol
C-SPY® Debugging Guide
382
for MSP430
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
--set_exit_breakpoint
Syntax
--set_exit_breakpoint
For use with
The C-SPY FET Debugger driver.
Description
Use this option to set a system breakpoint for exit.
Project>Options>Debugger>FET Debugger>Breakpoints>System breakpoints
on>exit
--set_getchar_breakpoint
Syntax
--set_getchar_breakpoint
For use with
The C-SPY FET Debugger driver.
Description
Use this option to set a system breakpoint for getchar.
Project>Options>Debugger>FET Debugger>Breakpoints>System breakpoints
on>getchar
--set_putchar_breakpoint
Syntax
--set_putchar_breakpoint
For use with
The C-SPY FET Debugger driver.
Description
Use this option to set a system breakpoint for putchar.
Project>Options>Debugger>FET Debugger>Breakpoints>System breakpoints
on>putchar
--settlingtime
Syntax
--settlingtime=milliseconds
For use with
The C-SPY FET Debugger driver.
Description
Use this option to specify the delay between switching on the target VCC and starting
the identification of the MSP430 device. Give the value in milliseconds in the range
0-9999 ms. This option can only be used with a USB connection.
383
AFE1_AFE2-1:1
Reference information on C-SPY command line options
Project>Options>Debugger>FET Debugger>Setup>Target VCC>Settling time (in
ms)
--silent
Syntax
--silent
Note that this option must be placed before the --backend option on the command line.
For use with
cspybat
Description
Use this option to omit the sign-on message.
This option is not available in the IDE.
--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.
For use with
cspybat
Description
Use this option to limit the maximum allowed execution time.
This option is not available in the IDE.
--use_emulated_breakpoints
Syntax
--use_emulated_breakpoints
For use with
The C-SPY FET Debugger driver.
Description
Use this option to allow C-SPY to use emulated breakpoints.
Project>Options>Debugger>FET Debugger>Breakpoints>Use software
breakpoints>Emulated breakpoints
C-SPY® Debugging Guide
384
for MSP430
AFE1_AFE2-1:1
The C-SPY command line utility—cspybat
--use_virtual_breakpoints
Syntax
--use_virtual_breakpoints
For use with
The C-SPY FET Debugger driver.
Description
Use this option to allow C-SPY to use virtual breakpoints.
Project>Options>Debugger>FET Debugger>Breakpoints>Use software
breakpoints>Virtual breakpoints
--vccvoltage
Syntax
--vccvoltage=volts
For use with
The C-SPY FET Debugger driver.
Description
Use this option to specify the voltage provided by the USB interface. Give the value in
Volts with one decimal’s precision in the range 1.0-4.0 V. This option can only be used
with a USB connection.
Project>Options>Debugger>FET Debugger>Setup>Target VCC>Target VCC (in
Volt)
--verify_all
Syntax
--verify_all
For use with
The C-SPY FET Debugger driver.
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>FET Debugger>Download>Verify download
385
AFE1_AFE2-1:1
Reference information on C-SPY command line options
C-SPY® Debugging Guide
386
for MSP430
AFE1_AFE2-1:1
Part 4. Additional
reference information
This part of the C-SPY® Debugging Guide for MSP430 includes these chapters:
●
Debugger options
●
Additional information on C-SPY drivers
387
388
Debugger options
●
Setting debugger options
●
Reference information on general debugger options
●
Reference information on the C-SPY simulator
●
Reference information on C-SPY hardware debugger driver options
Setting debugger options
Before you start the C-SPY debugger you might need to set some options—both C-SPY
generic options and options required for the target system (C-SPY driver-specific
options).
To set debugger options in the IDE:
1 Choose Project>Options to display the Options dialog box.
2 Select Debugger in the Category list.
For more information about the generic options, see Reference information on general
debugger options, page 390.
3 On the Setup page, make sure to select the appropriate C-SPY driver from the Driver
drop-down list.
4 To set the driver-specific options, select the appropriate driver from the Category list.
Depending on which C-SPY driver you are using, different options are available.
C-SPY driver
Available options pages
C-SPY FET Debugger driver
Setup for FET Debugger, page 395
Download, page 397
Breakpoints, page 398
C-SPY Simulator
Setup options for the simulator, page 394
Table 42: Options specific to the C-SPY drivers you are using
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.
389
AFE1_AFE2-1:1
Reference information on general debugger options
Reference information on general debugger options
Reference information about:
●
Setup
●
Images
●
Extra Options
●
Plugins
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 44.
C-SPY® Debugging Guide
390
for MSP430
AFE1_AFE2-1:1
Debugger options
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.
Device description file
A default device description file is selected automatically based on your project settings.
To override the default file, select Override default and specify an alternative file. A
browse button is available for your convenience.
For information about the device description file, see Modifying a device description
file, page 48.
Device description files for each MSP430 device are provided in the directory
430\config and have the filename extension ddf.
Images
The Images options control the use of additional debug files to be downloaded.
Download extra Images
Controls the use of additional debug files to be downloaded:
Path
Specify the debug file to be downloaded. A browse button is available for your
convenience.
Offset
Specify an integer that determines the destination address for the downloaded
debug file.
391
AFE1_AFE2-1:1
Reference information on general debugger options
Debug info only
Makes the debugger download only debug information, and not the complete
debug file.
If you want to download more than three images, use the related C-SPY macro, see
__loadImage, page 329.
For more information, see Loading multiple images, page 47.
Plugins
The Plugins options select the C-SPY plugin modules to be loaded and made available
during debug sessions.
Select plugins to load
Selects the plugin modules to be loaded and made available during debug sessions. The
list contains the plugin modules delivered with the product installation.
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 430\plugins directory.
Originator
Informs about the originator of the plugin module, which can be modules provided by
IAR Systems or by third-party vendors.
C-SPY® Debugging Guide
392
for MSP430
AFE1_AFE2-1:1
Debugger options
Version
Informs about the version number.
Extra Options
The Extra Options page provides you with a command line interface to C-SPY.
Use command line options
Specify command line arguments that are not supported by the IDE to be passed to
C-SPY.
Note that it is possible to use the /args option to pass command line arguments to the
debugged application.
Syntax: /args arg0 arg1 ...
Multiple lines with /args are allowed, for example:
/args --logfile log.txt
/args --verbose
393
AFE1_AFE2-1:1
Reference information on the C-SPY simulator
If you use /args, these variables must be defined in your application:
/* __argc, the number of arguments in __argv. */
__no_init int __argc;
/* __argv, an array of pointers to strings that holds the
arguments; must be large enough to fit the number of
parameters.*/
__no_init const char * __argv[MAX_ARGS];
/* __argvbuf, a storage area for __argv; must be large enough to
hold all command line parameters. */
__no_init __root char __argvbuf[MAX_ARG_SIZE];
Reference information on the C-SPY simulator
Reference information about:
●
Setup options for the simulator
This section gives reference information on the C-SPY simulator options.
Setup options for the simulator
The simulator Setup options control the C-SPY simulator.
Check for word access on odd address
Makes the simulator issue a warning if there is a word access to an odd address.
C-SPY® Debugging Guide
394
for MSP430
AFE1_AFE2-1:1
Debugger options
Reference information on C-SPY hardware debugger driver options
Reference information about:
●
Setup for FET Debugger, page 395
●
Download, page 397
●
Breakpoints, page 398
Setup for FET Debugger
The FET Debugger Setup options control the C-SPY FET Debugger driver.
Connection
Controls the communication between C-SPY and the target device.
The C-SPY FET Debugger can communicate with the target device via a number of
different emulators. Select the emulator you are using.
If your emulator is connected to the host computer via a parallel port, you must also
specify which parallel port to use: Parallel port 1, Parallel port 2, or Parallel port 3. If
your emulator is connected to the host computer via a USB port, the debugger will
automatically connect to the correct port.
Some emulator drivers support multiple emulators connected to the same host computer.
Each emulator requires its own instance of IAR Embedded Workbench and each
instance must identify its emulator. To identify an emulator, click the browse button to
display a list of all detected emulators. To identify a connection, click the port in the list
and the Mode LED on the attached emulator will light up.
395
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
Debug protocol
Determines the debug interface to use:
Automatic selection
Selects the debug interface automatically. (If Connection is set to Automatic,
C-SPY correctly determines which interface to use.)
Manual selection
Spy-Bi-Wire to select the 2-wire JTAG (Spy-Bi-Wire) interface. Works with
emulators from Elprotronic, Olimex, and Texas Instruments that connect via
USB.
Disable memory cache
Disables the memory cache in the FET debugger.
Jtag speed
Sets the JTAG communication speed. Choose between Fast, Medium, and Slow.
Target VCC
Specify the voltage provided by the USB interface:
Override default
Overrides the default voltage. To see what the default voltage is, see Device
Information window, page 56.
Target VCC
Specify the voltage with one decimal’s precision in the range 1.0–4.0 V. This
option can only be used with a USB connection.
Settling time
Specify a delay that will be used between switching on the target VCC and
starting the identification of the MSP430 device.
Enable ULP/LPMx.5 debug
Enables debugging of applications that use the LPMx5 low-power mode.
C-SPY® Debugging Guide
396
for MSP430
AFE1_AFE2-1:1
Debugger options
Download
By default, C-SPY downloads the application to RAM or flash when a debug session
starts. The Download options let you modify the behavior of the download.
Verify download
Verifies that the downloaded code image can be read back from target memory with the
correct contents.
Allow erase/write access to locked flash memory
Enables erase/write access to Info Segment A. This option can only be used with devices
that have the Info Segment A memory.
Allow erase/write access to BSL flash memory
Enables erase/write access to BSL flash memory. This option can only be used with
MSP430F5xx devices that have BSL flash memory.
External code download
Saves user code to external SPI memory.
Erase main memory
Erases only the main flash memory before download. The Information memory is not
erased.
Erase main and Information memory
Erases both flash memories—main and Information memory—before download.
397
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
Retain unchanged memory
Reads the main and Information memories into a buffer. Only the flash segments that
are needed are erased.
Compare with image on target
Compares the data that is to be written into a segment with the image on the
target. If the data matches the image, the data on the target is left as is, and
nothing is downloaded. The new data effectively replaces the old data, and
unchanged old data is retained.
Compare with image cached on PC
Compares the data that is to be written into a segment with the image that is
cached on the host computer.
Erase main and Information memory inc. IP PROTECTED area
Erases the main and Information flash memories, including the IP protected area before
download.
JTAG password
If a JTAG device is password-protected, supply the needed password here.
Breakpoints
The Breakpoints options control the use of breakpoints.
C-SPY® Debugging Guide
398
for MSP430
AFE1_AFE2-1:1
Debugger options
Use software breakpoints
Allows C-SPY to use software breakpoints when all available hardware breakpoints
have been used. Choose between:
Emulated breakpoints
Makes C-SPY use emulated breakpoints: the instruction where the breakpoint is
set will be replaced by a special instruction that the debugger recognizes.
Use only emulated breakpoints
C-SPY will use only emulated breakpoints.
Virtual breakpoints
Makes C-SPY use virtual breakpoints.
For information, see Breakpoints in the C-SPY FET debugger driver, page 106.
System breakpoints on
Controls the use of system breakpoints in the CLIB runtime environment. If the C-SPY
Terminal I/O window is not required 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, if you want, or do not want,
C-SPY to use system breakpoints for these. For more information, see Breakpoint
consumers, page 107.
In the DLIB runtime environment, C-SPY will always set a system breakpoint on the
__DebugBreak label. You cannot disable this behavior.
399
AFE1_AFE2-1:1
Reference information on C-SPY hardware debugger driver options
C-SPY® Debugging Guide
400
for MSP430
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.
Reference information on C-SPY driver menus
This section gives reference information on the menus specific to the C-SPY drivers.
More specifically, this means:
●
Simulator menu, page 402
●
Emulator menu, page 404.
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.
401
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:
Memory Access Setup
Displays a dialog box to simulate memory access checking by specifying
memory areas with different access types, see Memory Access Setup dialog box,
page 169.
Trace
Opens a window which displays the collected trace data, see Trace window,
page 180.
Function Trace
Opens a window which displays the trace data for function calls and function
returns, see Function Trace window, page 184.
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 187.
Function Profiler
Opens a window which shows timing information for the functions, see
Function Profiler window, page 226.
C-SPY® Debugging Guide
402
for MSP430
AFE1_AFE2-1:1
Additional information on C-SPY drivers
Data Log
Opens a window which logs accesses to up to four different memory locations
or areas, see Data Log window, page 205.
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 208.
Interrupt Log
Opens a window which displays the status of all defined interrupts, see Interrupt
Log window, page 275.
Interrupt Log Summary
Opens a window which displays a summary of the status of all defined
interrupts, see Interrupt Log Summary window, page 277.
Timeline
Opens a window which gives a graphical view of various kinds of information
on a timeline, see The application timeline, page 191.
Simulated Frequency
Opens the Simulated Frequency dialog box where you can specify the
simulator frequency used when the simulator displays time information, for
example in the log windows. Note that this does not affect the speed of the
simulator. For more information, see Simulated Frequency dialog box, page
408.
Interrupt Setup
Displays a dialog box where you can configure C-SPY interrupt simulation, see
Interrupt Setup dialog box, page 269.
Forced Interrupts
Opens a window from where you can instantly trigger an interrupt, see Forced
Interrupt window, page 272.
Interrupt Status
Opens a window from where you can instantly trigger an interrupt, see Interrupt
Status window, page 273.
Breakpoint Usage
Displays a window which lists all active breakpoints, see Breakpoint Usage
window, page 117.
403
AFE1_AFE2-1:1
Reference information on C-SPY driver menus
Emulator menu
When you are using the C-SPY FET Debugger driver, the Emulator menu is added to
the menu bar.
These commands are available on the menu:
Menu commands
These commands are available on the menu:
Power Log Setup
Opens a window; see Power Log Setup window, page 246.
Power Log
Opens a window; see Power Log window, page 248.
C-SPY® Debugging Guide
404
for MSP430
AFE1_AFE2-1:1
Additional information on C-SPY drivers
State Log
Opens a window; see State Log window, page 252.
State Log Summary
Opens a window; see State Log Summary window, page 254.
Timeline
Opens a window; see Reference information on application timeline, page 197.
Data Sample Setup
Opens a window; see Data Sample Setup window, page 215.
Data Sample
Opens a window; see Data Sample window, page 216.
Sampled Graphs
Opens a window; see Sampled Graphs window, page 211.
Function Profiler
Opens a window which shoes timing information for the functions; see Function
Profiler window, page 226.
Release JTAG on Go
Sets the JTAG drivers in tri-state so that the device is released from JTAG
control—TEST pin is set to GND—when Go is activated.
Leave Target Running
Leaves the application running on the target hardware after the debug session is
closed.
Any existing breakpoints will not be automatically removed. You might want to
consider disabling all breakpoints before using this menu command.
If this menu command is not available, it is not supported by the C-SPY driver
you are using.
GIE on/off
Clears the General Interrupt Enable bit (GIE) in the Processor Status register.
Force Single Stepping
Forces single step debugging.
Force hardware RST/NMI
Forces an RST/NMI clear reset when the Reset button is pressed.
Resynchronize JTAG
Regains control of the device.
405
AFE1_AFE2-1:1
Reference information on C-SPY driver menus
It is not possible to resynchronize JTAG while the device is operating.
Init New Device
Initializes the device according to the settings in the Projects>Options>FET
Debugger category. The current program file is downloaded to the device
memory, and the device is then reset. This command can be used to program
multiple devices with the same program from within the same C-SPY session.
It is not possible to choose Init New Device while the device is operating, thus
the command will be dimmed.
State Storage Control
Opens the State Storage Control window, which lets you define the use of the
state storage module; see State Storage Control window, page 294.
State Storage Window
Opens the State Storage window which contains state storage information
according to your definitions; see State Storage window, page 296.
Sequencer Control
Opens the Sequencer Control window, which lets you define a state machine;
see Sequencer Control window, page 303.
Advanced Cycle Counter
Opens a window; see Advanced Cycle Counter Control window, page 287.
Advanced>Clock Control
Lets you control the clocks on the device. Depending on the hardware support,
either the General Clock Control dialog box or the Extended Clock Control
dialog box is displayed; see General Clock Control dialog box, page 408 and
Extended Clock Control dialog box, page 409, respectively.
Advanced>Emulation Mode
Specifies the device to be emulated. The device must be reset (or reinitialized by
using the menu command Init New Device) following a change to the emulation
mode.
Advanced>Memory Dump
Displays the Memory Dump dialog box, which lets you write device memory
contents to a file; see Memory Dump dialog box, page 172.
Advanced>Breakpoint Combiner
Displays the Breakpoint combiner dialog box, which lets you combine two
already defined breakpoints; see Breakpoint combiner dialog box, page 133.
C-SPY® Debugging Guide
406
for MSP430
AFE1_AFE2-1:1
Additional information on C-SPY drivers
User code erase (unlocks device)
Overrides and clears FRAM memory protection and erases the Information and
main memories. (Only available for FR2xx and FR4xx devices.)
Secure - Blow JTAG Fuse
Blows the fuse on the target device. After the fuse is blown, no communication
with the device is possible.
Only available if you are using a USB-connected debug probe.
Breakpoint Usage
Opens a window which lists all active breakpoints; see Breakpoint Usage
window, page 117.
Device information
Opens the Device Information window with information about the device used
for debugging, see Device Information window, page 56.
Connected device
The name of the device used for debugging.
Note: Not all Emulator>Advanced submenu commands are available on all MSP430
devices.
Reference information on the C-SPY simulator
This section gives additional reference information the C-SPY simulator, reference
information not provided elsewhere in this documentation.
Reference information about:
●
Simulated Frequency dialog box, page 408
407
AFE1_AFE2-1:1
Reference information on the C-SPY FET Debugger driver
Simulated Frequency dialog box
The Simulated Frequency dialog box is available from the C-SPY driver menu.
Use this dialog box to specify the simulator frequency used when the simulator displays
time information.
Requirements
The C-SPY simulator.
Frequency
Specify the frequency in Hz.
Reference information on the C-SPY FET Debugger driver
This section gives additional reference information on the C-SPY hardware debugger
drivers, reference information not provided elsewhere in this documentation.
More specifically, this means:
●
General Clock Control dialog box, page 408
●
Extended Clock Control dialog box, page 409
General Clock Control dialog box
The General Clock Control dialog box is available from the Emulator menu.
Use this dialog box to control the clocks of the device.
C-SPY® Debugging Guide
408
for MSP430
AFE1_AFE2-1:1
Additional information on C-SPY drivers
Select the clock modules you want to stop when the execution stops. The other clocks
will keep running.
Which clock modules that are displayed depends on the available clocks on the
connected device.
Requirements
The C-SPY FET Debugger driver.
Extended Clock Control dialog box
The Extended Clock Control dialog box is available from the Emulator menu.
Use this dialog box for module level control over the clocks of the device.
Select the clock modules you want to stop when the execution stops. The other clocks
will keep running.
Which clock modules that are displayed depends on the available clocks on the
connected device.
Requirements
The C-SPY FET Debugger driver.
Resolving problems
These topics are covered:
●
The device port pins do not work
●
Write failure during load
●
No contact with the target hardware
409
AFE1_AFE2-1:1
Resolving problems
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.
To troubleshoot the Flash Emulation Tool, see appendix A in the document IAR
Embedded Workbench Version 3+ for MSP430 User’s Guide at the Texas Instruments
web site, www.ti.com. The document has the literature number SLAU138AN.
THE DEVICE PORT PINS DO NOT WORK
On some MSP430 devices, the device port pins are shared with the JTAG pins that
C-SPY uses to debug the device. Normally, C-SPY maintains the pins in JTAG mode so
that the device can be debugged. During this time the port functionality of the shared
pins is not available.
To release the JTAG pins:
Choose Emulator>Release JTAG on Go to set the JTAG drivers to tri-state and release
the device from JTAG control (the TEST pin is set to GND) when Go is activated. Any
active on-chip breakpoints are retained and the shared JTAG port pins revert to their port
functions.
Note: Be aware of the following:
●
The JTAG pins will only be released if there are N or fewer active breakpoints.
●
When you measure the electrical current of the device, the JTAG control signals
must be released, otherwise the device will be powered by the signals on the JTAG
pins and the measurements will be incorrect.
●
If you release the JTAG pins, C-SPY has no access to the device and cannot
determine if an active breakpoint has been triggered. C-SPY must be manually told
to stop the device, at which time the state of the device will be determined (that is,
has a breakpoint been reached?).
WRITE FAILURE DURING LOAD
There are several possible reasons for write failure during load. The most common is
that your application has been incorrectly linked:
●
C-SPY® Debugging Guide
410
for MSP430
AFE1_AFE2-1:1
Check the contents of your linker configuration file and make sure that your
application has not been linked to the wrong address
Additional information on C-SPY drivers
●
Check that you are using the correct linker configuration file.
To choose a device:
1 Choose Project>Options.
2 Select the General Options category.
3 Click the Target tab.
4 Choose the appropriate device from the Device drop-down list.
To override the default linker configuration file:
1 Choose Project>Options.
2 Select the Linker category.
3 Click the Config tab.
4 Choose the appropriate linker configuration file in the Linker configuration file area.
NO CONTACT WITH THE TARGET HARDWARE
There are several possible reasons for C-SPY to fail to establish contact with the target
hardware. Do this:
●
Check the communication devices on your host computer
●
Verify that the cable is properly plugged in and not damaged or of the wrong type
●
Make sure that the evaluation board is supplied with sufficient power
●
Check that the correct options for communication have been specified in the IAR
Embedded Workbench IDE.
Examine the linker configuration file to make sure that the application has not been
linked to the wrong address.
411
AFE1_AFE2-1:1
Resolving problems
C-SPY® Debugging Guide
412
for MSP430
AFE1_AFE2-1:1
Index
Index
A
Abort (Report Assert option) . . . . . . . . . . . . . . . . . . . . . . . 78
__abortLaunch (C-SPY system macro) . . . . . . . . . . . . . . . 321
absolute location, specifying for a breakpoint . . . . . . . . . . 133
Access type (Advanced Trigger breakpoints option) . . . . 131
Access type (Edit Memory Access option) . . . . . . . . . . . . 171
Access (Conditional breakpoints option) . . . . . . . . . . . . . 128
Access (Edit SFR option) . . . . . . . . . . . . . . . . . . . . . . . . . 168
Action (Advanced Trigger breakpoints option) . . . . . . . . . 131
Action (Conditional breakpoints option) . . . . . . . . . . . . . . 129
Action (Sequencer option) . . . . . . . . . . . . . . . . . . . . . . . . 303
Add to Watch Window (Symbolic Memory window context
menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Add (SFR Setup window context menu) . . . . . . . . . . . . . . 166
Address Range (Find in Trace option) . . . . . . . . . . . . . . . 190
Address (Edit SFR option) . . . . . . . . . . . . . . . . . . . . . . . . 168
Advanced Cycle Counter Control window . . . . . . . . . . . . 287
Advanced Trigger breakpoints dialog box . . . . . . . . . . . . 130
advanced trigger breakpoints, overview . . . . . . . . . . . . . . 105
Advanced (Sequencer option) . . . . . . . . . . . . . . . . . . . . . . 304
Advanced>Breakpoint Combiner (Emulator menu) . . . . . 406
Advanced>Clock Control (Emulator menu) . . . . . . . . . . . 406
Advanced>Emulation Mode (Emulator menu) . . . . . . . . . 406
Advanced>Memory Dump (Emulator menu) . . . . . . . . . . 406
Allow erase/write access to locked
flash memory (C-SPY FET Debugger option) . . . . . . . . . 397
Allow erase/write access to
BSL flash memory (C-SPY FET Debugger option) . . . . . 397
--allow_access_to_BSL (C-SPY command line option) . . 368
--allow_locked_flash_access
(C-SPY command line option) . . . . . . . . . . . . . . . . . . . . . 368
Ambiguous symbol (Resolve Symbol Ambiguity option) . 101
application flow, monitoring . . . . . . . . . . . . . . . . . . . . . . . 291
Applications (Advanced Cycle Counter option) . . . . . . . . 287
application, built outside the IDE . . . . . . . . . . . . . . . . . . . . 46
assembler labels, viewing . . . . . . . . . . . . . . . . . . . . . . . . . . 84
assembler source code, fine-tuning . . . . . . . . . . . . . . . . . . 221
assembler symbols, using in C-SPY expressions . . . . . . . . 81
assembler variables, viewing . . . . . . . . . . . . . . . . . . . . . . . 84
assumptions, programming experience . . . . . . . . . . . . . . . . 23
Auto Scroll (Sampled Graphs window context menu) . . . 213
Auto Scroll (Timeline window context menu) . 200, 203, 281
Auto window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Autostep settings dialog box . . . . . . . . . . . . . . . . . . . . . . . . 78
Autostep (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
B
--attach_to_running_target (C-SPY command line option)368
--backend (C-SPY command line option) . . . . . . . . . . . . . 369
backtrace information
viewing in Call Stack window . . . . . . . . . . . . . . . . . . . . 71
batch mode, using C-SPY in . . . . . . . . . . . . . . . . . . . . . . . 363
Big Endian (Memory window context menu) . . . . . . . . . . 148
blocks, in C-SPY macros . . . . . . . . . . . . . . . . . . . . . . . . . 315
bold style, in this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Break At (Advanced Trigger breakpoints option) . . . . . . . 130
Break At (Conditional breakpoints option) . . . . . . . . . . . . 127
Break on Throw (Debug menu) . . . . . . . . . . . . . . . . . . . . . 52
Break on Uncaught Exception (Debug menu) . . . . . . . . . . . 52
Break (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Breakpoint combiner dialog box . . . . . . . . . . . . . . . . . . . . 133
breakpoint condition, example . . . . . . . . . . . . . . . . . 112–113
Breakpoint Usage window . . . . . . . . . . . . . . . . . . . . . . . . 117
Breakpoint Usage (Emulator menu) . . . . . . . . . . . . . . . . . 407
breakpoints
advanced trigger. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
code, example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
conditional . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
using . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
connecting a C-SPY macro . . . . . . . . . . . . . . . . . . . . . 310
consumers of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
data log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
description of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
disabling used by Stack window . . . . . . . . . . . . . . . . . 108
emulated, configuring . . . . . . . . . . . . . . . . . . . . . . . . . 399
icons for in the IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
413
UCSARM-4:3
in Memory window . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
listing all . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
reasons for using . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
setting
in memory window . . . . . . . . . . . . . . . . . . . . . . . . . 111
using system macros . . . . . . . . . . . . . . . . . . . . . . . . 111
using the dialog box . . . . . . . . . . . . . . . . . . . . . . . . 109
toggling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
types of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
useful tips. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
virtual, configuring . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
Breakpoints dialog box
Advanced Trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Conditional . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Data Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Immediate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Trace Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Trace Stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Breakpoints window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Breakpoints (FET debugger options) . . . . . . . . . . . . . . . . 398
Browse (Trace toolbar) . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
byte order, setting in Memory window . . . . . . . . . . . . . . . 147
C
C function information, in C-SPY. . . . . . . . . . . . . . . . . . . . 65
C symbols, using in C-SPY expressions . . . . . . . . . . . . . . . 81
C variables, using in C-SPY expressions . . . . . . . . . . . . . . 80
call chain, displaying in C-SPY . . . . . . . . . . . . . . . . . . . . . 65
Call stack information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Call Stack window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
for backtrace information . . . . . . . . . . . . . . . . . . . . . . . . 65
Call Stack (Timeline window context menu) . . . . . . . . . . 200
__cancelAllInterrupts (C-SPY system macro) . . . . . . . . . 322
C-SPY® Debugging Guide
414
for MSP430
UCSARM-4:3
__cancelInterrupt (C-SPY system macro) . . . . . . . . . . . . . 322
Check for word access on odd address
(C-SPY simulator option) . . . . . . . . . . . . . . . . . . . . . . . . . 394
Clear All (Debug Log window context menu) . . . . . . . . . . 76
Clear Group (Registers User Groups
Setup window context menu) . . . . . . . . . . . . . . . . . . . . . . 163
Clear Group (Registers User
Groups Setup window context menu) . . . . . . . . . . . . . . . . 163
Clear trace data (Trace toolbar). . . . . . . . . . . . . . . . . . . . . 181
Clear (Advanced Cycle Counter option) . . . . . . . . . . . . . . 289
Clear (Interrupt Log window context menu) . . . . . . . 253, 256
Clear (Power Log window context menu). . . . . . . . . . . . . 249
__clearBreak (C-SPY system macro) . . . . . . . . . . . . . . . . 323
CLIB
consuming breakpoints . . . . . . . . . . . . . . . . . . . . . . . . 108
library reference information for . . . . . . . . . . . . . . . . . . 27
naming convention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
clock frequency, simulated . . . . . . . . . . . . . . . . . . . . . . . . 408
__closeFile (C-SPY system macro) . . . . . . . . . . . . . . . . . 323
code breakpoints
overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
toggling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Code Coverage window . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Code Coverage (Disassembly window context menu) . . . . 69
--code_coverage_file (C-SPY command line option) . . . . 370
code, covering execution of . . . . . . . . . . . . . . . . . . . . . . . 232
command line options . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
typographic convention . . . . . . . . . . . . . . . . . . . . . . . . . 28
command prompt icon, in this guide . . . . . . . . . . . . . . . . . . 28
computer style, typographic convention . . . . . . . . . . . . . . . 27
Condition (Conditional breakpoints option) . . . . . . . . . . . 129
conditional breakpoints
overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
triggering state storage . . . . . . . . . . . . . . . . . . . . . . . . . 292
Conditional breakpoints dialog box . . . . . . . . . . . . . . . . . 127
conditional statements, in C-SPY macros . . . . . . . . . . . . . 314
--connection (C-SPY command line option) . . . . . . . . . . . 369
Connection (C-SPY FET Debugger option) . . . . . . . . . . . 395
context menu, in windows . . . . . . . . . . . . . . . . . . . . . . . . . 83
conventions, used in this guide . . . . . . . . . . . . . . . . . . . . . . 27
Index
Copy Window Contents (Disassembly
window context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Copy (Debug Log window context menu) . . . . . . . . . . . . . 76
copyright notice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
CPU cycles, counting . . . . . . . . . . . . . . . . . . . . . . . . 284, 286
cspybat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
reading options from file (-f) . . . . . . . . . . . . . . . . . . . . 376
current position, in C-SPY Disassembly window . . . . . . . . 68
Current state (Sequencer option) . . . . . . . . . . . . . . . . . . . . 304
cursor, in C-SPY Disassembly window . . . . . . . . . . . . . . . 68
Cycle counter values (Advanced Cycle Counter option) . . 288
--cycles (C-SPY command line option) . . . . . . . . . . . . . . 370
C-SPY
batch mode, using in . . . . . . . . . . . . . . . . . . . . . . . . . . 363
debugger systems, overview of . . . . . . . . . . . . . . . . . . . 37
environment overview . . . . . . . . . . . . . . . . . . . . . . . . . . 33
plugin modules, loading . . . . . . . . . . . . . . . . . . . . . . . . . 45
setting up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43–44
starting the debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
C-SPY drivers
differences between drivers . . . . . . . . . . . . . . . . . . . . . . 39
overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
specifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
types of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
C-SPY expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
evaluating, using Macro Quicklaunch window . . . . . . 361
evaluating, using Quick Watch window . . . . . . . . . . . . . 97
in C-SPY macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Tooltip watch, using . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Watch window, using. . . . . . . . . . . . . . . . . . . . . . . . . . . 79
C-SPY hardware debugger driver
extending functionality of . . . . . . . . . . . . . . . . . . . . . . . 50
C-SPY macros
blocks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
conditional statements . . . . . . . . . . . . . . . . . . . . . . . . . 314
C-SPY expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
checking status of register . . . . . . . . . . . . . . . . . . . . 309
creating a log macro . . . . . . . . . . . . . . . . . . . . . . . . 310
executing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
connecting to a breakpoint . . . . . . . . . . . . . . . . . . . 310
using Quick Watch . . . . . . . . . . . . . . . . . . . . . . . . . 309
using setup macro and setup file . . . . . . . . . . . . . . . 309
functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 312
keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . 312–313, 315
loop statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
macro statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
setup macro file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
executing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
setup macro functions . . . . . . . . . . . . . . . . . . . . . . . . . 306
summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
system macros, summary of . . . . . . . . . . . . . . . . . . . . . 319
using . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 312
C-SPY options
Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
Download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
Extra Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
Plugins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
Setup (FET) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
C-SPYLink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
C-STAT for static analysis, documentation for . . . . . . . . . . 26
C++ terminology. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
D
-d (C-SPY command line option) . . . . . . . . . . . . . . . . . . . 371
data breakpoints, overview . . . . . . . . . . . . . . . . . . . . . . . . 104
Data Coverage (Memory window context menu) . . . . . . . 148
data coverage, in Memory window . . . . . . . . . . . . . . . . . . 146
data log breakpoints, overview . . . . . . . . . . . . . . . . . . . . . 105
Data Log Summary window . . . . . . . . . . . . . . . . . . . . . . . 208
Data Log Summary (Simulator menu) . . . . . . . . . . . . . . . 403
Data Log window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Data Log (Simulator menu) . . . . . . . . . . . . . . . . . . . . . . . 403
415
UCSARM-4:3
Data Log (Timeline window context menu) . . . . . . . . . . . 204
Data Sample Setup window . . . . . . . . . . . . . . . . . . . . . . . 215
Data Sample window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Data Sample (Sampled Graphs window context menu) . . 213
ddf (filename extension), selecting a file . . . . . . . . . . . . . . 44
Debug Log window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Debug menu (C-SPY main window). . . . . . . . . . . . . . . . . . 51
Debug protocol (C-SPY FET Debugger option) . . . . . . . . 396
Debug (Report Assert option) . . . . . . . . . . . . . . . . . . . . . . . 78
--debugfile (cspybat option) . . . . . . . . . . . . . . . . . . . . . . . 371
debugger concepts, definitions of . . . . . . . . . . . . . . . . . . . . 36
debugger drivers
FET Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
debugger drivers. See C-SPY drivers
Debugger Macros window . . . . . . . . . . . . . . . . . . . . . . . . 359
debugger system overview . . . . . . . . . . . . . . . . . . . . . . . . . 37
debugging projects
externally built applications . . . . . . . . . . . . . . . . . . . . . . 46
loading multiple images . . . . . . . . . . . . . . . . . . . . . . . . . 47
debugging, RTOS awareness . . . . . . . . . . . . . . . . . . . . . . . 35
__delay (C-SPY system macro) . . . . . . . . . . . . . . . . . . . . 323
Delay (Autostep Settings option) . . . . . . . . . . . . . . . . . . . . 78
Delete (Breakpoints window context menu) . . . . . . . . . . . 116
Delete (SFR Setup window context menu) . . . . . . . . . . . . 166
Delete/revert All Custom SFRs (SFR Setup window context
menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
--derivative (C-SPY command line option). . . . . . . . . . . . 372
Description (Edit Interrupt option) . . . . . . . . . . . . . . . . . . 271
description (interrupt property) . . . . . . . . . . . . . . . . . . . . . 271
Device description file (debugger option) . . . . . . . . . . . . . 391
device description files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
memory zones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
modifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
register zone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
specifying interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . 334
Device Information window . . . . . . . . . . . . . . . . . . . . . . . . 56
Device information (Emulator menu) . . . . . . . . . . . . . . . . 407
Device Support Module . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
C-SPY® Debugging Guide
416
for MSP430
UCSARM-4:3
Disable All (Breakpoints window context menu) . . . . . . . 116
Disable memory cache (C-SPY FET Debugger option) . . 396
Disable (Breakpoints window context menu) . . . . . . . . . . 116
__disableInterrupts (C-SPY system macro) . . . . . . . . . . . 324
--disable_interrupts (C-SPY command line option) . . . . . 372
--disable_memory_cache (C-SPY command line option) . 372
Disassembly window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
context menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
disclaimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
DLIB
consuming breakpoints . . . . . . . . . . . . . . . . . . . . . . . . 108
naming convention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
DMA load, measuring. . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
do (macro statement) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
document conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
documentation
overview of guides . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
overview of this guide . . . . . . . . . . . . . . . . . . . . . . . . . . 24
this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Download (FET debugger options) . . . . . . . . . . . . . . . . . . 397
--download_only (C-SPY command line option) . . . . . . . 372
Driver (debugger option) . . . . . . . . . . . . . . . . . . . . . . . . . 390
__driverType (C-SPY system macro) . . . . . . . . . . . . . . . . 324
E
Edit Expressions (Trace toolbar) . . . . . . . . . . . . . . . . . . . . 181
Edit Interrupt dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Edit Memory Access dialog box . . . . . . . . . . . . . . . . . . . . 171
Edit Memory Range dialog box . . . . . . . . . . . . . . . . . . . . 167
Edit Settings (Trace toolbar) . . . . . . . . . . . . . . . . . . . . . . . 181
Edit (Breakpoints window context menu) . . . . . . . . . . . . . 116
Edit (SFR Setup window context menu) . . . . . . . . . . . . . . 166
edition, of this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
--eem (C-SPY command line option) . . . . . . . . . . . . . . . . 373
emulated breakpoints, configuring . . . . . . . . . . . . . . . . . . 399
Emulator menu (reference information) . . . . . . . . . . . . . . 404
Enable All (Breakpoints window context menu). . . . . . . . 116
Enable interrupt simulation (Interrupt Setup option) . . . . . 269
Index
Enable Log File (Log File option). . . . . . . . . . . . . . . . . . . . 77
Enable ULP/LPMx.5 debug
(C-SPY FET Debugger option) . . . . . . . . . . . . . . . . . . . . . 396
Enable (Breakpoints window context menu). . . . . . . . . . . 116
Enable (Interrupt Log window context menu) . . . . . 253, 256
Enable (Power Log window context menu) . . . . . . . . . . . 249
Enable (Sampled Graphs window context menu) . . . . . . . 213
Enable (Timeline window context menu) . . . . . 200–201, 204
__enableInterrupts (C-SPY system macro) . . . . . . . . . . . . 325
Enable/Disable Breakpoint (Call
Stack window context menu) . . . . . . . . . . . . . . . . . . . . . . . 73
Enable/Disable Breakpoint (Disassembly window context
menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Enable/Disable (Trace toolbar) . . . . . . . . . . . . . . . . . . . . . 181
End address (Memory Save option) . . . . . . . . . . . . . . . . . 149
endianness. See byte order
Enter Location dialog box . . . . . . . . . . . . . . . . . . . . . . . . . 132
Erase main and Information memory inc. IP PROTECTED
area (C-SPY FET Debugger option) . . . . . . . . . . . . . . . . . 398
Erase main and Information memory
(C-SPY FET Debugger option) . . . . . . . . . . . . . . . . . . . . . 397
Erase main memory (C-SPY FET Debugger option) . . . . 397
--erase_exclude (C-SPY command line option) . . . . . . . . 374
--erase_ip_protected (C-SPY command line option). . . . . 374
--erase_main (C-SPY command line option) . . . . . . . . . . 374
--erase_main_and_info (C-SPY command line option) . . 375
--erase_retain_file (C-SPY command line option) . . . . . . 375
--erase_retain_target (C-SPY command line option) . . . . 375
__evaluate (C-SPY system macro) . . . . . . . . . . . . . . . . . . 325
Evaluate Now (Macro Quicklaunch
window context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
examples
C-SPY macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
interrupts
interrupt logging . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
macros
checking status of register . . . . . . . . . . . . . . . . . . . . 309
creating a log macro . . . . . . . . . . . . . . . . . . . . . . . . 310
using Quick Watch . . . . . . . . . . . . . . . . . . . . . . . . . 309
performing tasks and continue execution . . . . . . . . . . . 113
tracing incorrect function arguments . . . . . . . . . . . . . . 112
execUserExecutionStarted (C-SPY setup macro) . . . . . . . 318
execUserExecutionStopped (C-SPY setup macro) . . . . . . 318
execUserExit (C-SPY setup macro) . . . . . . . . . . . . . . . . . 319
execUserPreload (C-SPY setup macro) . . . . . . . . . . . . . . 317
execUserPreReset (C-SPY setup macro). . . . . . . . . . . . . . 319
execUserReset (C-SPY setup macro) . . . . . . . . . . . . . . . . 319
execUserSetup (C-SPY setup macro) . . . . . . . . . . . . . . . . 318
executed code, covering . . . . . . . . . . . . . . . . . . . . . . . . . . 232
execution history, tracing . . . . . . . . . . . . . . . . . . . . . . . . . 180
execution, stopping using the sequencer . . . . . . . . . . . . . . 299
expressions. See C-SPY expressions
Extended Clock Control dialog box . . . . . . . . . . . . . . . . . 409
extended command line file, for cspybat . . . . . . . . . . . . . . 376
External code download (C-SPY FET option) . . . . . . . . . 397
extra cycle counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
Extra Options, for C-SPY . . . . . . . . . . . . . . . . . . . . . . . . . 393
F
-f (cspybat option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
FET Debugger (C-SPY driver)
communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
hardware installation . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
File format (Memory Save option) . . . . . . . . . . . . . . . . . . 149
file types
device description, specifying in IDE . . . . . . . . . . . . . . 44
macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44, 391
filename extensions
ddf, selecting device description file . . . . . . . . . . . . . . . 44
mac, using macro file . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
sfr, register definitions for C-SPY . . . . . . . . . . . . . . . . 161
Filename (Memory Restore option) . . . . . . . . . . . . . . . . . 150
Filename (Memory Save option) . . . . . . . . . . . . . . . . . . . 150
Fill dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
__writeMemory8 (C-SPY system macro) . . . . . . . . . . . . . 326
__writeMemory16 (C-SPY system macro) . . . . . . . . . . . . 326
__writeMemory32 (C-SPY system macro) . . . . . . . . . . . . 327
417
UCSARM-4:3
Find in Trace dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Find in Trace window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Find in Trace (Disassembly window context menu) . . . . . . 71
Find (Memory window context menu) . . . . . . . . . . . . . . . 148
Find (Trace toolbar) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
first activation time (interrupt property)
definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
First activation (Edit Interrupt option) . . . . . . . . . . . . . . . 271
flash memory, load library module to . . . . . . . . . . . . . . . . 329
flash memory, single-stepping in C-SPY emulator . . . . . . . 62
__fmessage (C-SPY macro keyword) . . . . . . . . . . . . . . . . 315
for (macro statement) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Force hardware RST/NMI (Emulator menu). . . . . . . . . . . 405
Force Single Stepping (Emulator menu) . . . . . . . . . . . . . . 405
Force (Forced Interrupt window context menu) . . . . . . . . 273
Forced Interrupt window. . . . . . . . . . . . . . . . . . . . . . . . . . 272
Forced Interrupts (Simulator menu) . . . . . . . . . . . . . . . . . 403
Format (Registers User Groups
Setup window context menu) . . . . . . . . . . . . . . . . . . . . . . 163
Format (Registers window context menu) . . . . . . . . . . . . 161
formats, C-SPY input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Function Profiler window . . . . . . . . . . . . . . . . . . . . . . . . . 226
Function Profiler (Simulator menu) . . . . . . . . . . . . . . . . . 402
Function Trace window . . . . . . . . . . . . . . . . . . . . . . . . . . 184
functions
C-SPY running to when starting . . . . . . . . . . . . . . 44, 390
most time spent in, locating . . . . . . . . . . . . . . . . . . . . . 221
--function_profiling (cspybat option) . . . . . . . . . . . . . . . . 376
fuse, blowing on the target device . . . . . . . . . . . . . . . . . . . 407
G
General Clock Control dialog box . . . . . . . . . . . . . . . . . . 408
GIE on/off (Emulator menu) . . . . . . . . . . . . . . . . . . . . . . . 405
Go to Source (Breakpoints window context menu) . . . . . . 116
Go to Source (Call Stack window context menu) . . . . . . . . 72
Go To Source (Timeline window context menu)201, 205, 282
Go (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51, 64
C-SPY® Debugging Guide
418
for MSP430
UCSARM-4:3
H
hardware setup, power consumption because of . . . . . . . . 241
--hardware_multiplier (C-SPY command line option) . . . 377
highlighting, in C-SPY . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Hold time (Edit Interrupt option) . . . . . . . . . . . . . . . . . . . 272
hold time (interrupt property), definition of . . . . . . . . . . . 263
--hwmult_type (C-SPY command line option) . . . . . . . . . 377
I
icons, in this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
if else (macro statement) . . . . . . . . . . . . . . . . . . . . . . . . . . 314
if (macro statement) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Ignore (Report Assert option) . . . . . . . . . . . . . . . . . . . . . . . 78
Images window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Images, loading multiple . . . . . . . . . . . . . . . . . . . . . . . . . . 391
immediate breakpoints, overview . . . . . . . . . . . . . . . . . . . 105
Include (Log File option) . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Init New Device (Emulator menu) . . . . . . . . . . . . . . . . . . 406
input formats, C-SPY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Input Mode dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
input, special characters in Terminal I/O window . . . . . . . . 74
installation directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Instruction Profiling (Disassembly window context menu) 70
Intel-extended, C-SPY input format . . . . . . . . . . . . . . . . . . 35
Intel-extended, C-SPY output format . . . . . . . . . . . . . . . . . 38
Intel-Standard, C-SPY input format . . . . . . . . . . . . . . . . . . 35
interference, power consumption because of . . . . . . . . . . 241
interrupt handling, power consumption during . . . . . . . . . 240
Interrupt Log Summary window . . . . . . . . . . . . . . . . 254, 277
Interrupt Log window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Interrupt Setup dialog box . . . . . . . . . . . . . . . . . . . . . . . . 269
Interrupt Setup (Simulator menu) . . . . . . . . . . . . . . . . . . . 403
Interrupt Status window . . . . . . . . . . . . . . . . . . . . . . . . . . 273
interrupt system, using device description file . . . . . . . . . 265
Interrupt (Edit Interrupt option) . . . . . . . . . . . . . . . . . . . . 271
Interrupt (Timeline window context menu). . . . . . . . . . . . 282
Index
interrupts
adapting C-SPY system for target hardware . . . . . . . . 265
simulated, introduction to . . . . . . . . . . . . . . . . . . . . . . 261
timer, example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
using system macros . . . . . . . . . . . . . . . . . . . . . . . . . . 264
__isBatchMode (C-SPY system macro) . . . . . . . . . . . . . . 328
italic style, in this guide . . . . . . . . . . . . . . . . . . . . . . . . 27–28
J
JTAG password (C-SPY FET Debugger option) . . . . . . . 398
JTAG pins, shared with port pins . . . . . . . . . . . . . . . . . . . 410
JTAG speed (C-SPY FET Debugger option) . . . . . . . . . . 396
--jtag_speed (C-SPY command line option) . . . . . . . . . . . 378
L
labels (assembler), viewing . . . . . . . . . . . . . . . . . . . . . . . . . 84
Leave Target Running (Emulator menu). . . . . . . . . . . . . . 405
--leave_target_running (C-SPY command line option) . . . 378
Length (Fill option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
library functions
C-SPY support for using, plugin module . . . . . . . . . . . 381
online help for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
lightbulb icon, in this guide. . . . . . . . . . . . . . . . . . . . . . . . . 28
linker options
typographic convention . . . . . . . . . . . . . . . . . . . . . . . . . 28
consuming breakpoints . . . . . . . . . . . . . . . . . . . . . . . . 108
Little Endian (Memory window context menu) . . . . . . . . 147
Live Watch window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
__loadImage (C-SPY system macro) . . . . . . . . . . . . . . . . 329
loading multiple debug files, list currently loaded . . . . . . . 54
loading multiple images . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Locals window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
log breakpoints, overview . . . . . . . . . . . . . . . . . . . . . . . . . 104
Log File dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Logging>Set Log file (Debug menu) . . . . . . . . . . . . . . . . . 53
Logging>Set Terminal I/O Log file (Debug menu). . . . . . . 53
loop statements, in C-SPY macros . . . . . . . . . . . . . . . . . . 315
low-power mode, power consumption during . . . . . . . . . . 238
--lpt1 (C-SPY command line option) . . . . . . . . . . . . . . . . 379
--lpt2 (C-SPY command line option) . . . . . . . . . . . . . . . . 379
--lpt3 (C-SPY command line option) . . . . . . . . . . . . . . . . 379
M
mac (filename extension), using a macro file . . . . . . . . . . . 44
--macro (C-SPY command line option) . . . . . . . . . . . . . . 379
macro files, specifying . . . . . . . . . . . . . . . . . . . . . . . . 44, 391
Macro Quicklaunch window . . . . . . . . . . . . . . . . . . . . . . . 361
Macro Registration window . . . . . . . . . . . . . . . . . . . . . . . 357
macro statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
macros
executing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
using . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
--macro-param (C-SPY command line option) . . . . . . . . . 380
main function, C-SPY running to when starting . . . . . 44, 390
--mapu (C-SPY command line option) . . . . . . . . . . . . . . . 380
Mask (Advanced Trigger breakpoints option). . . . . . . . . . 131
Mask (Conditional breakpoints option) . . . . . . . . . . . . . . . 129
Memory access checking (Memory Access Setup option) 170
Memory Access Setup dialog box . . . . . . . . . . . . . . . . . . . 169
Memory Access Setup (Simulator menu) . . . . . . . . . . . . . 402
memory contents, writing to a file . . . . . . . . . . . . . . . . . . 172
Memory Dump dialog box . . . . . . . . . . . . . . . . . . . . . . . . 172
Memory Fill (Memory window context menu) . . . . . . . . . 148
memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Memory Restore dialog box . . . . . . . . . . . . . . . . . . . . . . . 150
Memory Restore (Memory window context menu) . . . . . 148
Memory Save dialog box . . . . . . . . . . . . . . . . . . . . . . . . . 149
Memory Save (Memory window context menu) . . . . . . . . 148
Memory window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
memory zones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
in device description file . . . . . . . . . . . . . . . . . . . . . . . 139
__memoryRestore (C-SPY system macro) . . . . . . . . . . . . 330
__memorySave (C-SPY system macro) . . . . . . . . . . . . . . 330
Memory>Restore (Debug menu) . . . . . . . . . . . . . . . . . . . . 53
Memory>Save (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . 53
419
UCSARM-4:3
menu bar, C-SPY-specific . . . . . . . . . . . . . . . . . . . . . . . . . 50
__message (C-SPY macro keyword) . . . . . . . . . . . . . . . . 315
__messageBoxYesCancel (C-SPY system macro) . . . . . . 331
__messageBoxYesNo (C-SPY system macro) . . . . . . . . . 332
Messages window, amount of output . . . . . . . . . . . . . . . . . 76
migration, from earlier IAR compilers . . . . . . . . . . . . . . . . 26
MISRA C
documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Mixed Mode (Disassembly window context menu) . . . . . . 71
Mode (Advanced Cycle Counter option) . . . . . . . . . . . . . 288
Motorola, C-SPY input format . . . . . . . . . . . . . . . . . . . . . . 35
Motorola, C-SPY output format . . . . . . . . . . . . . . . . . . . . . 38
Move to PC (Disassembly window context menu) . . . . . . . 69
N
Name (Edit SFR option) . . . . . . . . . . . . . . . . . . . . . . . . . . 167
naming conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Navigate (Sampled Graphs window context menu) . . . . . 212
Navigate (Timeline window context menu) . . . 200, 203, 281
New Breakpoint (Breakpoints window context menu) . . . 116
Next Statement (Debug menu) . . . . . . . . . . . . . . . . . . . . . . 52
Next Symbol (Symbolic Memory window context menu) 154
O
--odd_word_check (C-SPY command line option) . . . . . . 380
Open Setup Window (Power Log window context menu) 250
Open User Groups Setup Window (Registers window context
menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
__openFile (C-SPY system macro) . . . . . . . . . . . . . . . . . . 332
Operation (Fill option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Operator (Advanced Trigger breakpoints option) . . . . . . . 131
Operator (Conditional breakpoints option) . . . . . . . . . . . . 128
operators, sizeof in C-SPY . . . . . . . . . . . . . . . . . . . . . . . . . 82
optimizations, effects on variables . . . . . . . . . . . . . . . . . . . 82
options
in the IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
on the command line . . . . . . . . . . . . . . . . . . . . . . 367, 393
C-SPY® Debugging Guide
420
for MSP430
UCSARM-4:3
Options (Stack window context menu) . . . . . . . . . . . . . . . 158
__orderInterrupt (C-SPY system macro). . . . . . . . . . . . . . 334
Originator (debugger option) . . . . . . . . . . . . . . . . . . . . . . 392
P
-p (C-SPY command line option) . . . . . . . . . . . . . . . . . . . 381
__param (C-SPY macro keyword) . . . . . . . . . . . . . . . . . . 313
parameters
tracing incorrect values of . . . . . . . . . . . . . . . . . . . . . . . 65
typographic convention . . . . . . . . . . . . . . . . . . . . . . . . . 27
part number, of this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
peripheral units
debugging power consumption for . . . . . . . . . . . . . . . . 235
detecting mistakenly unattended . . . . . . . . . . . . . . . . . 239
detecting unattended . . . . . . . . . . . . . . . . . . . . . . . . . . 239
device-specific . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
displayed in Register window . . . . . . . . . . . . . . . . . . . 138
in an event-driven system . . . . . . . . . . . . . . . . . . . . . . 240
in C-SPY expressions . . . . . . . . . . . . . . . . . . . . . . . . . . 81
initializing using setup macros . . . . . . . . . . . . . . . . . . . 306
Please select one symbol
(Resolve Symbol Ambiguity option) . . . . . . . . . . . . . . . . 102
--plugin (C-SPY command line option) . . . . . . . . . . . . . . 381
plugin modules (C-SPY) . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Plugins (C-SPY options) . . . . . . . . . . . . . . . . . . . . . . . . . . 392
__popSimulatorInterruptExecutingStack (C-SPY
system macro) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
pop-up menu. See context menu
--port (C-SPY command line option) . . . . . . . . . . . . . . . . 382
port pins, shared with JTAG pins . . . . . . . . . . . . . . . . . . . 410
power consumption, measuring . . . . . . . . . . . . . . . . 222, 235
Power graph in Timeline window . . . . . . . . . . . . . . . . . . . 251
Power Log window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
power sampling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Power Setup window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
prerequisites, programming experience . . . . . . . . . . . . . . . 23
Previous Symbol (Symbolic
Memory window context menu) . . . . . . . . . . . . . . . . . . . . 154
Index
probability (interrupt property) . . . . . . . . . . . . . . . . . . . . . 272
definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Probability % (Edit Interrupt option) . . . . . . . . . . . . . . . . 272
Profile Selection (Timeline window context menu) . . . . . 201
profiling
analyzing data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
on function level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
on instruction level. . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
using MSP430 advanced cycle counter . . . . . . . . . . . . 285
profiling information, on functions and instructions . . . . . 221
profiling sources
trace (calls) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222, 228
trace (flat) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222, 228
program execution
breaking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104–105
in C-SPY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
program flow, monitoring . . . . . . . . . . . . . . . . . . . . . . . . . 291
program states, monitoring . . . . . . . . . . . . . . . . . . . . . . . . 291
programming experience . . . . . . . . . . . . . . . . . . . . . . . . . . 23
program. See application
projects, for debugging externally built applications. . . . . . 46
--protocol (C-SPY command line option) . . . . . . . . . . . . . 382
publication date, of this guide . . . . . . . . . . . . . . . . . . . . . . . . 2
Q
Quick Watch window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
executing C-SPY macros . . . . . . . . . . . . . . . . . . . . . . . 309
R
Range breakpoints dialog box . . . . . . . . . . . . . . . . . . . . . . 125
range breakpoints, overview . . . . . . . . . . . . . . . . . . . . . . . 105
Range for (Viewing Range option) . . . . . . . . . . . . . . . . . . 218
Reaction trigger (Advanced Cycle Counter option) . . . . . 290
__readFile (C-SPY system macro) . . . . . . . . . . . . . . . . . . 335
__readFileByte (C-SPY system macro) . . . . . . . . . . . . . . 336
reading guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
__readMemoryByte (C-SPY system macro) . . . . . . . . . . . 336
__readMemory8 (C-SPY system macro) . . . . . . . . . . . . . 336
__readMemory16 (C-SPY system macro) . . . . . . . . . . . . 337
__readMemory32 (C-SPY system macro) . . . . . . . . . . . . 337
reference information, typographic convention . . . . . . . . . . 28
Refresh (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
register groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
predefined, enabling. . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Register User Groups Setup window . . . . . . . . . . . . . . . . 162
registered trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
__registerMacroFile (C-SPY system macro) . . . . . . . . . . 338
Registers window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
registers, displayed in Registers window . . . . . . . . . . . . . 159
Release JTAG on Go (Emulator menu) . . . . . . . . . . . . . . 405
Remove All (Macro Quicklaunch window
context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
Remove (Macro Quicklaunch window context menu) . . . 362
Remove (Registers User Groups
Setup window context menu) . . . . . . . . . . . . . . . . . . . . . . 163
Repeat interval (Edit Interrupt option) . . . . . . . . . . . . . . . 271
repeat interval (interrupt property), definition of . . . . . . . 262
Replace (Memory window context menu) . . . . . . . . . . . . 148
Report Assert dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Reset Counter (Advanced Cycle Counter option) . . . . . . . 290
Reset States (Sequencer option) . . . . . . . . . . . . . . . . . . . . 304
Reset Trigger (Sequencer option) . . . . . . . . . . . . . . . . . . . 304
Reset (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
__resetFile (C-SPY system macro) . . . . . . . . . . . . . . . . . . 338
Resolve Source Ambiguity dialog box . . . . . . . . . . . . . . . 134
Restore (Memory Restore option) . . . . . . . . . . . . . . . . . . . 150
Resynchronize JTAG (Emulator menu) . . . . . . . . . . . . . . 405
Retain unchanged memory
(C-SPY FET Debugger option) . . . . . . . . . . . . . . . . . . . . . 398
return (macro statement) . . . . . . . . . . . . . . . . . . . . . . . . . . 315
ROM-monitor, definition of . . . . . . . . . . . . . . . . . . . . . . . . 38
RTOS awareness debugging . . . . . . . . . . . . . . . . . . . . . . . . 35
RTOS awareness (C-SPY plugin module) . . . . . . . . . . . . . 35
Run to Cursor (Call Stack window context menu) . . . . . . . 72
Run to Cursor (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . 52
Run to Cursor (Disassembly window context menu) . . . . . 69
Run to Cursor, command for executing . . . . . . . . . . . . . . . 64
421
UCSARM-4:3
Run to (C-SPY option) . . . . . . . . . . . . . . . . . . . . . . . . 44, 390
S
Sampled Graphs window . . . . . . . . . . . . . . . . . . . . . . . . . 211
Save Custom SFRs (SFR Setup window context menu) . . 167
Save to File (Register User Groups
Setup window context menu) . . . . . . . . . . . . . . . . . . . . . . 163
Save to File (Registers window context menu) . . . . . . . . . 162
Save (Memory Save option) . . . . . . . . . . . . . . . . . . . . . . . 150
Save (Trace toolbar) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Scale (Viewing Range option) . . . . . . . . . . . . . . . . . . . . . 219
Secure - Blow JTAG Fuse (Emulator menu). . . . . . . . . . . 407
Select All (Debug Log window context menu) . . . . . . . . . . 76
Select Graphs (Sampled Graphs window context menu). . 214
Select Graphs (Timeline window context menu)201, 205, 282
Select plugins to load (debugger option) . . . . . . . . . . . . . . 392
Sequencer Control window . . . . . . . . . . . . . . . . . . . . . . . . 303
Sequencer Control (Emulator menu). . . . . . . . . . . . . . . . . 406
sequencer, setting up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Set Data Breakpoint (Memory window context menu) . . . 148
Set Data Log
Breakpoint (Memory window context menu) . . . . . . . . . . 149
Set Next Statement (Debug menu) . . . . . . . . . . . . . . . . . . . 52
Set Next Statement (Disassembly window context menu) . 70
__setAdvancedTriggerBreak (C-SPY system macro) . . . . 339
__setCodeBreak (C-SPY system macro). . . . . . . . . . . . . . 340
__setConditionalBreak (C-SPY system macro) . . . . . . . . 341
__setDataBreak (C-SPY system macro) . . . . . . . . . . . . . . 343
__setDataLogBreak (C-SPY system macro) . . . . . . . . . . . 344
__setLogBreak (C-SPY system macro) . . . . . . . . . . . . . . 345
__setRangeBreak (C-SPY system macro) . . . . . . . . . . . . . 346
__setSimBreak (C-SPY system macro) . . . . . . . . . . . . . . 347
Settling time (C-SPY FET option) . . . . . . . . . . . . . . . . . . 396
--settlingtime (C-SPY command line option) . . . . . . . . . . 383
__setTraceStartBreak (C-SPY system macro) . . . . . . . . . 348
__setTraceStopBreak (C-SPY system macro) . . . . . . . . . . 349
setup macro file, registering . . . . . . . . . . . . . . . . . . . . . . . . 44
C-SPY® Debugging Guide
422
for MSP430
UCSARM-4:3
setup macro functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
reserved names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
Setup macros (debugger option) . . . . . . . . . . . . . . . . . . . . 391
Setup (C-SPY options) . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
Setup (FET debugger options) . . . . . . . . . . . . . . . . . . . . . 395
--set_exit_breakpoint (C-SPY command line option) . . . . 383
--set_getchar_breakpoint (C-SPY command line option) . 383
--set_putchar_breakpoint (C-SPY command line option) . 383
SFR
using as assembler symbols . . . . . . . . . . . . . . . . . . . . . . 81
SFR Setup window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
shortcut menu. See context menu
Show all images (Images window context menu) . . . . . . . . 55
Show All (SFR Setup window context menu). . . . . . . . . . 166
Show Arguments (Call Stack window context menu) . . . . . 72
Show Custom SFRs only (SFR Setup
window context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Show Cycles (Interrupt Log window context menu) . 253, 256
Show Factory SFRs only (SFR Setup
window context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Show Numerical Value
(Timeline window context menu) . . . . . . . . . . . . . . . 205, 214
Show offsets (Stack window context menu) . . . . . . . . . . . 157
Show only (Image window context menu) . . . . . . . . . . . . . 55
Show Time (Interrupt Log window context menu) . . 253, 256
Show variables (Stack window context menu) . . . . . . . . . 157
--silent (C-SPY command line option) . . . . . . . . . . . . . . . 384
Simulated Frequency dialog box . . . . . . . . . . . . . . . . . . . . 408
simulating interrupts, enabling/disabling . . . . . . . . . . . . . 269
Simulator menu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
simulator, introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Size (Edit SFR option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Size (Sampled Graphs window context menu) . . . . . . . . . 214
Size (Timeline window context menu) . . . . . . . . . . . . . . . 204
sizeof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
__smessage (C-SPY macro keyword) . . . . . . . . . . . . . . . . 315
software delay, power consumption during . . . . . . . . . . . . 238
Solid Graph (Sampled Graphs window context menu) . . . 214
Solid Graph (Timeline window context menu) . . . . . . . . . 204
__sourcePosition (C-SPY system macro) . . . . . . . . . . . . . 350
Index
special function registers (SFR)
description files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
using as assembler symbols . . . . . . . . . . . . . . . . . . . . . . 81
Stack window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
standard C, sizeof operator in C-SPY . . . . . . . . . . . . . . . . . 82
Start address (Fill option) . . . . . . . . . . . . . . . . . . . . . . . . . 151
Start address (Memory Save option) . . . . . . . . . . . . . . . . . 149
Start (Advanced Cycle Counter option) . . . . . . . . . . . . . . 289
State Log window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
state storage
setting up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
starting using the sequencer . . . . . . . . . . . . . . . . . . . . . 299
State Storage Control window . . . . . . . . . . . . . . . . . . . . . 294
State Storage Control (Emulator menu) . . . . . . . . . . . . . . 406
State Storage window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
static analysis
documentation for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Statics window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
stdin and stdout, redirecting to C-SPY window . . . . . . . . . 73
Step Into (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Step Into, description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Step Out (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Step Out, description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Step Over (Debug menu) . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Step Over, description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
step points, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Stop Debugging (Debug menu) . . . . . . . . . . . . . . . . . . . . . 52
Stop (Advanced Cycle Counter option) . . . . . . . . . . . . . . 289
stopping execution using the sequencer . . . . . . . . . . . . . . 299
__strFind (C-SPY system macro) . . . . . . . . . . . . . . . . . . . 350
__subString (C-SPY system macro) . . . . . . . . . . . . . . . . . 351
Symbolic Memory window . . . . . . . . . . . . . . . . . . . . . . . . 152
Symbols window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
symbols, using in C-SPY expressions . . . . . . . . . . . . . . . . . 80
System breakpoints on (C-SPY FET Debugger option) . . 399
T
target system, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 37
Target VCC (C-SPY FET Debugger option) . . . . . . . . . . 396
__targetDebuggerVersion (C-SPY system macro) . . . . . . 351
Terminal IO Log Files (Terminal IO Log Files option) . . . 75
Terminal I/O Log Files dialog box . . . . . . . . . . . . . . . . . . . 74
Terminal I/O window . . . . . . . . . . . . . . . . . . . . . . . . . . 65, 73
terminology. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Text search (Find in Trace option) . . . . . . . . . . . . . . . . . . 189
TI msp430-txt, C-SPY input format . . . . . . . . . . . . . . . . . . 35
TI msp430-txt, C-SPY output format . . . . . . . . . . . . . . . . . 38
Time Axis Unit (Timeline window context menu) . . 201, 205
Time Axis Unit
(Timeline window context menu) . . . . . . . . . . . . . . . . . . . 282
Timeline window . . . . . . . . . . . . . . . . . . . . . . . 198, 201, 257
power graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
--timeout (C-SPY command line option) . . . . . . . . . . . . . 384
timer interrupt, example . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Toggle Breakpoint (Code) (Call
Stack window context menu) . . . . . . . . . . . . . . . . . . . . . . . 72
Toggle Breakpoint (Code) (Disassembly
window context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Toggle Breakpoint (Log) (Call
Stack window context menu) . . . . . . . . . . . . . . . . . . . . . . . 73
Toggle Breakpoint (Log) (Disassembly
window context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Toggle Breakpoint (Trace Start) (Call
Stack window context menu) . . . . . . . . . . . . . . . . . . . . . . . 73
Toggle Breakpoint (Trace Start) (Disassembly
window context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Toggle Breakpoint (Trace Stop) (Call
Stack window context menu) . . . . . . . . . . . . . . . . . . . . . . . 73
Toggle Breakpoint (Trace Stop) (Disassembly
window context menu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Toggle source (Trace toolbar) . . . . . . . . . . . . . . . . . . . . . . 181
__toLower (C-SPY system macro) . . . . . . . . . . . . . . . . . . 352
tools icon, in this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
__toString (C-SPY system macro) . . . . . . . . . . . . . . . . . . 352
__toUpper (C-SPY system macro) . . . . . . . . . . . . . . . . . . 353
trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177, 191
Trace Expressions window . . . . . . . . . . . . . . . . . . . . . . . . 187
trace start and stop breakpoints, overview . . . . . . . . . . . . 104
423
UCSARM-4:3
Trace Start breakpoints dialog box . . . . . . . . . . . . . . . . . . 185
Trace Stop breakpoints dialog box . . . . . . . . . . . . . . . . . . 186
Trace window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
trace (calls), profiling source . . . . . . . . . . . . . . . . . . 222, 228
trace (flat), profiling source . . . . . . . . . . . . . . . . . . . 222, 228
trace, in Timeline window . . . . . . . . . . . . 198, 201, 251, 257
trace, state storage being variant of . . . . . . . . . . . . . . . . . . 291
trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Type (Advanced Trigger breakpoints option) . . . . . . . . . . 130
Type (Conditional breakpoints option) . . . . . . . . . . . . . . . 128
typographic conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
U
UBROF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Unavailable, C-SPY message . . . . . . . . . . . . . . . . . . . . . . . 83
Universal Binary Relocatable Object Format. See UBROF
__unloadImage(C-SPY system macro) . . . . . . . . . . . . . . . 353
Use command line options (debugger option) . . . . . . . . . . 393
Use Extra Images (debugger option) . . . . . . . . . . . . . . . . . 391
Use manual ranges (Memory Access Setup option) . . . . . 170
Use only emulated breakpoints
(FET Debugger option) . . . . . . . . . . . . . . . . . . . 211–212, 399
Use ranges based on (Memory Access Setup option) . . . . 169
Use software breakpoints (C-SPY FET Debugger option) 399
user application, definition of . . . . . . . . . . . . . . . . . . . . . . . 37
--use_emulated_breakpoints
(C-SPY command line option) . . . . . . . . . . . . . . . . . . . . . 384
--use_virtual_breakpoints (C-SPY command line option). 385
V
Value (Advanced Trigger breakpoints option) . . . . . . . . . 131
Value (Fill option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
__var (C-SPY macro keyword) . . . . . . . . . . . . . . . . . . . . . 312
variables
effects of optimizations . . . . . . . . . . . . . . . . . . . . . . . . . 82
information, limitation on . . . . . . . . . . . . . . . . . . . . . . . 82
using in C-SPY expressions . . . . . . . . . . . . . . . . . . . . . . 80
C-SPY® Debugging Guide
424
for MSP430
UCSARM-4:3
variance (interrupt property), definition of . . . . . . . . . . . . 263
Variance % (Edit Interrupt option) . . . . . . . . . . . . . . . . . . 272
--vccvoltage (C-SPY command line option) . . . . . . . . . . . 385
Verify download (debugger option) . . . . . . . . . . . . . . . . . 397
--verify_all (C-SPY command line option) . . . . . . . . . . . . 385
version number
of this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
View Group (Registers window context menu) . . . . . . . . 161
View User Group (Registers window context menu) . . . . 161
Viewing Range dialog box . . . . . . . . . . . . . . . . . . . . . . . . 218
Viewing Range (Sampled Graphs window context menu) 214
Viewing Range (Timeline window context menu) . . . . . . 204
virtual breakpoints
configuring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
visualSTATE, C-SPY plugin module for . . . . . . . . . . . . . . 38
W
waiting for device, power consumption during . . . . . . . . . 238
warnings icon, in this guide . . . . . . . . . . . . . . . . . . . . . . . . 28
Watch window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
using . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
web sites, recommended . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
while (macro statement) . . . . . . . . . . . . . . . . . . . . . . . . . . 315
windows, specific to C-SPY . . . . . . . . . . . . . . . . . . . . . . . . 53
With I/O emulation modules (linker option), using. . . . . . . 73
__writeFile (C-SPY system macro) . . . . . . . . . . . . . . . . . 354
__writeFileByte (C-SPY system macro) . . . . . . . . . . . . . . 354
__writeMemoryByte (C-SPY system macro) . . . . . . . . . . 355
__writeMemory8 (C-SPY system macro) . . . . . . . . . . . . . 355
__writeMemory16 (C-SPY system macro) . . . . . . . . . . . . 355
__writeMemory32 (C-SPY system macro) . . . . . . . . . . . . 356
Z
zone
defined in device description file . . . . . . . . . . . . . . . . . 139
in C-SPY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
part of an absolute address . . . . . . . . . . . . . . . . . . . . . . 133
Index
Zone (Edit SFR option). . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Zone (Memory Save option) . . . . . . . . . . . . . . . . . . . 149–150
Zoom (Sampled Graphs window context menu) . . . . . . . . 213
Zoom (Timeline window context menu) . . . . . . 200, 204, 281
Symbols
__abortLaunch (C-SPY system macro) . . . . . . . . . . . . . . . 321
__cancelAllInterrupts (C-SPY system macro) . . . . . . . . . 322
__cancelInterrupt (C-SPY system macro) . . . . . . . . . . . . . 322
__clearBreak (C-SPY system macro) . . . . . . . . . . . . . . . . 323
__closeFile (C-SPY system macro) . . . . . . . . . . . . . . . . . 323
__delay (C-SPY system macro) . . . . . . . . . . . . . . . . . . . . 323
__disableInterrupts (C-SPY system macro) . . . . . . . . . . . 324
__driverType (C-SPY system macro) . . . . . . . . . . . . . . . . 324
__enableInterrupts (C-SPY system macro) . . . . . . . . . . . . 325
__evaluate (C-SPY system macro) . . . . . . . . . . . . . . . . . . 325
__fillMemory8 (C-SPY system macro) . . . . . . . . . . . . . . 326
__fillMemory16 (C-SPY system macro). . . . . . . . . . . . . . 326
__fillMemory32 (C-SPY system macro). . . . . . . . . . . . . . 327
__fmessage (C-SPY macro keyword) . . . . . . . . . . . . . . . . 315
__isBatchMode (C-SPY system macro) . . . . . . . . . . . . . . 328
__loadImage (C-SPY system macro) . . . . . . . . . . . . . . . . 329
__memoryRestore (C-SPY system macro) . . . . . . . . . . . . 330
__memorySave (C-SPY system macro) . . . . . . . . . . . . . . 330
__message (C-SPY macro keyword) . . . . . . . . . . . . . . . . 315
__messageBoxYesCancel (C-SPY system macro) . . . . . . 331
__messageBoxYesNo (C-SPY system macro) . . . . . . . . . 332
__openFile (C-SPY system macro) . . . . . . . . . . . . . . . . . . 332
__orderInterrupt (C-SPY system macro). . . . . . . . . . . . . . 334
__param (C-SPY macro keyword) . . . . . . . . . . . . . . . . . . 313
__popSimulatorInterruptExecutingStack (C-SPY
system macro) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
__readFile (C-SPY system macro) . . . . . . . . . . . . . . . . . . 335
__readFileByte (C-SPY system macro) . . . . . . . . . . . . . . 336
__readMemoryByte (C-SPY system macro) . . . . . . . . . . . 336
__readMemory8 (C-SPY system macro) . . . . . . . . . . . . . 336
__readMemory16 (C-SPY system macro) . . . . . . . . . . . . 337
__readMemory32 (C-SPY system macro) . . . . . . . . . . . . 337
__registerMacroFile (C-SPY system macro) . . . . . . . . . . 338
__resetFile (C-SPY system macro) . . . . . . . . . . . . . . . . . . 338
__setAdvancedTriggerBreak (C-SPY system macro) . . . . 339
__setCodeBreak (C-SPY system macro). . . . . . . . . . . . . . 340
__setConditionalBreak (C-SPY system macro) . . . . . . . . 341
__setDataBreak (C-SPY system macro) . . . . . . . . . . . . . . 343
__setDataLogBreak (C-SPY system macro) . . . . . . . . . . . 344
__setLogBreak (C-SPY system macro) . . . . . . . . . . . . . . 345
__setRangeBreak (C-SPY system macro) . . . . . . . . . . . . . 346
__setSimBreak (C-SPY system macro) . . . . . . . . . . . . . . 347
__setTraceStartBreak (C-SPY system macro) . . . . . . . . . 348
__setTraceStopBreak (C-SPY system macro) . . . . . . . . . . 349
__smessage (C-SPY macro keyword) . . . . . . . . . . . . . . . . 315
__sourcePosition (C-SPY system macro) . . . . . . . . . . . . . 350
__strFind (C-SPY system macro) . . . . . . . . . . . . . . . . . . . 350
__subString (C-SPY system macro) . . . . . . . . . . . . . . . . . 351
__targetDebuggerVersion (C-SPY system macro) . . . . . . 351
__toLower (C-SPY system macro) . . . . . . . . . . . . . . . . . . 352
__toString (C-SPY system macro) . . . . . . . . . . . . . . . . . . 352
__toUpper (C-SPY system macro) . . . . . . . . . . . . . . . . . . 353
__unloadImage (C-SPY system macro) . . . . . . . . . . . . . . 353
__var (C-SPY macro keyword) . . . . . . . . . . . . . . . . . . . . . 312
__writeFile (C-SPY system macro) . . . . . . . . . . . . . . . . . 354
__writeFileByte (C-SPY system macro) . . . . . . . . . . . . . . 354
__writeMemoryByte (C-SPY system macro) . . . . . . . . . . 355
__writeMemory8 (C-SPY system macro) . . . . . . . . . . . . . 355
__writeMemory16 (C-SPY system macro) . . . . . . . . . . . . 355
__writeMemory32 (C-SPY system macro) . . . . . . . . . . . . 356
-d (C-SPY command line option) . . . . . . . . . . . . . . . . . . . 371
-f (cspybat option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
-p (C-SPY command line option) . . . . . . . . . . . . . . . . . . . 381
--allow_access_to_BSL (C-SPY command line option) . . 368
--allow_locked_flash_access
(C-SPY command line option) . . . . . . . . . . . . . . . . . . . . . 368
--attach_to_running_target (C-SPY command line option)368
--backend (C-SPY command line option) . . . . . . . . . . . . . 369
--code_coverage_file (C-SPY command line option) . . . . 370
--connection (C-SPY command line option) . . . . . . . . . . . 369
--cycles (C-SPY command line option) . . . . . . . . . . . . . . 370
--debugfile (cspybat option) . . . . . . . . . . . . . . . . . . . . . . . 371
425
UCSARM-4:3
--derivative (C-SPY command line option). . . . . . . . . . . . 372
--disable_interrupts (C-SPY command line option) . . . . . 372
--disable_memory_cache (C-SPY command line option) . 372
--download_only (C-SPY command line option) . . . . . . . 372
--eem (C-SPY command line option) . . . . . . . . . . . . . . . . 373
--erase_exclude (C-SPY command line option) . . . . . . . . 374
--erase_ip_protected (C-SPY command line option). . . . . 374
--erase_main (C-SPY command line option) . . . . . . . . . . 374
--erase_main_and_info (C-SPY command line option) . . 375
--erase_retain_file (C-SPY command line option) . . . . . . 375
--erase_retain_target (C-SPY command line option) . . . . 375
--function_profiling (cspybat option) . . . . . . . . . . . . . . . . 376
--hardware_multiplier (C-SPY command line option) . . . 377
--hwmult_type (C-SPY command line option) . . . . . . . . . 377
--jtag_speed (C-SPY command line option) . . . . . . . . . . . 378
--leave_target_running (C-SPY command line option) . . . 378
--lpt1 (C-SPY command line option) . . . . . . . . . . . . . . . . 379
--lpt2 (C-SPY command line option) . . . . . . . . . . . . . . . . 379
--lpt3 (C-SPY command line option) . . . . . . . . . . . . . . . . 379
--macro (C-SPY command line option) . . . . . . . . . . . . . . 379
--macro_param (C-SPY command line option) . . . . . . . . . 380
--mapu (C-SPY command line option) . . . . . . . . . . . . . . . 380
--odd_word_check (C-SPY command line option) . . . . . . 380
--plugin (C-SPY command line option) . . . . . . . . . . . . . . 381
--port (C-SPY command line option) . . . . . . . . . . . . . . . . 382
--protocol (C-SPY command line option) . . . . . . . . . . . . . 382
--settlingtime (C-SPY command line option) . . . . . . . . . . 383
--set_exit_breakpoint (C-SPY command line option) . . . . 383
--set_getchar_breakpoint (C-SPY command line option) . 383
--set_putchar_breakpoint (C-SPY command line option) . 383
--silent (C-SPY command line option) . . . . . . . . . . . . . . . 384
--timeout (C-SPY command line option) . . . . . . . . . . . . . 384
--use_emulated_breakpoints
(C-SPY command line option) . . . . . . . . . . . . . . . . . . . . . 384
--use_virtual_breakpoints (C-SPY command line option). 385
--vccvoltage (C-SPY command line option) . . . . . . . . . . . 385
--verify_all (C-SPY command line option) . . . . . . . . . . . . 385
C-SPY® Debugging Guide
426
for MSP430
UCSARM-4:3
Numerics
1x Units (Symbolic Memory window context menu) . . . . 154
8x Units (Memory window context menu) . . . . . . . . . . . . 147
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement