Getting Started
with µVision2
and the C51 Microcontrolle
r
Development Tools
User’s Guide 02.2001
2 Keil Software
Information in this document is subject to change without notice and does not
represent a commitment on the part of the manufacturer. The software described
in this document is furnished under license agreement or nondisclosure
agreement and may be used or copied only in accordance with the terms of the
agreement. It is against the law to copy the software on any medium except as
specifically allowed in the license or nondisclosure agreement. The purchaser
may make one copy of the software for backup purposes. No part of this manual
may be reproduced or transmitted in any form or by any means, electronic or
mechanical, including photocopying, recording, or information storage and
retrieval systems, for any purpose other than for the purchaser’s personal use,
without written permission.
Copyright © 1997-2001 Keil Elektronik GmbH and Keil Software, Inc.
All rights reserved.
NOTE
This manual assumes that you are familiar with Microsoft Windows and the
hardware and instruction set of the 8051 microcontrollers.
Keil C51™ and µVision™ are trademarks of Keil Elektronik GmbH.
Microsoft
®
, and Windows™ are trademarks or registered trademarks of
Microsoft Corporation.
PC
®
is a registered trademark of International Business Machines Corporation.
Every effort was made to ensure accuracy in this manual and to give appropriate
credit to persons, companies, and trademarks referenced herein.
Getting Started and Creating Applications 3
Preface
This manual is an introduction to the Keil Software development tools for the
8051 family of microcontrollers. It introduces new users and interested readers
to our products. This user’s guide contains the following chapters.
“Chapter 1. Introduction” gives an overview and discusses the different products
that Keil Software offers for the 8051 microcontroller families.
“Chapter 2. Installation” describes how to install the software and how to setup
the operating environment for the tools.
“Chapter 3. Development Tools” describes the major features of the µVision2
IDE with integrated debugger, the C compiler, assembler, and utilities.
“Chapter 4. Creating Applications” describes how to create projects, edit source
files, compile and fix syntax errors, and generate executable code.
“Chapter 5. Testing Programs” describes how you use the µVision2 debugger to
simulate and test your entire application.
“Chapter 6. µVision2 Debug Functions” discusses built-in, user, and signal
functions that extended the debugging capabilities of µVision2.
“Chapter 7. Sample Programs” provides several sample programs that show you
how to use the Keil 8051 development tools.
“Chapter 8. RTX-51 Real-Time Operating System” discusses RTX-51 Tiny and
RTX-51 Full and provides an example program.
“Chapter 9. Using On-chip Peripherals” shows how to access the on-chip 8051
peripherals with the C51 compiler. This chapter also includes several
Application Notes.
“Chapter 10. CPU and C Startup Code” provides information on setting up the
8051 CPU for your application.
“Chapter 11. Using Monitor-51” discusses how to initialize the monitor and
install it on your target hardware.
“Chapter 12. Command Reference” briefly describes the commands and
controls available in the Keil 8051 development tools.
4 Preface
Document Conventions
This document uses the following conventions:
Examples Description
README.TXT
Bold capital text is used for the names of executable programs, data files,
source files, environment variables, and commands you enter at the
command prompt. This text usually represents commands that you must
type in literally. For example:
CLS DIR BL51.EXE
Note that you are not required to enter these commands using all capital
letters.
Courier Text in this typeface is used to represent information that displays on
screen or prints at the printer.
This typeface is also used within the text when discussing or describing
command line items.
Variables
Text in italics represents information that you must provide. For example,
projectfile in a syntax string means that you must supply the actual project
file name.
Occasionally, italics are also used to emphasize words in the text.
Elements that
repeat…
Ellipses (…) are used to indicate an item that may be repeated.
Omitted code
:
:
Vertical ellipses are used in source code listings to indicate that a
fragment of the program is omitted. For example:
Void main (void) {
:
:
while (1);
Optional Items
Double brackets indicate optional items in command lines and input fields.
For example:
C51 TEST.C PRINT (filename)
{ opt1 | opt2 }
Text contained within braces, separated by a vertical bar represents a
group of items from which one must be chosen. The braces enclose all of
the choices and the vertical bars separate the choices. One item in the list
must be selected.
Keys
Text in this sans serif typeface represents actual keys on the keyboard.
For example, “Press Enter to continue.”
Point
Move the mouse until the mouse pointer rests on the item desired.
Click
Quickly press and release a mouse button while pointing at the item to be
selected.
Drag
Press the left mouse button while on a selected item. Then, hold the
button down while moving the mouse. When the item to be selected is at
the desired position, release the button.
Double-Click
Click the mouse button twice in rapid succession.
Getting Started and Creating Applications 5
Contents
Chapter 1. Introduction......................................................................................9
Manual Topics ............................................................................................................ 10
Changes to the Documentation ................................................................................... 10
Evaluation Kits and Production Kits........................................................................... 11
Types of Users ............................................................................................................ 11
Requesting Assistance................................................................................................. 12
Software Development Cycle ..................................................................................... 13
Product Overview ....................................................................................................... 16
Chapter 2. Installation......................................................................................19
System Requirements.................................................................................................. 19
Installation Details ...................................................................................................... 19
Folder Structure .......................................................................................................... 20
Chapter 3. Development Tools.........................................................................21
µVision2 Integrated Development Environment ........................................................ 21
C51 Optimizing C Cross Compiler............................................................................. 32
A51 Macro Assembler ................................................................................................ 49
BL51 Code Banking Linker/Locator .......................................................................... 51
LIB51 Library Manager.............................................................................................. 54
OC51 Banked Object File Converter.......................................................................... 55
OH51 Object-Hex Converter ...................................................................................... 55
Chapter 4. Creating Applications....................................................................57
Creating Projects......................................................................................................... 57
Project Targets and File Groups ................................................................................. 64
Overview of Configuration Dialogs............................................................................ 66
Code Banking ............................................................................................................. 67
µVision2 Utilities........................................................................................................ 69
Writing Optimum Code .............................................................................................. 78
Tips and Tricks ........................................................................................................... 82
Chapter 5. Testing Programs...........................................................................93
µVision2 Debugger..................................................................................................... 93
Debug Commands..................................................................................................... 107
Expressions............................................................................................................... 110
Tips and Tricks ......................................................................................................... 126
Chapter 6. µVision2 Debug Functions ..........................................................131
Creating Functions.................................................................................................... 131
Invoking Functions ................................................................................................... 133
Function Classes ....................................................................................................... 133
Differences Between Debug Functions and C........................................................... 147
Differences Between dScope and the µVision2 Debugger ....................................... 148