- •Preface
- •Document Conventions
- •Contents
- •Chapter 1. Introduction
- •Manual Topics
- •Changes to the Documentation
- •Evaluation Kits and Production Kits
- •Types of Users
- •Requesting Assistance
- •Software Development Cycle
- •Product Overview
- •Chapter 2. Installation
- •System Requirements
- •Installation Details
- •Folder Structure
- •Chapter 3. Development Tools
- •C51 Optimizing C Cross Compiler
- •A51 Macro Assembler
- •BL51 Code Banking Linker/Locator
- •LIB51 Library Manager
- •OC51 Banked Object File Converter
- •Chapter 4. Creating Applications
- •Creating Projects
- •Project Targets and File Groups
- •Overview of Configuration Dialogs
- •Code Banking
- •µVision2 Utilities
- •Writing Optimum Code
- •Tips and Tricks
- •Chapter 5. Testing Programs
- •µVision2 Debugger
- •Debug Commands
- •Expressions
- •Tips and Tricks
- •Chapter 6. µVision2 Debug Functions
- •Creating Functions
- •Invoking Functions
- •Function Classes
- •Chapter 7. Sample Programs
- •HELLO: Your First 8051 C Program
- •Introduction
- •RTX51 Technical Data
- •Overview of RTX51 Routines
- •TRAFFIC: RTX-51 Tiny Example Program
- •RTX Kernel Aware Debugging
- •Chapter 9. Using On-chip Peripherals
- •Special Function Registers
- •Register Banks
- •Interrupt Service Routines
- •Interrupt Enable Registers
- •Parallel Port I/O
- •Timers/Counters
- •Serial Interface
- •Watchdog Timer
- •D/A Converter
- •A/D Converter
- •Power Reduction Modes
- •Chapter 10. CPU and C Startup Code
- •Caveats
- •Hardware and Software Requirements
- •Serial Transmission Line
- •µVision2 Monitor Driver
- •µVision2 Restrictions when using Monitor-51
- •Monitor-51 Configuration
- •Troubleshooting
- •Debugging with Monitor-51
- •Chapter 12. Command Reference
- •µVision 2 Command Line Invocation
- •A51 / A251 Macro Assembler Directives
- •C51/C251 Compiler
- •LIB51 / L251 Library Manager Commands
- •OC51 Banked Object File Converter
- •Index
Getting Started
with µVision2
and the C51 Microcontroller
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.
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.
NOTE
This manual assumes that you are familiar with Microsoft Windows and the hardware and instruction set of the 8051 microcontrollers.
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: |
|
Courier
Variables
Elements that repeat…
Omitted code
:
:
Optional Items
{ opt1 | opt2 }
Keys
Point
Click
Drag
Double-Click
CLS |
DIR |
BL51.EXE |
Note that you are not required to enter these commands using all capital letters.
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.
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. Ellipses (…) are used to indicate an item that may be repeated.
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);
Double brackets indicate optional items in command lines and input fields. For example:
C51 TEST.C PRINT (filename)
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.
Text in this sans serif typeface represents actual keys on the keyboard. For example, “Press Enter to continue.”
Move the mouse until the mouse pointer rests on the item desired.
Quickly press and release a mouse button while pointing at the item to be selected.
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.
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 |
6 Contents
Chapter 7. Sample Programs......................................................................... |
149 |
HELLO: Your First 8051 C Program....................................................................... |
150 |
MEASURE: A Remote Measurement System ......................................................... |
155 |
Chapter 8. RTX-51 Real-Time Operating System....................................... |
169 |
Introduction............................................................................................................... |
169 |
RTX51 Technical Data ............................................................................................. |
173 |
Overview of RTX51 Routines................................................................................... |
174 |
TRAFFIC: RTX-51 Tiny Example Program............................................................ |
176 |
RTX Kernel Aware Debugging................................................................................. |
180 |
Chapter 9. Using On-chip Peripherals.......................................................... |
183 |
Special Function Registers........................................................................................ |
183 |
Register Banks .......................................................................................................... |
184 |
Interrupt Service Routines......................................................................................... |
185 |
Interrupt Enable Registers......................................................................................... |
187 |
Parallel Port I/O ........................................................................................................ |
187 |
Timers/Counters........................................................................................................ |
189 |
Serial Interface .......................................................................................................... |
190 |
Watchdog Timer ....................................................................................................... |
193 |
D/A Converter........................................................................................................... |
194 |
A/D Converter........................................................................................................... |
195 |
Power Reduction Modes ........................................................................................... |
196 |
Chapter 10. CPU and C Startup Code.......................................................... |
197 |
Chapter 11. Using Monitor-51 ....................................................................... |
199 |
Caveats...................................................................................................................... |
199 |
Hardware and Software Requirements...................................................................... |
200 |
Serial Transmission Line........................................................................................... |
201 |
µVision2 Monitor Driver .......................................................................................... |
201 |
µVision2 Restrictions when using Monitor-51 ......................................................... |
202 |
Tool Configuration when Using Monitor-51............................................................. |
204 |
Monitor-51 Configuration......................................................................................... |
206 |
Troubleshooting ........................................................................................................ |
208 |
Debugging with Monitor-51...................................................................................... |
209 |
Chapter 12. Command Reference ................................................................. |
211 |
µVision 2 Command Line Invocation ....................................................................... |
211 |
A51 / A251 Macro Assembler Directives ................................................................. |
212 |
C51/C251 Compiler .................................................................................................. |
213 |
L51/BL51 Linker/Locator......................................................................................... |
215 |
L251 Linker/Locator ................................................................................................. |
216 |
LIB51 / L251 Library Manager Commands.............................................................. |
218 |
OC51 Banked Object File Converter ........................................................................ |
219 |
OH51 Object-Hex Converter .................................................................................... |
219 |
OH251 Object-Hex Converter .................................................................................. |
219 |
Getting Started and Creating Applications |
7 |
Index.................................................................................................................. |
222 |