uv2 v2 guide

8
IDE for Microcontrollers IDE for Microcontrollers Quick Start Quick Start μVision2, the IDE from Keil Software, combines Project Management, Source Code Editing, and Program Debugging in one powerful environment. This Quick Start guide gives you the information necessary to use μVision2 for your own projects. It provides a step-by-step introduction of the most commonly used μVision2 features including: Project Setup for the Make and Build Process Editor facilities for Modifying and Correcting Source Code Program Debugging and Additional Test Utilities new n n n Project Manager Editor & Debugger Output Window Peripheral Dialog Project Window Work- space Watch Window and Call Stack Memory Window TM

Upload: radhika

Post on 05-Feb-2016

238 views

Category:

Documents


0 download

DESCRIPTION

microvision microcontroller program book

TRANSCRIPT

Page 1: Uv2 v2 Guide

IDE forMicrocontrollers

IDE forMicrocontrollers

Quick StartQuick Start

µVision2, the IDE from Keil Software, combines ProjectManagement, Source Code Editing, and Program Debugging inone powerful environment. This Quick Start guide gives you theinformation necessary to use µVision2 for your own projects. Itprovides a step-by-step introduction of the most commonly usedµVision2 features including:

Project Setup for the Make and Build ProcessEditor facilities for Modifying and Correcting Source CodeProgram Debugging and Additional Test Utilities

new

Project ManagerEditor & Debugger

OutputWindow

PeripheralDialog

ProjectWindow

Work-space

WatchWindowand CallStack

MemoryWindow

TM

Page 2: Uv2 v2 Guide

PROJECTS

2

Project Management

Device Database

Getting Help

µVision2 now includes several robust featuresto make project management easier than ever.

The Device Database makes it easy to startwriting programs for a particular CPU. Justselect the microcontroller you use andµVision2 sets the necessary optionsautomatically. Since µVision2 alreadyincludes numerous devices in its database, toolsetup is fast and easy. You may add newdevices to the database as the need arises.

µVision2 provides a Books tab in the Projectwindow where extensive on-line manuals forthe toolchain and selected CPU are found.You may double-click on a book title to openthe on-line manual.

Most dialogs have a help buttonwhich provides detailed information about thedialog controls. To get help on menu items,select the item and press F1.

File Groups

Project Targets

let you group associated filestogether in a project. This is useful forgrouping files into functional blocks or foridentifying engineers in your software team.

let you create severalprograms from a single project. You may needone target for testing and another target for arelease version of your application. Eachtarget allows individual tool settings within thesame project file.

The provides access to alldialogs for project management including...

which creates a new project.

which addcomponents to a project. Local menus in theProject window let you add files to the project.

which opens an existingproject. Note that the Quick Start examplesare based on the measure project files locatedin .

and openthe local menu. Then, use .

Project menu

New Project...

Targets, Groups, Files...

Open Project...

EXAMPLES\MEASURE

Select Device

To choose a device for a project, point to thetarget name in the Project window

What’s this

The Files tab in the Project windowdisplays the currently selectedtarget along with groups and files.You may drag & drop files withinthis window.

The local menu opens when youclick the right mouse button.Here, you may set options fortargets, groups, and files.

Generic devices may beused if a specific device isnot available in the database.

The Books tab in the Projectwindow lists the on-linemanuals that are available.

Page 3: Uv2 v2 Guide

OPTIONS & MAKE

3

Tool Options

Build Project

µVision2 lets you set the options for all files ina target, a group, or even a single source file.The options dialog opens via the local menu inthe Project window. In the Target page of thisdialog, you may specify the CPU and memoryparameters of the target system. µVision2 usesthis information to configure basic tool optionsincluding the linker/locater settings and thesimulator driver.

The Output page defines the output filesgenerated by the assembler, compiler, andlinker. The Listing page lets you configure thelisting files. The C166, A166, and L166 pageslet you enter tool-specific options (like#defines) and display the current tool settings.The Debug page configures the µVision2Debugger.

The toolchain stores include and source filedependencies. This information is used duringthe make process to build only those files thathave changed. Optionally, incremental re-translations are performed when globaloptimizing is enabled.

You can quickly open thefor the selected target using the toolbar

button. In the target dialog, specify thememory model along with CPU and memoryparameters. Enter the off-chip memoryaddress ranges under . Tobegin a new project, the settings of the targetpage are all you need!

µVision2 insert or configure your Cstartup files. Configuring the startup code isdescribed in the C Compiler User’s Guide andshould reflect the settings of the Target page.

Target OptionsDialog

External Memory

NOTEdoes not

Start compiling and assembling your targetapplication with the button onthe toolbar.

The Build page of the output window lists toolinformation during the code generation. Youmay double-click on error messages to correctsyntax errors in your program. Errors arecorrectly located even after you insert ordelete source lines.

Build Target

Select current Target

of theproject

StopBuild

Process

RebuildTarget

BuildTarget

Translatecurrent file

Target Options

Dialog

Double-click on syntax errors to position thecursor on the erroneous line in the source.

ROM specifies areas for code and constants.RAM defines the address range for variables.

Specify the usage ofintegrated on-chipmicrocontrollercomponents.

Build Toolbar

Page 4: Uv2 v2 Guide

EDITOR

4

Source Code Editor

Breakpoints

Utilities

The µVision2 editor includes all the standardfeatures you are accustomed to. Color syntaxhighlighting and text indentation are optimizedfor editing C source code. Most editorfunctions may be quickly accessed from thetoolbar. The editor is available whiledebugging your program. This gives you anatural debugging environment that lets youquickly correct your source code.

µVision2 marks the status of the source lines inthe column of the editor window.This provides a quick overview of the currentbreakpoint settings.

Double-click in the Files page of the ProjectWindow to open a selected source file. Then,use the Workbook navigation bar to quicklyselect editor windows. Enable

from the menu.Workbook

Mode View

µVision2 lets you set program breakpointswhile writing your source text. Simply use thebuttons on the to markbreakpoints on source lines. After making yourprogram, you can start the Debugger with the

toolbar button. Breakpoints you haveset while editing are activated in yourdebugging session.

Editor Toolbar

Debug

Attributes

In addition to its standard editor features,µVision2 contains many powerful functionsthat help you complete your projects on time.For example, the dialog performsa text search in all specified files. The searchresults are displayed in the Find in Files pageof the Output window. You can use this featureto locate all uses of a function or variable.

Find in Files

Saveall files

Open

file

Newfile

Savefile

CutCopy

Paste

UndoRedo

Indent

Unindent

ToggleBookm

ark

Next Bookmark

PreviousBookm

ark

Clear all Bookmarks

Findin

Files

SearchText

FindPrint

Project Window

Output W

indow

ToggleBreak

Enable/Disable

Debug

Kill all Breaks

Disableall

Editor Toolbar

Workbook bar for quick document selection

Bookmark

Code already executed

No Executable Code

Enabled Breakpoint

Attributes

Current PC, next statement

Disabled Breakpoint

Selected line from Output Window

Code is not executed

Search Text

Double-click to position the cursor onthe line with the matching string.

Page 5: Uv2 v2 Guide

DEBUGGER

5

Code Execution

Watch Window

Memory Window

Code Coverage

You may use buttons on the toolbar to stepthrough your application program. Thebutton executes code until a breakpoint isreached. When is enabled,the button lists the last1024 instructions that were executed. Tracerecording lets you analyze the program flowprior to a breakpoint.

Run

Trace RecordingShow Trace Records

The Locals page of the Watch Windowdisplays the values of automatic variables inthe current function. The value of a variablecan be changed as follows:

Select the value with a mouse click.Wait a second.Another mouse click enters edit mode.

The Memory Window displays two differentmemory areas. Double click to open an editbox to change the memory contents.

You can use this technique to edit variables inother Watch pages. The Call Stack page liststhe program call tree; a double click shows thefunction invocation in the editor window.

The Code Coverage Window shows you thepercentage of instructions in your program thathave been executed. This aids in debuggingand testing. It lets you easily distinguish theparts of your program that have been executedfrom the parts that have not. You may thenchange your testing strategy to ensure that allprogram paths are traveled and tested.

Reset CPU

RunHalt Execution

SingleStep

Into

StepO

ver

StepO

ut

Runtill Cursor line

Shownext statem

ent

EnableTrace

Recording.

ShowTrace

Records

Disassembly

Window

Watch

Window

CodeCoverage

Window

Mem

oryW

indow

Toolbox

Serial Window

#1

Performance

Analyzer

Debug Toolbar

Trace history shows the last1024 instructions that were executed.

Local menus let you select display formats.

Code coverage displays statistical information andhelps you locate un-executed program sections.

Page 6: Uv2 v2 Guide

SIMULATOR

6

Peripheral Simulation

Serial Window

Performance Analyzer

µVision2 simulates the on-chip peripherals ofnumerous microcontrollers. When you select aCPU from the device database to configureyour project, µVision2 automaticallyconfigures the peripheral simulator for you.With its logical and timing simulation, it ispossible to test an application before the targethardware is even available. The simulatormakes it easy to test hardware defects andcritical situations which are difficult to debugwith real hardware.

The Serial Window provides a terminalsimulator for the on-chip UART. HEX andASCII modes may be selected via the localmenu. For devices with two serial interfaces asecond Serial Window is available. The SerialWindows are convenient to use for printf testoutputs in your application programs.

Peripheral dialog boxes, available withcommands in the menu, let you reviewand modify the status of on-chip componentsincluding system and BUS configuration. Allinterrupts, including timers, are simulated.

You may enter I/O port values in thedialog pages. If an I/O pin is configured

as an interrupt input, the interrupt serviceroutine is serviced. In the

dialog, you may enter the inputvoltage for the analog inputs of the CPU.µVision2 simulates the conversion time and theinterrupt of the on-chip A/D converter.

Debug

ParallelPort

Analog/DigitalConverter

The built-in performance analyzer records anddisplays execution times for functions andprogram blocks you select. A bar graphdisplays the amount of CPU time spent in eachpart of your program.

You can use the information gathered by theperformance analyzer to determine where yourprogram spends most of its time. Then, youcan concentrate your efforts on making thatsection faster.

You may supply I/O pin valuesin the peripheral dialog boxes.

Select the Serial Window and enterASCII characters for UART input.

Select a function or block for detailed statistics. Use themenu for configuration.Debug - Performance Analyzer

Page 7: Uv2 v2 Guide

ADVANCED FEATURES

7

Complex Breakpoints

Function Language

Toolbox

Target Monitor

µVision2 allows breakpoints on C statements,assembly instructions, conditional expressions,and even on different types of memoryaccesses. Breakpoints may include a countwhich is decreased until the breakpoint istriggered. A command may be executed whenthe breakpoint is triggered. If no command isspecified, program execution stops.

µVision2 incorporates a C-like functionlanguage that lets you generate and use:

The dialog contains user-configurablebuttons. Click on a Toolbox button to executethe associated command. Toolbox buttonsmay be executed at any time, even whilerunning the test program.

The µVision2 debugger communicates withyour target hardware and the Keil Monitorprogram to help you easily debug yourapplications in real-time. You can single-stepthrough program code, check variables, setbreakpoints, examine memory contents, andmore! The Keil Monitor comes pre-installedon many evaluation boards.

You may use the command fromthe Debug menu to set breakpoint definitions.

The command string may invoke debugfunctions when a breakpoint is triggered.

Breakpoint

Toolbox

Built-in functions like printf, memset, rand,and other useful routines.

Signal functions to simulate analog anddigital inputs to the CPU.

User functions to extend the commandscope and combine repetitive actions.

You may use the function language to describethe behavior of external hardware componentsor to supply input values to the controller I/Opins. Signal functions run in the backgroundwhile µVision2 simulates your target program.Therefore, signal functions must call the

function to let your target program run.twatch

Select toconnect to a Monitor board.

Use Target Debugger

Using toolbox buttons, functionscan be called at any time, evenduring program execution.

Enable and disable breakpointswith convenient check boxes.

Create Debug Functions with thedialog.Debug - Function Editor

Toolbox buttons are definedin the Command page of the output window.

/* Toggle Port P2.0 and Set P2.8 */

FUNC void SetP28_ToggleP20 (void) {PORT2 ^= 0x0001; /* invert value on Port2.0 */PORT2 |= 0x0100; /* set bit Port2.8 */

}

/* Simulate analog input ramp on analog input AIN0 */

SIGNAL void analog0 (float limit) {float volts;

printf ("ANALOG0 (%f) ENTERED\n", limit);while (1) { /* forever */

volts = 0;while (volts <= limit) {

AIN0 = volts; /* analog input 0 */twatch (30000); /* 30000 Cycles Time-Break */volts += 0.5; /* increase voltage */

}}

}

Page 8: Uv2 v2 Guide

IDE forMicrocontrollers

Quick Start

SHORTCUTS

8

The following table lists important shortcut keys forµVision2:

Copyright © 1998-2000 Keil Elektronik GmbH & Keil Software, Inc. All rights reserved.Information in this data sheet is subject to change without notice and does not represent a commitment on the part of Keil Software, Inc.

Europe:

Support ++49 89 / 45 60 40 - 24FAX ++49 89 / 46 81 62Email [email protected]

[email protected]

United States:

972-312-1107FAX 972-312-1159Email [email protected]

[email protected]

Keil Elektronik GmbHBretonischer Ring 1585630 GrasbrunnGermany

Keil Software, Inc.1501 10th Street, Suite 110Plano, TX 75074USA

Phone ++49 89 / 45 60 40 - 0 Phone 800-348-8051

TM

http://www.keil.com

Key Function

Ctrl+NCtrl+OCtrl+PCtrl+S

F11

Create new fileOpen an existing filePrint current documentSave current document

Single-step into a function

F5Ctrl+F5F7Ctrl+F7Alt+F7F10Ctrl+F10

Ctrl+F11

E D I T O R K E Y S

Ctrl+ACtrl+CCtrl+FCtrl+HCtrl+VCtrl+XCtrl+YCtrl+ZCtrl+[Shift+Ctrl+ZCtrl+HomeCtrl+EndCtrl+Ctrl+Ctrl+F2F2Shift+F2F3Shift+F3Ctrl+F3

Go (execute) until the next active breakpointStart/stop debug sessionBuild projectCompile current fileOpen project options dialog boxSingle-step over a functionGo (execute) to the current cursor line

Step out of the current function

Select all textCopy selected text to the clipboardFind textReplace textPaste text from the clipboardCut selected text to the clipboardCut line to the clipboardUndo last operationFind matching braceRedo last Undo commandMove the cursor to beginning of fileMove the cursor to end of fileMove cursor one word leftMove cursor one word rightSet bookmark on current lineMove cursor to next bookmarkMove cursor to previous bookmarkRepeat search text forwardRepeat search text backwardSearch for word under cursor

Example Programs

Example programs are found in thefolder. Each program is stored in a separate folderalong with a project file that will help you quickly buildand evaluate the example.

Many of the example project files contain severaltargets with different configurations. Refer to thedocument for a detailed description.

EXAMPLES

ABSTRACT.TXT

Example Description

BADCODE Program with syntax errors and warnings.You may use the editor to correct these.

CSAMPLE

DHRY

HELLO

MEASURE

RTX_EX1

RTX_EX2

SIEVE

TRAFFIC

Simple calculator which shows how tobuild a multi-module project withµVision2.

Dhrystone benchmark. Calculates thedhrystones factor for the target CPU.

Hello world program. Try this first whenyou begin using µVision2. It prints

on the serial interface and helpsyou confirm that the development toolswork correctly.

Data acquisition system for analog anddigital signals.

RTX51 example. Demonstrates round-robin multitasking with the RTX real-timekernel.

RTX51 application that uses signals fortask communication.

Benchmark that calculates primenumbers.

Traffic light controller using the RTX real-

HelloWorld

Contact your local distributor for more information about our other embedded systems development tools and products.

Evaluation software and detailed technical information are available from your distributor and our World Wide Web site (www.keil.com).

Keil Elektronik GmbH Keil Software, Inc.and , have representatives in the following countries:

Australia, Austria, Belgium, Brazil, Canada, Czech, China, Denmark, Finland, France, Germany, Hong Kong, India, Ireland, Israel, Italy, Japan, Korea,Mexico, Netherlands, Norway, Poland, Russia, Spain, Singapore, South Africa, Sweden, Switzerland, Taiwan, United Kingdom, and United States.

Contact Keil Elektronik GmbH or Keil Software, Inc., for the distributor nearest you.