UCS8051-1
IAR Embedded Workbench
®
C-SPY
®
Debugging Guide
for the 8051 Microcontroller Architecture
UCS8051-1
UCS8051-1
COPYRIGHT NOTICE
Copyright © 2011 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, C-SPY, visualSTATE, From Idea To Target,
IAR KickStart Kit, IAR PowerPac, IAR YellowSuite, IAR Advanced Development Kit,
IAR, and the IAR Systems logotype are trademarks or registered trademarks owned by
IAR Systems AB. J-Link is a trademark licensed to IAR Systems AB.
Intel® is a registered trademark of Intel Corporation.
Microsoft and Windows are registered trademarks of Microsoft 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
First edition: April 2011
Part number: UCS8051-1
This guide applies to version 8.x of IAR Embedded Workbench® for 8051.
The C-SPY® Debugging Guide for 8051 replaces all debugging information in the IAR
Embedded Workbench IDE User Guide and the hardware debugger guides for 8051.
Internal reference: M9, Too6.1, tut2009.1, IJOA.
UCS8051-1
3
Brief contents
Tables ...................................................................................................................... 15
Figures .................................................................................................................... 17
Preface .................................................................................................................... 21
The IAR C-SPY Debugger ........................................................................... 27
Getting started using C-SPY ....................................................................... 39
Executing your application ........................................................................... 55
Working with variables and expressions .............................................. 73
Using breakpoints ............................................................................................. 89
Monitoring memory and registers ........................................................ 113
Collecting and using trace data ............................................................... 133
Using the profiler ............................................................................................ 149
Code coverage ................................................................................................. 157
Simulating interrupts ..................................................................................... 161
Using C-SPY macros ................................................................................... 177
The C-SPY Command Line Utility—cspybat ................................... 221
Debugger options ........................................................................................... 261
Additional information on C-SPY drivers .......................................... 285
Target-adapting the ROM-monitor ....................................................... 293
Index ..................................................................................................................... 311
UCS8051-1
4
C-SPY® Debugging Guide
for 8051
UCS8051-1
5
Contents
Tables ...................................................................................................................... 15
Figures .................................................................................................................... 17
Preface .................................................................................................................... 21
Who should read this guide ............................................................... 21
How to use this guide ........................................................................... 21
What this guide contains ..................................................................... 22
Other documentation ........................................................................... 23
User and reference guides .................................................................. 23
The online help system ...................................................................... 24
Web sites ............................................................................................ 24
Document conventions ........................................................................ 24
Typographic conventions ................................................................... 25
Naming conventions .......................................................................... 25
The IAR C-SPY Debugger ........................................................................... 27
Introduction to C-SPY .......................................................................... 27
An integrated environment ................................................................. 27
General C-SPY debugger features ..................................................... 28
RTOS awareness ................................................................................ 29
Debugger concepts ................................................................................ 29
C-SPY and target systems .................................................................. 29
The debugger ...................................................................................... 30
The target system ............................................................................... 30
The application ................................................................................... 30
C-SPY debugger systems ................................................................... 30
The ROM-monitor program ............................................................... 31
Third-party debuggers ........................................................................ 31
C-SPY plugin modules ....................................................................... 31
C-SPY drivers overview ....................................................................... 32
Differences between the C-SPY drivers ........................................... 32