ANALOG DEVICES W3.5 Started Guide

W3.5
Getting Started Guide
for 16-Bit Processors
Analog Devices, Inc. One Technology Way Norwood, Mass. 02062-9106
Revision 1.0, October 2003
Part Number
82-000035-05
a
Copyright Information
©1996–2003 Analog Devices, Inc., ALL RIGHTS RESERVED. This document may not be reproduced in any form without prior, express writ­ten consent from Analog Devices, Inc.
Printed in the USA.
Disclaimer
Analog Devices, Inc. reserves the right to change this product without prior notice. Information furnished by Analog Devices is believed to be accurate and reliable. However, no responsibility is assumed by Analog Devices for its use; nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted by impli­cation or otherwise under the patent rights of Analog Devices, Inc.
Trademark and Service Mark Notice
The Analog Devices logo and Blackfin are registered trademarks and VisualDSP++ and the VisualDSP++ logo are trademarks of Analog Devices, Inc.
All other brand and product names are trademarks or service marks of their respective owners.

Contents

PREFACE
Purpose of This Manual ................................................................. vii
Intended Audience ......................................................................... vii
Manual Contents .......................................................................... viii
What’s New in This Manual .......................................................... viii
Technical or Customer Support ....................................................... ix
Supported Processors ....................................................................... ix
Product Information ........................................................................ x
MyAnalog.com ........................................................................... x
DSP Product Information .......................................................... xi
Related Documents .................................................................. xii
Online Technical Documentation ............................................. xii
From VisualDSP++ ............................................................. xiii
From Windows ................................................................... xiii
From the Web ...................................................................... xiv
Printed Manuals ........................................................................ xv
VisualDSP++ Documentation Set .......................................... xv
Hardware Manuals ................................................................ xv
Data Sheets ........................................................................... xv
VisualDSP++ 3.5 Getting Started Guide iii for 16-Bit Processors
CONTENTS
Contacting DSP Publications ................................................... xvi
Notation Conventions .................................................................. xvii
FEATURES AND TOOLS
VisualDSP++ Features .................................................................. 1-1
New Features in Release 3.5 .......................................................... 1-5
Code Development Tools .............................................................. 1-7
BASIC TUTORIAL
Overview ...................................................................................... 2-1
Exercise One: Building and Running a C Program ......................... 2-3
Step 1: Start VisualDSP++ and Open a Project ......................... 2-4
Step 2: Build the dotprodc Project ........................................... 2-7
Step 3: Run the Program ....................................................... 2-10
Step 4: Run dotprodc ............................................................ 2-15
Exercise Two: Modifying a C Program to Call an
Assembly Routine .................................................................... 2-16
Step 1: Create a New Project ................................................. 2-16
Step 2: Add Source Files to dot_product_asm ........................ 2-21
Step 3: Create a Linker Description File for the Project .......... 2-22
Step 4: Modify the Project Source Files .................................. 2-27
Step 5: Use the Expert Linker to modify dot_prod_asm.ldf .... 2-31
Step 6: Rebuild and Run dot_product_asm ............................ 2-34
Exercise Three: Plotting Data ...................................................... 2-36
Step 1: Load the FIR Program ............................................... 2-36
Step 2: Open a Plot Window ................................................. 2-38
iv VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
CONTENTS
Step 3: Run the FIR Program and View the Data ................... 2-41
Exercise Four: Linear Profiling ..................................................... 2-50
Step 1: Load the FIR Program ................................................ 2-50
Step 2: Open the Profiling Window ....................................... 2-51
Step 3: Collect and Examine the Linear Profile Data ............... 2-53
Exercise Five: Installing and Using a VCSE Component ............... 2-56
Step 1: Start VisualDSP++ and Open the Project .................... 2-56
Step 2: Install the EXAMPLES::CULawc Component on
Your System ........................................................................ 2-58
Step 3: Add the Component to Your Project ........................... 2-61
Step 4: Build and Run the Program ........................................ 2-62
ADVANCED TUTORIAL
Overview ...................................................................................... 3-1
Exercise One: Using Profile-Guided Optimization ......................... 3-2
Step 1: Load the Project ........................................................... 3-4
Step 2: Configure a Data Set .................................................... 3-5
Step 3: Attach an Input Stream ................................................ 3-9
Step 4: Configure Additional Data Sets .................................. 3-13
Step 5: Create PGO Files and Optimize Your Program ........... 3-15
Step 6: Compare Execution Times ......................................... 3-16
Exercise Two: Using Background Telemetry Channel ................... 3-19
Adding BTC to Your DSP Application ................................... 3-20
Running the BTC Assembly Demo ........................................ 3-22
Step 1: Load the Btc_AsmDemo Project ............................ 3-23
VisualDSP++ 3.5 Getting Started Guide v for 16-Bit Processors
CONTENTS
Step 2: Examine the BTC Commands ............................... 3-23
Step 3: Set Up the BTC Memory Window and View Data 3-26
Running the BTC FFT Demo ............................................... 3-34
Step 1: Build the FFT Demo ............................................. 3-34
Step 2: Plot BTC Data ...................................................... 3-35
Step 3: Record and Analyze BTC Data .............................. 3-40
INDEX
vi VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors

PREFACE

Thank you for purchasing VisualDSP++™, the development software for Analog Devices processors.

Purpose of This Manual

The VisualDSP++ 3.5 Getting Started Guide for 16-Bit Processors provides basic and advanced tutorials that highlight many VisualDSP++ features. By completing the step-by-step procedures, you will become familiar with the VisualDSP++ environment and learn how to use these features in your own digital signal processing (DSP) development projects.

Intended Audience

This manual is intended for DSP programmers who are familiar with Analog Devices processors. The manual assumes that the audience has a working knowledge of Analog Devices processor architecture and instruc­tion set.
DSP programmers who are unfamiliar with Analog Devices processors should refer to their processor’s Hardware Reference and Instruction Set Reference, which describe the processor architecture and instruction set. Note that the ADSP-BF533 Blackfin Processor Hardware Reference includes information about the ADSP-BF531 and ADSP-BF532 processors.
VisualDSP++ 3.5 Getting Started Guide vii for 16-Bit Processors

Manual Contents

Manual Contents
This guide contains the following chapters.
Chapter 1, “Features and Tools”
Provides an overview of VisualDSP++ features and code develop­ment tools
Chapter 2, “Basic Tutorial”
Provides step-by-step instructions for creating sessions, and for building and debugging projects by using examples of C/C++ and assembly sources
The tutorial is organized to follow the steps that you take in devel­oping a typical programming project. Before you begin actual programming, you should be familiar with the architecture of your particular processor and the other software development tools.
Chapter 3, “Advanced Tutorial”
Provides step-by-step instructions for using profile-guided optimization (PGO) and background telemetry channel (BTC).

What’s New in This Manual

A new “Advanced Tutorial” chapter has been added to the guide. This chapter covers some of the more advanced VisualDSP++ features and techniques.
viii VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors

Technical or Customer Support

You can reach DSP Tools Support in the following ways.
Visit the DSP Development Tools website at
http://www.analog.com/technology/dsp/developmentTools/index.html
Email questions to
dsptools.support@analog.com
Phone questions to 1-800-ANALOGD
Contact your ADI local sales office or authorized distributor
Send questions by mail to:
Analog Devices, Inc. One Technology Way P.O. Box 9106 Norwood, MA 02062-9106 USA
Preface

Supported Processors

The name “Blackfin” refers to a family of Analog Devices 16-bit, embed­ded processors. VisualDSP++ currently supports the following Blackfin processors.
ADSP-BF531 ADSP-BF532 (formerly ADSP-21532)
ADSP-BF533 ADSP-BF535 (formerly ADSP-21535)
ADSP-BF561 AD6532
VisualDSP++ 3.5 Getting Started Guide ix for 16-Bit Processors

Product Information

VisualDSP++ currently supports the following ADSP-21xx processors.
ADSP-2181 ADSP-2191
ADSP-2183 ADSP-2192-12
ADSP-2184/84L/84N ADSP-2195
ADSP-2185/85L/85M/85N ADSP-2196
ADSP-2186/86L/86M/86N ADSP-21990
ADSP-2187L/87N ADSP-21991
ADSP-2188L/88N ADSP-21992
ADSP-2189M/89N
Product Information
You can obtain product information from the Analog Devices website, from the product CD-ROM, or from the printed publications (manuals).
Analog Devices is online at www.analog.com. Our website provides infor­mation about a broad range of products—analog integrated circuits, amplifiers, converters, and digital signal processors.

MyAnalog.com

MyAnalog.com is a free feature of the Analog Devices website that allows
customization of a webpage to display only the latest information on products you are interested in. You can also choose to receive weekly email notification containing updates to the webpages that meet your interests.
MyAnalog.com provides access to books, application notes, data sheets,
code examples, and more.
x VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Preface
Registration:
Visit
www.myanalog.com to sign up. Click Register to use MyAnalog.com.
Registration takes about five minutes and serves as means for you to select the information you want to receive.
If you are already a registered user, just log on. Your user name is your email address.

DSP Product Information

For information on digital signal processors, visit our website at
www.analog.com/dsp, which provides access to technical publications, data
sheets, application notes, product overviews, and product announcements.
You may also obtain additional information about Analog Devices and its products in any of the following ways.
Email questions or requests for information to
dsp.support@analog.com
Fax questions or requests for information to
1-781-461-3010 (North America) 089/76 903-557 (Europe)
Access the Digital Signal Processing Division’s FTP website at
ftp ftp.analog.com or ftp 137.71.23.21 ftp://ftp.analog.com
VisualDSP++ 3.5 Getting Started Guide xi for 16-Bit Processors
Product Information

Related Documents

For information on product related development software, see the follow­ing publications.
VisualDSP++ 3.5 User’s Guide for 16-Bit Processors
VisualDSP++ 3.5 C/C++ Compiler and Library Manual for Blackfin Processors
VisualDSP++ 3.5 C Compiler and Library Manual for ADSP-218x Processors
VisualDSP++ 3.5 C/C++ Compiler and Library Manual for ADSP-219x Processors
VisualDSP++ 3.5 Assembler and Preprocessor Manual for Blackfin Processors
VisualDSP++ 3.5 Assembler and Preprocessor Manual for ADSP-21xx Processors
VisualDSP++ 3.5 Linker and Utilities Manual for 16-Bit Processors
VisualDSP++ 3.5 Loader Manual for 16-Bit Processors
VisualDSP++ 3.5 Product Bulletin
VisualDSP++ Kernel (VDK) User’s Guide
VisualDSP++ Component Software Engineering User’s Guide
Quick Installation Reference Card
For hardware information, refer to your processor’s Hardware Reference, Programming Reference, and data sheet.
All documentation is available online. Most documentation is available in printed form.

Online Technical Documentation

Online documentation comprises VisualDSP++ Help system and tools manuals, Dinkum Abridged C++ library and FlexLM network license manager software documentation. You can easily search across the entire VisualDSP++ documentation set for any topic of interest. For easy print­ing, supplementary
xii VisualDSP++ 3.5 Getting Started Guide
.PDF files for the tools manuals are also provided.
for 16-Bit Processors
Preface
A description of each documentation file type is as follows.
File Description
.CHM Help system files and VisualDSP++ tools manuals.
.HTML Dinkum Abridged C++ library and FlexLM network license manager software doc-
umentation. Viewing and printing the net Explorer 4.0 (or higher).
.PDF VisualDSP++ tools manuals in Portable Documentation Format, one .PDF file for
each manual. Viewing and printing the .PDF files require a PDF reader, such as Adobe Acrobat Reader (4.0 or higher).
.HTML files require a browser, such as Inter-
If documentation is not installed on your system as part of the software installation, you can add it from the VisualDSP++ CD-ROM at any time by rerunning the Tools installation.
Access the online documentation from the VisualDSP++ environment, Windows Explorer, or Analog Devices website.
From VisualDSP++
Access VisualDSP++ online Help from the Help menu’s Contents, Search, and Index commands.
Open online Help from context-sensitive user interface items (tool­bar buttons, menu commands, and windows).
From Windows
In addition to any shortcuts you may have constructed, there are many ways to open VisualDSP++ online Help or the supplementary documenta­tion from Windows.
VisualDSP++ 3.5 Getting Started Guide xiii for 16-Bit Processors
Product Information
Help system files (.
CHM files) are located in the Help folder, and .PDF files
are located in the Docs folder of your VisualDSP++ installation. The Docs folder also contains the Dinkum Abridged C++ library and FlexLM net­work license manager software documentation.
Using Windows Explorer
Double-click any file that is part of the VisualDSP++ documenta­tion set.
Double-click the vdsp-help.chm file, which is the master Help sys­tem, to access all the other .CHM files.
Using the Windows Start Button
Access VisualDSP++ online Help by clicking the Start button and choosing Programs, VisualDSP, and VisualDSP++ Documentation.
Access the .PDF files by clicking the Start button and choosing Programs, VisualDSP, Documentation for Printing, and the name of the book.
From the Web
To download the tools manuals, point your browser at:
www.analog.com/technology/dsp/developmentTools/gen_purpose.html
Select a DSP family and book title. Download archive (.ZIP) files, one for each manual. Use any archive management software, such as WinZip, to decompress downloaded files.
xiv VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Preface

Printed Manuals

For general questions regarding literature ordering, call the Literature Center at 1-800-ANALOGD (1-800-262-5643) and follow the prompts.
VisualDSP++ Documentation Set
VisualDSP++ manuals may be purchased through Analog Devices Cus­tomer Service at 1-781-329-4700; ask for a Customer Service representative. The manuals can be purchased only as a kit. For additional information, call 1-603-883-2430.
If you do not have an account with Analog Devices, you will be referred to Analog Devices distributors. To get information on our distributors, log onto http://www.analog.com/salesdir/continent.asp.
Hardware Manuals
Hardware reference and instruction set reference manuals can be ordered through the Literature Center or downloaded from the Analog Devices website. The phone number is 1-800-ANALOGD (1-800-262-5643). The manuals can be ordered by a title or by product number located on the back cover of each manual.
Data Sheets
All data sheets can be downloaded from the Analog Devices website. As a general rule, any data sheet with a letter suffix (L, M, N) can be obtained from the Literature Center at 1-800-ANALOGD (1-800-262-5643) or downloaded from the website. Data sheets without the suffix can be downloaded from the website only—no hard copies are available. You can ask for the data sheet by a part name or by product number.
VisualDSP++ 3.5 Getting Started Guide xv for 16-Bit Processors
Product Information
If you want to have a data sheet faxed to you, the phone number for that service is 1-800-446-6212. Follow the prompts and a list of data sheet code numbers will be faxed to you. Call the Literature Center first to find out if requested data sheets are available.

Contacting DSP Publications

Please send your comments and recommendations for improving our manuals and online Help. You can contact us by sending an email to:
dsp.techpubs@analog.com
xvi VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors

Notation Conventions

The following table identifies and describes text conventions used in this manual.
Preface
L
Example Description
Close command (File menu) or OK
{this | that} Alternative required items in syntax descriptions appear within curly
[this | that] Optional items in syntax descriptions appear within brackets and sepa-
[this,…] Optional item lists in syntax descriptions appear within brackets
.SECTION Registers, commands, directives, keywords, code examples, and feature
filename Non-keyword placeholders appear in text with italic style format.
appear throughout this document.
Te x t i n bold style indicates the location of an item within the VisualDSP++ environment’s menu system. For example, the Close command appears on the File menu.
brackets and separated by vertical bars; read the example as
that.
rated by vertical bars; read the example as an optional this or that.
delimited by commas and terminated with an ellipsis; read the example as an optional comma-separated list of
names are in text with letter gothic font.
A note, providing information of special interest or identifying a related topic. In the online version of this book, the word Note appears instead of this symbol.
this or
this.
Additional conventions, which apply only to specific chapters, may
A caution, providing information about critical design or program­ming issues that influence operation of a product. In the online version of this book, the word Caution appears instead of this symbol.
VisualDSP++ 3.5 Getting Started Guide xvii for 16-Bit Processors
Notation Conventions
xviii VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors

1 FEATURES AND TOOLS

This chapter contains the following topics.
“VisualDSP++ Features” on page 1-1
“New Features in Release 3.5” on page 1-5
“Code Development Tools” on page 1-7

VisualDSP++ Features

VisualDSP++ provides the following features.
Extensive editing capabilities. Create and modify source files by using multiple language syntax highlighting, drag-and-drop, book­marks, and other standard editing operations. View files generated by the code development tools.
Flexible project management. Specify a project definition that identifies the files, dependencies, and tools that you will use to build projects. Create this project definition once or modify it to meet changing development needs.
VisualDSP++ 3.5 Getting Started Guide 1-1 for 16-Bit Processors
VisualDSP++ Features
Easy access to code development tools. Analog Devices provides these code development tools: C/C++ compiler, assembler, linker, splitter, and loader. Specify options for these tools by using dialog boxes instead of complicated command line scripts. Options that control how the tools process inputs and generate outputs have a one-to-one correspondence to command line switches. Define options for a single file or for an entire project. Define these options once or modify them as necessary.
Flexible project build options. Control builds at the file or project level. VisualDSP++ enables you to build files or projects selectively, update project dependencies, or incrementally build only the files that have changed since the previous build. View the status of your project build in progress. If the build reports an error, double-click on the file name in the error message to open that source file. Then correct the error, rebuild the file or project, and start a debug session.
VisualDSP++ Kernel (VDK) Support. Add VDK support to a project to structure and scale application development. The Kernel tab page of the Project window enables you to manipulate events, event bits, priorities, semaphores, and thread types.
Flexible workspace management. Create up to ten workspaces and quickly switch between them. Assigning a different project to each workspace enables you to build and debug multiple projects in a single session.
Easy movement between debug and build activities. You start the debug session and move freely between editing, build, and debug activities.
1-2 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Features and Tools
Figure 1-1 shows the Integrated Development and Debugging
Environment.

Figure 1-1. The VisualDSP++ IDDE

VisualDSP++ 3.5 Getting Started Guide 1-3 for 16-Bit Processors
VisualDSP++ Features
VisualDSP++ reduces your debugging time by providing these key features.
Easy-to-use debugging activities. Debug with one common, easy-to-use interface for all processor simulators and emulators, or hardware evaluation and development boards. Switch easily between these targets.
Multiple language support. Debug programs written in C, C++, or assembly, and view your program in machine code. For programs written in C/C++, you can view the source in C/C++ or mixed C/C++ and assembly, and display the values of local variables or evaluate expressions (global and local) based on the current context.
Effective debug control. Set breakpoints on symbols and addresses and then step through the program’s execution to find problems in coding logic. Set watchpoints (conditional breakpoints) on regis­ters, stacks, and memory locations to identify when they are accessed.
Tools for improving performance. Use the trace, profile, and lin­ear and statistical profiles to identify bottlenecks in your DSP application and to identify program optimization needs. Use plot­ting to view data arrays graphically. Generate interrupts, outputs, and inputs to simulate real-world application conditions.
1-4 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Features and Tools

New Features in Release 3.5

Release 3.5 includes the following new features and enhancements.
New processor support. The ADSP-BF561 processor is supported
by this software version. Refer to the ADSP-BF561 Blackfin Hard- ware Reference and chip data sheet for details.
Multiple project support. VisualDSP++ provides the ability to switch among multiple open projects in the same IDDE session. The Project window displays active projects.
Data streaming and logging. VisualDSP++ now offers the ability to stream and log data from a target DSP without halting the DSP. The IDDE takes advantage of this capability in plot windows. If the target supports background telemetry channel (BTC), the plot window is updated while the target is running.
License management in the IDDE. License management (installa­tion and validation) has been integrated into the VisualDSP++ IDDE. Installing a FlexLM license server is still handled by the separate instal­lation application.
Profile-guided optimization (PGO) in the IDDE. VisualDSP++ includes facilities to run common PGO scenarios simply and also pro­vides a mechanism for advanced applications that require more control over the profiling process via scripting. The techniques relies on setting up and executing data sets to produce an optimized application.
VisualDSP++ 3.5 Getting Started Guide 1-5 for 16-Bit Processors
New Features in Release 3.5
Integrated Source Code Control (SCC). VisualDSP++ uses the Microsoft Common Source Code Control (MCSCC) interface to pro­vide a connection from the IDDE to SCC applications (such as Visual SourceSafe, PVCS Version Manager, and ClearCase) installed on your machine. You can now conveniently access commonly-used SCC fea­tures from VisualDSP++ without leaving the IDDE. Advanced and application-specific SCC features not available from the IDDE must be run directly from the SCC applications.
Automation aware scripting engine. VisualDSP++ includes a script­ing engine that uses the Microsoft ActiveX script host framework. The engine enables you to use multiple scripting languages (such as VBScript, JavaScript, and so on) to access the VisualDSP++ Automa­tion API.
You can interact with the IDDE by using a single command or a script file similar to the Tcl scripting functionality, which was available in previous versions of VisualDSP++.
Profiling code with Expert Linker. You can use Expert Linker to profile object sections in a program. When the program halts, Expert Linker graphically displays how much time was spent in each object section. You can use this display to locate code “hotspots” and then move that code to faster, internal memory.
Address bar in Disassembly and Memory windows. When enabled, an address bar is displayed in Disassembly windows and memory win­dows. You can use the address bar to navigate by address, symbol, or expression. The address bar maintains a most recently used history of visited locations.
Menus with Icons. Icons now appear beside menu commands that have corresponding toolbar buttons.
1-6 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors

Code Development Tools

Code development tools for 16-bit processors include:
C/C++ compiler
Runtime library with over 100 math, DSP, and C runtime library routines
•Assembler
•Linker
Splitter
•Loader
Simulator
Features and Tools
Emulator (must be purchased separately from VisualDSP++)
These tools enable you to develop applications that take full advantage of your processor’s architecture.
The VisualDSP++ linker supports multiprocessing, shared memory, and memory overlays.
VisualDSP++ 3.5 Getting Started Guide 1-7 for 16-Bit Processors
Code Development Tools
The code development tools provide the following key features.
Easy-to-program C, C++, and assembly languages. Program in C/C++, assembly, or mix C/C++ and assembly in one source. The assembly language is based on an algebraic syntax that is easy to learn, program, and debug.
Flexible system definition. Define multiple types of executables for a single type of processor in one Linker Description File ( Specify input files, including objects, libraries, shared memory files, overlay files, and executables.
Support for overlays, multiprocessors, and shared memory exe- cutables. The linker places code and resolves symbols in multiprocessor memory space for use by multiprocessor systems. The loader enables you to configure multiprocessors with less code and faster boot time. Create host, link port, and PROM boot images.
.LDF).
Software and hardware tool kits include context-sensitive Help and manu­als in PDF format.
For details about assembly syntax, refer to the VisualDSP++ 3.5 Assembler and Preprocessor Manual for your target processor.
1-8 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors

2 BASIC TUTORIAL

This chapter contains the following topics.
“Overview” on page 2-1
“Exercise One: Building and Running a C Program” on page 2-3
“Exercise Two: Modifying a C Program to Call an Assembly Rou-
tine” on page 2-16
“Exercise Three: Plotting Data” on page 2-36
“Exercise Four: Linear Profiling” on page 2-50
“Exercise Five: Installing and Using a VCSE Component” on
page 2-56

Overview

The Basic Tutorial demonstrates key features and capabilities of the VisualDSP++ Integrated Development and Debugging Environment (IDDE). The exercises use sample programs written in C, C++, and assembly for Blackfin processors.
You can use different Blackfin processors with only minor changes to the Linker Description Files (.LDFs) included with each project. VisualDSP++ includes basic Linker Description Files for each processor type in the
folder
Program Files\Analog Devices\VisualDSP 3.5 16-Bit\Blackfin\ldf
VisualDSP++ 3.5 Getting Started Guide 2-1 for 16-Bit Processors
. For Blackfin processors, the folder’s default installation path is:
ldf
Overview
The source files for these exercises are installed during the VisualDSP++ software installation.
The tutorial contains five exercises:
•In Exercise One, you will start up VisualDSP++, build a project containing C source code, and profile the performance of a C function.
•In Exercise Two, you will create a new project, create a Linker Description File to link with the assembly routine, rebuild the project, and profile the performance of the assembly language routine.
•In Exercise Three, you will plot the various waveforms produced by a Finite Impulse Response (FIR) algorithm.
•In Exercise Four, you will use linear profiling to examine the effi- ciency of the FIR algorithm used in Exercise Three. Using the collected linear profile data, you will pinpoint the most time-con­suming areas of the algorithm, which are likely to require hand tuning in the assembly language.
•In Exercise Five, you will install a VCSE component on your sys- tem and add the component to the project. Then you will build and run the program with the component.
The ADSP-BF53x Family Simulator and ADSP-BF535 processor are used for all exercises.
Tip: Become familiar with the VisualDSP++ toolbar buttons, shown in
Figure 2-1 on page 2-3. They are shortcuts for menu commands such as
Open a file and Run a program. Toolbar buttons and menu commands that are not available for tasks that you want to perform are disabled and displayed in gray.
2-2 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors

Figure 2-1. VisualDSP++ Toolbar Buttons

Basic Tutorial
L
VisualDSP++ is a licensed software product. To run the software, you must have a valid license installed on your system. If you try to run VisualDSP++ and a license is not installed, a message window opens to let you add a license. For details about license manage­ment, see the VisualDSP++ 3.5 User’s Guide for 16-Bit Processors or the VisualDSP++ online Help.

Exercise One: Building and Running a C Program

In this exercise, you will:
Start up the VisualDSP++ environment
Open and build an existing project
Examine windows and dialog boxes
Run the program
The sources for this exercise are in the installation path is:
dot_product_c folder. The default
Program Files\Analog Devices\VisualDSP 3.5 16-Bit\Blackfin\
Examples\Tutorial\dot_product_c
VisualDSP++ 3.5 Getting Started Guide 2-3 for 16-Bit Processors
Exercise One: Building and Running a C Program

Step 1: Start VisualDSP++ and Open a Project

To start VisualDSP++ and open a project:
1. Click the Windows Start button and select Programs, Analog
Devices, VisualDSP++ 3.5 for 16-bit Processor, and VisualDSP++ Environment.
If you are running VisualDSP++ for the first time, the New Session dialog box (Figure 2-6 on page 2-11) opens to enable you to set up a session.
a. Select the values shown in Table 2-1.
Table 2-1. Session Specification
Box Value
Debug Target ADSP-BF53x Family Simulator
Platform ADSP-BF535 Simulator
Session Name ADSP-BF535 ADSP-BF535 Simulator
Processor
ADSP-BF535
b. Click OK. The VisualDSP++ main window appears.
If you have already run VisualDSP++ and the Reload last project at
startup option is selected on the Project page under Settings and Preferences, VisualDSP++ opens the last project that you worked
on. To close this project, choose Close from the Project menu, and then click No when prompted to save the project. Since you have made no changes to the project, you do not have to save it.
2. From the Project menu, choose Open.
VisualDSP++ displays the Open Project dialog box.
2-4 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
3. In the Look in box, open the folder and double-click the following subfolders in succession.
VisualDSP 3.5 16-Bit\Blackfin\Examples\Tutorial\ dot_product_c
This path is based on the default installation.
Program Files\Analog Devices
L
4. Double-click the dotprodc project (.dpj) file.
VisualDSP++ loads the project in the Project window, as shown in
Figure 2-2. The environment displays messages in the Output win-
dow as it processes the project settings and file dependencies.
Figure 2-2. Project Loaded in the Project Window
The dotprodc project comprises two C language source files, dot-
prod.c
their dot products.
VisualDSP++ 3.5 Getting Started Guide 2-5 for 16-Bit Processors
and dotprod_main.c, which define the arrays and calculate
Exercise One: Building and Running a C Program
5. From the Settings menu, choose Preferences to open the Prefer­ences dialog box, shown in Figure 2-3.
Figure 2-3. Preferences Dialog Box
6. On the General page, under General Preferences, make sure that the following options are selected.
Run to main after load
Load executable after build
2-6 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
7. Click OK to close the Preferences dialog box.
The VisualDSP++ main window appears. You are now ready to build the project.

Step 2: Build the dotprodc Project

To build the dotprodc project:
1. From the Project menu, choose Build Project.
VisualDSP++ first checks and updates the project dependencies and then builds the project by using the project source files.
As the build progresses, the Output window displays status mes­sages (error and informational) from the tools. For example, when a tool detects invalid syntax or a missing reference, the tool reports the error in the Output window.
Basic Tutorial
If you double-click the file name in the error message, Visu­alDSP++ opens the source file in an editor window. You can then edit the source to correct the error, rebuild, and launch the debug session. If the project build is up-to-date (the files, dependencies, and options have not changed since the last project build), no build is performed unless you run the Rebuild All command. Instead, you see the message “
Project is up to date.” If the build has no
errors, a message reports “Build completed successfully.”
VisualDSP++ 3.5 Getting Started Guide 2-7 for 16-Bit Processors
Exercise One: Building and Running a C Program
In this example (Figure 2-4) notice that the compiler detects an undefined identifier and issues the following error in the Output window.
Figure 2-4. Example of Error Message
2. Double-click the error message text in the Output window.
VisualDSP++ opens the C source file
dotprod_main.c in an editor
window and places the cursor on the line that contains the error (see Figure 2-5 on page 2-9).
The editor window in Figure 2-5 shows that the integer variable declaration int has been misspelled as itn.
2-8 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
Figure 2-5. Output Window and Editor Window
3. In the editor window, click on
itn and change it to int. Notice
that int is now color coded to signify that it is a valid C keyword.
4. Save the source file by choosing Save from the File menu.
5. Build the project again by choosing Build Project from the Project menu. The project is now built without any errors, as reported on the Build page in the Output window.
Now that you have built your project successfully, you can run the exam­ple program.
VisualDSP++ 3.5 Getting Started Guide 2-9 for 16-Bit Processors
Exercise One: Building and Running a C Program

Step 3: Run the Program

In this procedure, you will:
Set up the debug session before running the program
View debugger windows and dialog boxes
Since you enabled Load executable after build on the General page in the Preferences dialog box, the executable file dotprodc.dxe is automatically downloaded to the target. If the debug session’s processor does not match the project’s build target, VisualDSP++ reports this discrepancy and asks if you want to select another session before downloading the executable to the target. If VisualDSP++ does not open the Session List dialog box, skip steps 1–4.
2-10 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
To set up the debug session:
1. In the Session List dialog box, click New Session to open the New Session dialog box, shown in Figure 2-6.
For subsequent debugging sessions, use the New Session command on the Sessions menu to open the New Session dialog box.
Figure 2-6. New Session Dialog Box
2. Specify the target and processor information listed in the
Table 2-2.
Table 2-2. Session Specification
Box Value
Debug Target ADSP-BF53x Family Simulator
Platform ADSP-BF535 Simulator
Session Name ADSP-BF535 ADSP-BF535 Simulator
Processor
ADSP-BF535
VisualDSP++ 3.5 Getting Started Guide 2-11 for 16-Bit Processors
Exercise One: Building and Running a C Program
3. Click OK to close the New Session dialog box and return to the Session List dialog box.
4. With the new session name highlighted, click Activate.
L
If you do not click Activate, the session mismatch message appears again.
VisualDSP++ closes the Session List dialog box, automatically loads your project’s executable file (dotprodc.dxe), and advances to the main function of your code (see Figure 2-7).
Figure 2-7. Loading dotprodc.dxe
2-12 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
5. Look at the information in the open windows.
The Output window’s Console page contains messages about the status of the debug session. In this case, VisualDSP++ reports that the
dotprodc.dxe load is complete.
The Disassembly window displays the assembly code for the exe­cutable. Use the scroll bars to move around the Disassembly window.
Note that a solid red circle and a yellow arrow appear at the start of the program labeled “main”. The solid red circle indicates that a breakpoint is set on that instruction, and the yellow arrow indi­cates that the processor is currently halted at that instruction. When VisualDSP++ loads your C program, it automatically sets two breakpoints, one at the beginning and one at the end of code execution. Your breakpoint locations may differ slightly from those shown in the examples in this book.
6. From the Settings menu, choose Breakpoints to view the break­points set in your program. VisualDSP++ displays the Breakpoints dialog box, shown in Figure 2-8 on page 2-14.
VisualDSP++ 3.5 Getting Started Guide 2-13 for 16-Bit Processors
Exercise One: Building and Running a C Program
Figure 2-8. Breakpoints Dialog Box
The breakpoints are set at these C program labels:
at “dotprod_main.c” 114
at __lib_prog_term
The Breakpoints dialog box enables you to view, add, and delete breakpoints and to browse for symbols. In the Disassembly and editor windows, double-clicking on a line of code toggles (adds or deletes) breakpoints. In the editor window, however, you must place the mouse pointer in the gutter before double-clicking.
2-14 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
Use these tool buttons to set or clear breakpoints:
Toggles a breakpoint for the current line
Clears all breakpoints
7. Click OK or Cancel to exit the Breakpoints dialog box.

Step 4: Run dotprodc

To run dotprodc, click the Run button or choose Run from the Debug menu.
VisualDSP++ computes the dot products and displays the following results on the Console page (Figure 2-9) in the Output window.
Dot product [0] = 13273595 Dot product [1] = –49956078 Dot product [2] = 35872518
Figure 2-9. Results of the dotprodc Program
You are now ready to begin Exercise Two.
VisualDSP++ 3.5 Getting Started Guide 2-15 for 16-Bit Processors

Exercise Two: Modifying a C Program to Call an Assembly Routine

Exercise Two: Modifying a C Program to Call an Assembly Routine
In Exercise One, you built and ran a C program. In this exercise, you will:
Modify the C program to call an assembly language routine
Create a Linker Description File to link with the assembly routine
Rebuild the project
The project files are largely identical to those of Exercise One. Minor modifications illustrate the changes needed to call an assembly language routine from C source code.

Step 1: Create a New Project

To create a new project:
1. From the Project menu, choose Close to close the dotprodc project.
Click Yes when prompted to close all open source windows.
If you have modified your project during this session, you are prompted to save the project. Click No.
2-16 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
2. From the Project menu, choose New to open the Save New Project As dialog box, shown in Figure 2-10.
Figure 2-10. Save New Project As Dialog Box
3. Click the up-one-level button until you locate the
dot_product_asm folder, and then double-click this folder.
VisualDSP++ 3.5 Getting Started Guide 2-17 for 16-Bit Processors
Exercise Two: Modifying a C Program to Call an Assembly Routine
4. In the File name box, type
dot_product_asm, and click Save.
The Project Options dialog box (Figure 2-11) appears.
Figure 2-11. Project Options Dialog Box: Project Page
This dialog box enables you to specify project build information.
5. Take a moment to view the tabbed pages in the Project Options window: Project, General, Compile, Assemble, Link, Load, Com- piled Simulation, and Post Build. On each page, you specify the tool options used to build the project.
2-18 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
6. On the Project page (Figure 2-11 on page 2-18), specify the values shown in Table 2-3.
Table 2-3. Completing the Project Page
Box Value
Processor ADSP-BF535
Type DSP executable file
Name dot_product_asm
Settings for configuration Debug
These settings specify information for building an executable file for the ADSP-BF535 processor. The executable contains debug information, so you can examine program execution.
7. Click the Compile tab to display the Compile page, shown in
Figure 2-12 on page 2-20.
VisualDSP++ 3.5 Getting Started Guide 2-19 for 16-Bit Processors
Exercise Two: Modifying a C Program to Call an Assembly Routine
Figure 2-12. Project Options Dialog Box: Compile Page
8. Complete the General group box as follows.
a. Select the Enable optimization check box to enable
optimization.
b. Select the Generate debug information check box, if it is
not already selected, to enable debug information for the C source.
2-20 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
These settings direct the C compiler to optimize code for the ADSP-BF535 processor. Because the optimization takes advantage of DSP architecture and assembly language features, some of the C debug information is not saved. Debugging is, therefore, per­formed through debug information at the assembly language level.
9. Click OK to apply changes to the project options and to close the Project Options dialog box. When prompted to add support for the VisualDSP++ kernel, click No.
You are now ready to add the source files to the project.

Step 2: Add Source Files to dot_product_asm

To add the source files to the new project:
1. Click the Add File button , or from the Project menu, choose Add to Project, and then choose File(s).
The Add Files dialog box (Figure 2-13) appears.
Figure 2-13. Add Files Dialog Box: Adding Source Files to the Project
VisualDSP++ 3.5 Getting Started Guide 2-21 for 16-Bit Processors
Exercise Two: Modifying a C Program to Call an Assembly Routine
2. In the Look in box, locate the project folder,
dot_product_asm.
3. In the Files of type box, select All Source Files from the
drop-down list.
4. Hold down the Ctrl key and click dotprod.c and dotprod_main.c. Then click Add.
To display the files that you added in step 4, open the Source
Files
folder in the Project window.
You are now ready to create a Linker Description File for the project.

Step 3: Create a Linker Description File for the Project

In this procedure, you will use the Expert Linker to create a Linker Description File for the project.
To create a Linker Description File:
1. From the Tools menu, choose Expert Linker and then choose Cre- ate LDF to open the Create LDF Wizard, shown in Figure 2-14 on
page 2-23.
2-22 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
Figure 2-14. Create LDF Wizard
VisualDSP++ 3.5 Getting Started Guide 2-23 for 16-Bit Processors
Exercise Two: Modifying a C Program to Call an Assembly Routine
2. Click Next to display the Create LDF – Step 1 of 3 page, shown in
Figure 2-15.
Figure 2-15. Create LDF – Step 1 of 3 Page
This page enables you to assign the LDF file name (based on the project name) and to select the Project type.
2-24 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
3. Accept the values selected for your project and click Next to dis­play the Create LDF – Step 2 of 3 page, shown in Figure 2-16.
Figure 2-16. Create LDF – Step 2 of 3 Page
This page enables you to set the System type (defaulted to Single processor), the Processor type (defaulted to ADSP-BF535 to match the project), and the name of the linker Output file (defaulted to the name selected by the project).
VisualDSP++ 3.5 Getting Started Guide 2-25 for 16-Bit Processors
Exercise Two: Modifying a C Program to Call an Assembly Routine
4. Accept the default values and click Next to display the Create LDF – Step 3 of 3 page, shown in Figure 2-17.
Figure 2-17. Create LDF – Step 3 of 3 Page
2-26 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
5. Review the Summary of choices and click Finish to create the file.
You now have a new .LDF file in your project. The new file is in the Linker Files folder in the Project window.
The Expert Linker window opens with a representation of the .LDF file that you created. This file is complete for this project. Close the Expert Linker window.
6. Click the Rebuild All button to build the project. The C source file opens in an editor window, and execution halts.
The C version of the project is now complete. You are now ready to mod­ify the sources to call the assembly function.

Step 4: Modify the Project Source Files

In this procedure, you will:
•Modify dotprod_main.c to call a_dot_c_asm instead of a_dot_c
Save the modified file
.LDF
VisualDSP++ 3.5 Getting Started Guide 2-27 for 16-Bit Processors
Exercise Two: Modifying a C Program to Call an Assembly Routine
To modify
dotprod_main.c to call the assembly function:
1. Resize or maximize the editor window for better viewing.
2. From the Edit menu, choose Find to open the Find dialog box, shown in Figure 2-18.
Figure 2-18. Find Dialog Box: Locating Occurrences of /*
3. In the Find What box, type /*, and then click Mark All.
The editor bookmarks all lines containing /* and positions the cur­sor at the first instance of /* in the extern int a_dot_c_asm declaration.
2-28 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
4. Select the comment characters
/* and use the Ctrl+X key combina-
tion to cut the comment characters from the beginning of the
a_dot_c_asm declaration. Then move the cursor up one line and
use the Ctrl+V key combination to paste the comment characters at the beginning of the a_dot_c declaration. Because syntax color­ing is turned on, the code will change color as you cut and paste the comment characters.
Repeat this step for the end-of-comment characters */ at the end of the a_dot_c_asm declaration. The a_dot_c declaration is now fully commented out, and the a_dot_c_asm declaration is no longer commented.
5. Press F3 to move to the next bookmark.
The editor positions the cursor on the /* in the function call to
a_dot_c_asm, which is currently commented out. Note that the
previous line is the function call to the a_dot_c routine.
6. Press Ctrl+X to cut the comment characters from the beginning of the function call to a_dot_c_asm. Then move the cursor up one line and press Ctrl+V to paste the comment characters at the begin- ning of the call to a_dot_c.
Repeat this step for the end-of-comment characters */. The main() function should now be calling the a_dot_c_asm routine instead of the a_dot_c function, previously called in Exercise One.
Figure 2-19 on page 2-30 shows the changes made in step 6.
VisualDSP++ 3.5 Getting Started Guide 2-29 for 16-Bit Processors
Exercise Two: Modifying a C Program to Call an Assembly Routine
Figure 2-19. Editor Window: Modifying dotprod_main.c to Call a_dot_c_asm
7. From the File menu, choose Save to save the changes to the file.
8. Place the cursor in the editor window. Then, from the File menu, choose Close to close the
You are now ready to modify
dotprod_main.c file.
dotprodasm.ldf.
2-30 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors

Step 5: Use the Expert Linker to modify dot_prod_asm.ldf

In this procedure you will:
Basic Tutorial
View the Expert Linker representation of the
.LDF file that you
created
Modify the
.LDF file to map in the section for the a_dot_c_asm
assembly routine
To examine and then modify dot_prod_asm.ldf to link with the assembly function:
1. Click the Add File button .
2. Select dotprod_func.asm and click Add.
3. Try to build the project by performing one of these actions:
Click the Build Project button .
From the Project menu, choose Build Project.
Notice the linker error in the Output window, shown in
Figure 2-20.
Figure 2-20. Output Window: Linker Error
VisualDSP++ 3.5 Getting Started Guide 2-31 for 16-Bit Processors
Exercise Two: Modifying a C Program to Call an Assembly Routine
4. In the Project window, double-click in the
dot_prod_asm.ldf file.
The Expert Linker window (Figure 2-21) opens with a graphical representation of your file.
Resize the window to expand your view and change the view mode. To display the tree view shown in Figure 2-21, right-click in the right pane, choose View Mode, and then choose Memory Map Tree.
Figure 2-21. Expert Linker Window
The left pane contains a list of the Input Sections that are in your project or are mapped in the .LDF file. A red X is over the icon in front of the section named “
my_asm_section” because the Expert
Linker has determined that the section is not mapped by the .LDF file.
The right pane contains a representation of the memory segments that the Expert Linker defined when it created the .LDF file.
2-32 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
5. Map the section
MEM_PROGRAM as follows.
my_asm_section into the memory segment named
Open the my_asm_section input section by clicking on the plus sign in front of it. The input section expands to show that the linker macros $COMMAND_LINE_OBJECTS and $OBJECTS and the object file dotprod_func.doj have a section that has not been mapped. Expand MEM_PROGRAM in the memory map pane and drag the icon in front of $OBJECTS onto the program output section under
MEM_PROGRAM.
As shown in Figure 2-22, the red X should no longer appear because the section my_asm_section has been mapped.
Figure 2-22. Dragging $OBJECTS onto Program Output Section
6. From the Tools menu, choose Expert Linker and Save to save the modified file. Then close the Expert Linker window.
If you forget to save the file and then rebuild the project, Visu­alDSP++ will see that you modified the file and will automatically save it.
VisualDSP++ 3.5 Getting Started Guide 2-33 for 16-Bit Processors
Exercise Two: Modifying a C Program to Call an Assembly Routine
You are now ready to rebuild and run the modified project.

Step 6: Rebuild and Run dot_product_asm

To run dot_product:
1. Build the project by performing one of these actions:
Click the Build Project button .
From the Project menu, choose Build Project.
At the end of the build, the Output window displays the following message on the Build page.
Build completed successfully.
VisualDSP++ loads the program, runs to main, and displays the Output, Disassembly, and editor windows (shown in Figure 2-23
on page 2-35).
2-34 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
Figure 2-23. Windows Left Open from the Previous Debugger Session
2. Click the Run button to run
dot_product_asm.
The program calculates the three dot products and displays the results on the Console page in the Output window. When the pro­gram stops running, the message “Halted” appears in the status bar at the bottom of the window. The results, shown below, are identi­cal to the results obtained in Exercise One.
Dot product [0] = 13273595 Dot product [1] = –49956078 Dot product [2] = 35872518
You are now ready to begin Exercise Three.
VisualDSP++ 3.5 Getting Started Guide 2-35 for 16-Bit Processors

Exercise Three: Plotting Data

Exercise Three: Plotting Data
In this exercise, you will:
Load and debug a pre-built program that applies a simple Finite Impulse Response (FIR) filter to a buffer of data
Use VisualDSP++’s plotting engine to view the different data arrays graphically, both before and after running the program

Step 1: Load the FIR Program

To load the FIR program:
1. Keep the Disassembly window and Console page (in the Output window) open, but close all other windows.
2. From the File menu, choose Load Program or click . The Open a Processor Program dialog box appears.
3. Select the FIR program to load as follows.
a. Open your Analog Devices folder and double-click:
VisualDSP 3.5 16-Bit\Blackfin\Examples\Tutorial\fir
b. Double-click the Debug subfolder.
c. Double-click FIR.DXE to load the program.
If VisualDSP++ does not open an editor window (shown in
Figure 2-24 on page 2-37), right-click in the Disassembly
window and select View Source.
2-36 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
Figure 2-24. Loading the FIR Program
4. Look at the source code of the FIR program.
You can see two global data arrays:
IN
OUT
You can also see one function, fir, that operates on these arrays.
You are now ready to open a plot window.
VisualDSP++ 3.5 Getting Started Guide 2-37 for 16-Bit Processors
Exercise Three: Plotting Data

Step 2: Open a Plot Window

To open a plot window:
1. From the View menu, choose Debug Windows and Plot. Then choose New to open the Plot Configuration dialog box, shown in
Figure 2-25.
Here you will add the data sets that you want to view in a plot window.
Figure 2-25. Plot Configuration Dialog Box
2-38 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
2. In the Plot group box, specify the following values.
•In the Type box, select Line Plot from the drop-down list.
Basic Tutorial
•In the Title box, type
fir.
3. Enter two data sets to plot by using the values in Table 2-4.
Table 2-4. Two Data Sets: Input and Output
Box Input Data
Set
Name Input Output Data set
Memory BLACKFIN
Memory
Address IN OUT The address of this data set is that of the
Count 128 128 The array is 260 elements long, but you are
Stride 1 1 The data is contiguous in memory.
Data short short Input and Output are arrays of int values.
Output Data Set
BLACKFIN Memory
Description
Data memory
Input or Output array. Click Browse to select the value from the list of loaded symbols.
plotting the first 128 elements.
After entering each data set, click Add to add the data set to the Data sets list on the left of dialog box.
The Plot Configuration dialog box should now look like the one in
Figure 2-26 on page 2-40.
VisualDSP++ 3.5 Getting Started Guide 2-39 for 16-Bit Processors
Exercise Three: Plotting Data
Figure 2-26. Plot Configuration Dialog Box with Input/Output Data Sets
4. Click OK to apply the changes and to open a plot window with these data sets.
The plot window now displays the two arrays. Since, by default, the simulator initializes memory to zero, the Output data set appears as one horizontal line, shown in Figure 2-27 on page 2-41.
2-40 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
Figure 2-27. Plot Window: Before Running the FIR Program
Resizing the plot window changes the scale on the x and y axis.
L
5. Right-click in the plot window and choose Modify Settings. On the General page, in the Options group box, select Legend and click OK to display the legend box.

Step 3: Run the FIR Program and View the Data

To run the FIR program and view the data:
1. Press F5 or click the Run button to run to the end of the program.
When the program halts, you see the results of the FIR filter in the Output array. The two data sets are visible in the plot window, as shown in Figure 2-28 on page 2-42.
VisualDSP++ 3.5 Getting Started Guide 2-41 for 16-Bit Processors
Exercise Three: Plotting Data
Figure 2-28. Plot Window After Running the FIR Program to Completion
Next you will zoom in on a particular region of interest in the plot window to focus in on the data.
2-42 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
2. Click the left mouse button inside the plot window and drag the mouse to create a rectangle to zoom into. Then release the mouse button to magnify the selected region.
Figure 2-29 shows the selected region, and Figure 2-30 on page 2-44 shows the magnified result.
Figure 2-29. Plot Window: Selecting a Region to Magnify
VisualDSP++ 3.5 Getting Started Guide 2-43 for 16-Bit Processors
Exercise Three: Plotting Data
Figure 2-30. Plot Window: Magnified Result
To return to the previous view (before magnification), right-click in the plot window and choose Reset Zoom from the pop-up menu. You can view individual data points in the plot window by enabling the data cursor, as explained in the next step.
3. Right-click inside the plot window and choose Data Cursor from the popup menu. Move to each data point in the current data set
by pressing and holding the Left () or Right () arrow key on the keyboard. To switch data sets, press the Up () or Down (↓)
arrow key. The value of the current data point appears in the lower-left corner of the plot window, as shown in Figure 2-31 on
page 2-45.
2-44 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
Figure 2-31. Plot Window: Using the Data Cursor Feature
4. Right-click in the plot window and choose Data Cursor from the
pop-up menu.
Next you will look at data sets in the frequency domain.
5. Right-click in the plot window and choose Modify Settings to open the Plot Settings dialog box.
VisualDSP++ 3.5 Getting Started Guide 2-45 for 16-Bit Processors
Exercise Three: Plotting Data
6. Complete these steps:
a. Click the Data Processing tab to display the Data Process-
ing page, shown in Figure 2-32.
Figure 2-32. Data Processing Page
b. In the Data Sets box, make sure that Input (the default) is
selected. In the Data Process box, choose FFT Magnitude. c. In the Sample rate (Hz) box, type 10000. d. In the Data Sets box, select Output. In the Data Process
box, choose FFT Magnitude
2-46 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
e. Click OK to exit the Data Processing page.
VisualDSP++ performs a Fast Fourier Transform (FFT) on the selected data set before it is plotted. FFT enables you to view the signal in the frequency domain, as shown in
Figure 2-33.
Figure 2-33. FFT Performed on a Selected Data Set
Now, complete the following steps to look at the FIR filter’s response in the frequency domain.
1. From the View menu, choose Debug Windows and Plot. Then choose New to open the Plot Configuration dialog box.
2. Set up the Filter Frequency Response plot by completing the Plot and Data Setting group boxes as shown in Figure 2-34 on
page 2-48.
VisualDSP++ 3.5 Getting Started Guide 2-47 for 16-Bit Processors
Exercise Three: Plotting Data
Figure 2-34. Filter Frequency Response Data Set
3. Click Add to add the data set to the Data sets box.
4. Click OK to apply the changes and to open the plot window with this data set.
5. Right-click in the plot window and choose Modify Settings to open the Plot Settings dialog box.
2-48 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
6. Click the Data Processing tab to display the Data Processing page, shown in Figure 2-32 on page 2-46. Complete this page as follows.
a. In the Data Sets box, select h.
b. In the Data Process box, choose FFT Magnitude.
c. In the Sample rate (Hz) box, type 10000.
d. Click OK to exit the Data Processing page.
VisualDSP++ performs a Fast Fourier Transform (FFT) on the selected data set, and enables you to view the filter response plot in the frequency domain, as shown in Figure 2-35.
Figure 2-35. Filter Frequency Response Plot
This plot shows that the low pass FIR filter cuts off all frequency components above 4,000 Hz. When you apply a low pass filter to the input signal, the resulting signal has no output above 4,000 Hz.
VisualDSP++ 3.5 Getting Started Guide 2-49 for 16-Bit Processors

Exercise Four: Linear Profiling

You are now ready to begin Exercise Four.
Exercise Four: Linear Profiling
In this exercise, you will:
Load and debug the FIR program from the previous exercise
Use linear profiling to evaluate the program’s efficiency and to determine where the application is spending the majority of its exe­cution time in the code
VisualDSP++ supports two types of profiling: linear and statistical.
You use linear profiling with a simulator. The count in the Linear Profiling Results window is incremented every time a line of code is executed.
You use statistical profiling with a JTAG emulator connected to a processor target. The count in the Statistical Profiling Results window is based on random sampling.

Step 1: Load the FIR Program

To load the FIR program:
1. Close all open windows except for the Disassembly window and the Output window.
2. From the File menu, choose Load Program, or click . The Open a Processor Program dialog box appears.
2-50 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
3. Select the program to load as follows.
Basic Tutorial
a. Open the
VisualDSP 3.5 16-Bit\Blackfin\Examples\Tutorial\fir
Analog Devices folder and double-click:
b. Double-click the Debug subfolder.
c. Double-click FIR.DXE to load and run the FIR program.
If VisualDSP++ does not open an editor window (shown in
Figure 2-37 on page 2-52), right-click in the Disassembly
window and select View Source.
You are now ready to set up linear profiling.

Step 2: Open the Profiling Window

To open the linear profiling window:
1. From the Tools menu, choose Linear Profiling and then choose New Profile.
Figure 2-36. Setting Up Linear Profiling for the FIR Program
The Linear Profiling Results window opens.
VisualDSP++ 3.5 Getting Started Guide 2-51 for 16-Bit Processors
Exercise Four: Linear Profiling
2. For a better view of the data, use the window’s title bar to drag and dock the window to the top of the VisualDSP++ main window, as shown in Figure 2-37.
Figure 2-37. Linear Profiling Results Window (Empty)
The Linear Profiling Results window is initially empty. Linear profiling will be performed when you run the FIR program. After you run the program and collect data, this window displays the results of the profiling session.
You are now ready to collect and examine linear profile data.
2-52 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial

Step 3: Collect and Examine the Linear Profile Data

To collect and examine the linear profile data:
1. Press F5 or click to run to the end of the program.
When the program halts, the results of the linear profile appear in the Linear Profiling Results window.
2. Examine the results of your linear profiling session.
The Linear Profiling Results window is divided into two, three-column panes.
The left pane shows the results of the profile data. You can see the percentages of total execution time consumed, by function and by address.
Double-clicking a line with a function enables you to display the source file that contains that function. For example, double-click the fir function to display the assembly source file fir.asm in the right pane, as shown in Figure 2-38.
Figure 2-38. Linear Profiling Results, FIR Program Performance Analysis
VisualDSP++ 3.5 Getting Started Guide 2-53 for 16-Bit Processors
Exercise Four: Linear Profiling
The field values in the left pane are defined as follows.
Histogram A graphical representation of the percentage of time
spent in a particular execution unit. This percentage is based on the total time that the program spent running, so longer bars denote more time spent in a particular execution unit.The Linear Profiling Results window always sorts the data with the most time-consuming (expensive) execution units at the top.
% The numerical percent of the same data found in
the Histogram column. You can view this value as an absolute number of samples by right-clicking in the Linear Profiling Results window and by select­ing View Sample Count from the popup menu.
Execution Unit The program location to which the samples belong.
If the instructions are inside a C function or a C++ method, the execution unit is the name of the func­tion or method. For instructions that have no corresponding symbolic names, such as hand-coded assembly or source files compiled without debug­ging information, this value is an address in the form of PC[xxx], where xxx is the address of the instruction.
If the instructions are part of an assembly file, the execution unit is either an assembly function or the assembly file followed by the line number in parentheses.
2-54 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
In Figure 2-38 on page 2-53 the left pane shows that the
fir function
consumes over 93% of the total execution time. The right (source) pane, shown in Figure 2-39, displays the percentage that each line in the fir function consumes.
Figure 2-39. Linear Profile Data for fir.asm
You are now ready to begin Exercise Five.
VisualDSP++ 3.5 Getting Started Guide 2-55 for 16-Bit Processors

Exercise Five: Installing and Using a VCSE Component

Exercise Five: Installing and Using a VCSE Component
In this exercise, you will:
Start up the VisualDSP++ environment (if it is not running)
Open an existing project
Install a VCSE component on your system
Add the component to the project
Build and run the program with the component
The sources for the exercise are in the vcse_component folder. The default installation path is:
Program Files\Analog Devices\VisualDSP 3.5 16-Bit\Blackfin\ Examples\Tutorial\vcse_component

Step 1: Start VisualDSP++ and Open the Project

If VisualDSP++ is already running, proceed to step 2 on the next page.
To start VisualDSP++ and open the project:
1. Click the Windows Start button and select Programs, VisualDSP, and VisualDSP++ Environment.
The VisualDSP++ main window appears.
If you have already run VisualDSP++ and the Reload last project
at startup option is selected (on the Project page in the Settings, Preferences dialog box), VisualDSP++ opens the last project that
you worked on.
2-56 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
To close this project, choose Close from the Project menu and then click No when prompted to save the project. Since you have made no changes to the project, you do not have to save it.
2. From the Project menu, choose Open.
VisualDSP++ displays the Open Project dialog box.
3. In the Look in box, open the following folders.
Program Files\Analog Devices\VisualDSP 3.5 16-Bit
Then double-click the following sub-folders in succession.
Blackfin\Examples\Tutorial\vcse_component
L
This path is based on the default installation.
4. Double-click the useg711.dpj project file.
VisualDSP++ loads the project. The environment displays messages in the Output window as it processes the project settings.
The useg711 project contains a single C language source file
useg711.c, which contains the code needed to create an instance of
the CULawc component and to invoke the methods of the IG711 interface.
VisualDSP++ 3.5 Getting Started Guide 2-57 for 16-Bit Processors
Exercise Five: Installing and Using a VCSE Component

Step 2: Install the EXAMPLES::CULawc Component on Your Sys te m

The EXAMPLES::CULawc component is distributed as part of VisualDSP++ and is ready to be installed on your system:
1. From the Tools menu, select the VCSE submenu and then choose Manage Components.
2. In the Display field, select Downloaded component package… from the drop-down list.
The Open dialog box is displayed.
3. In the Look in box, open the Program Files\Analog Devices folder and double-click the following subfolders in succession.
VisualDSP 3.5 16-Bit\Blackfin\Examples\Tutorial\ vcse_component
L
This path is based on the default installation.
4. Double-click the examples_culawc_BF535.vcp file.
VisualDSP++ opens the file, extracts the information about the component, and shows it as a downloaded component in the Com- ponent Manager dialog box (Figure 2-40 on page 2-59).
2-58 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
Figure 2-40. Component Manager Dialog Box – Downloaded Component
5. Click the Install… button. Component Manager installs the compo­nent on your system. Once the component is installed, click OK.
VisualDSP++ 3.5 Getting Started Guide 2-59 for 16-Bit Processors
Exercise Five: Installing and Using a VCSE Component
6. In the Display field select Locally installed components from the drop-down list, and in the Sort by field select Title.
Select Component for G711 which implements the mu-law encoding in C, as shown in Figure 2-41.
Figure 2-41. Component Manager Dialog Box – Selected Component
7. Click Close to close Component Manager.
2-60 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors

Step 3: Add the Component to Your Project

To add the newly installed component to the project:
1. From the Tools menu, select the VCSE submenu and then choose Add Component.
2. Click Component for G711 which implements the mu-law encod- ing in C to select it.
Basic Tutorial
L
Figure 2-42. Expanded View of Component Information
If you have multiple components on your system and you are not sure which one to add, click the expand button to display the component information (shown in Figure 2-42). Make sure that ADSP-BF535 is designated as the Processor for the component that you are adding to your project.
3. Click Add to indicate that you want to add the component to the project.
Component Manager displays the dialog box shown in Figure 2-43
on page 2-62.
VisualDSP++ 3.5 Getting Started Guide 2-61 for 16-Bit Processors
Exercise Five: Installing and Using a VCSE Component
Figure 2-43. Adding Files to the Project
4. Click OK to add the component files to the project.

Step 4: Build and Run the Program

To build and run the program:
1. From the Project menu, choose Build Project.
VisualDSP++ displays the message shown in Figure 2-44 on
page 2-63.
2-62 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Basic Tutorial
Figure 2-44. Rebuilding Files Affected by Changes to Project Settings
2. Click Yes. VisualDSP++ compiles the source files and creates the program.
3. From the Debug menu, choose Run to execute the program. The program generates the following output.
Harness to test component code generated by EXAMPLES_CULawc.idl Testing EXAMPLES::IG711 Test Completed result = MR_OK
You have now completed the Basic Tutorial.
VisualDSP++ 3.5 Getting Started Guide 2-63 for 16-Bit Processors
Exercise Five: Installing and Using a VCSE Component
2-64 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors

3 ADVANCED TUTORIAL

This chapter contains the following topics.
“Overview” on page 3-1
“Exercise One: Using Profile-Guided Optimization” on page 3-2
“Exercise Two: Using Background Telemetry Channel” on
page 3-19

Overview

This tutorial demonstrates the more advanced features and techniques that you can use in the VisualDSP++ Integrated Development and Debugging Environment (IDDE). The exercises use sample programs written in C, C++, and assembly for Blackfin processors.
•In Exercise One: Using Profile-Guided Optimization, you will build a project with PGO support, create PGO files, compile the project without using the information in the PGO files, re-compile the project by using the PGO files to optimize the build, check the PGO results, and compare execution times.
•In Exercise Two: Using Background Telemetry Channel, you will add BTC to your DSP application and then run two demos that dem­onstrate BTC functionality.
The ADSP-BF53x Family Simulator and ADSP-BF532 processor are used for Exercise One. The EZ-KIT Lite USB emulator, HP PCI ICE, and ADSP-BF535 processor are used for Exercise Two.
VisualDSP++ 3.5 Getting Started Guide 3-1 for 16-Bit Processors

Exercise One: Using Profile-Guided Optimization

Exercise One: Using Profile-Guided Optimization
Profile-guided optimization (PGO) is an optimization technique that uses previously-collected information to guide the compiler optimizer’s decisions.
Traditionally, a compiler compiles each function only once and attempts to produce generated code that will perform well in most cases. The compiler has to make decisions about the best code to generate. For example, given an if…then…else construct, the compiler has to decide whether the most com­mon case is the “then” or the “else.” You can offer crude guidelines—compile for speed or compile for space—but, usually, the compiler has to make a default decision.
With PGO, the compiler makes these decisions based on data collected during previous executions of the generated code. This process involves the following steps.
1. Compile the application to collect profile information.
2. Run the application in a simulator session by using representative data sets. The simulator accumulates profile data indicating where the application spends most of its time.
3. Re-compile the application by using the collected profile data. The compiler uses the collected information rather than the application’s default behavior to make decisions about the relative importance of parts of the application.
The profile data collected from a simulator run is stored in a file with a suffix. You can process multiple data sets to cover the spectrum of potential data and create a separate .PGO file for each data set. The re-compilation stage can accept multiple .PGO files as input.
3-2 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
.PGO
Advanced Tutorial
The basic steps required to use PGO are:
1. Build the application with PGO support.
2. Set up one or more streams in the simulator to provide a set of data inputs that represent what the application would see in a real target environment.
3. Tell the simulator to produce a
.PGO file with a specified filename.
4. Load and run the application to produce the .PGO file.
5. Rebuild the application and pass all .PGO files to the compiler, which uses the generated PGO results to optimize the application.
In this exercise, you will:
Load the PGO example project in the VisualDSP++ environment.
Create data sets for profile-guided optimization.
Attach input streams to the data sets.
•Create .PGO files by executing the project with the data sets as input.
Re-compile the project by using the .PGO files to optimize the build.
Run the optimized version of the project with the same data sets as input.
Compare the execution times of all three executions.
The files used for this exercise are in the
pgo folder. The default installation
path of this folder is:
Program Files\Analog Devices\VisualDSP++ 3.5 for 16-Bit Processors\Blackfin\Examples\Tutorial\pgo
VisualDSP++ 3.5 Getting Started Guide 3-3 for 16-Bit Processors
Exercise One: Using Profile-Guided Optimization

Step 1: Load the Project

To open a VisualDSP++ project:
1. Start VisualDSP++ and connect to an ADSP-BF532 simulator session. For information about connecting to a session, refer to “Step 1: Start
VisualDSP++ and Open a Project” on page 2-4.
2. Open the project PgoExample.dpj. For details about opening projects, see “Step 1: Start VisualDSP++ and Open a Project” on page 2-4.
This project contains a C file, PgoExample.c. When you run the pro­gram, it reads data from an address and counts the number of even and odd values. This counting is done with an if…then…else statement. If the majority of values read are odd, the program will spend most of its time in the then… branch. If the majority of values read are even, the program will spend most of its time in the else… branch. Normally, the compiler has no way of knowing which branch will be taken more often. By using PGO, the compiler can determine which branch is most often used and optimize the next build.
L
3-4 VisualDSP++ 3.5 Getting Started Guide
This project also contains a Visual Basic script that demonstrates how to use the VisualDSP++ Automation API to perform PGO. The automation functionality is beyond the scope of this tutorial. Refer to the online Help for more information about automation.
Three data files are used as input to the C program. These simple text files contain lists of values.
Dataset_1.dat has 128 even values (50%) and 128 odd values
• (50%).
Dataset_2.dat has 192 even values (75%) and 64 odd values (25%).
Dataset_3.dat has 256 even values (100%) and 0 odd values
(0%).
for 16-Bit Processors
Advanced Tutorial
To view these files, use the Open command on the File menu in VisualDSP++. The two possible values in all three files are either
0x01
or 0x02. Each file contains 256 values.
For the purposes of this exercise, assume that this program will be used in the real world, and that you can expect a similar distribution of val­ues as input from the real world.
By looking at the C code and the potential input, you can easily see that the executed program will spend more time in the else… branch than in the then… branch. Without using PGO, the compiler cannot make this same conclusion. By default, it will expect the then… branch to be executed most frequently and will compile the code with­out optimizing execution time.
Since the example program and input are very simple, you could fix the problem by making a few minor changes to the code. Manually tweaking a large program to speed up execution time, however, would take far too long, and you would have to analyze sample input on your own. PGO provides a quick and easy way to enable the compiler to make these adjustments for you.

Step 2: Configure a Data Set

The first step in the PGO process is to create a data set—a collection of sam­ple input for the program being optimized. A data set feeds the input into the executing program, and this input causes the program to be executed along certain paths. Some paths will be used more often than others. This informa­tion is recorded by the simulator and is stored in a .PGO file for the compiler to use later for optimization. The most commonly used paths will be opti­mized to run quickly, while less common paths will run more slowly.
VisualDSP++ 3.5 Getting Started Guide 3-5 for 16-Bit Processors
Exercise One: Using Profile-Guided Optimization
Complete the following steps to create the first of three data sets for this exercise.
1. From the Tools menu, choose PGO and then Manage Data Sets, as shown in Figure 3-1.
Figure 3-1. Manage Data Sets Menu Option
The Manage Data Sets dialog box (Figure 3-2) is displayed.
Figure 3-2. Manage Data Sets Dialog Box
3-6 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Advanced Tutorial
This dialog box is where you manage your data sets. Note the slider bar near the bottom of the window. This control allows you to customize your optimization. Moving the slider all the way to the left enables you to build as small an executable as possible, but may sacrifice execution speed. Moving the slider all the way to the right enables you to build a fast executable, with a potential space trade-off. Placing the slider between the two extremes provides varying ratios of space vs. speed optimization. For this exercise, move the slider all the way to the right.
2. Click the New button to open the Edit Data Set dialog box, shown in
Figure 3-3.
Figure 3-3. Edit Data Set Dialog Box
VisualDSP++ 3.5 Getting Started Guide 3-7 for 16-Bit Processors
Exercise One: Using Profile-Guided Optimization
3. Replace the default Data set name with a more descriptive name.
Since the first data file contains an equal number of even and odd val­ues, use a name such as
50% Even – 50% Odd.
4. Specify the Output filename (where the optimization information
produced by this data set will be saved). Optimization information is saved in files with the .PGO suffix.
Type in a file name such as dataset_1.pgo. The file will be saved in the project directory. To save the files elsewhere, type in a full path name. You can use Command line arguments for more advanced control of the data set, but they are not covered in this tutorial.
For more information about command line arguments, see the
VisualDSP++ 3.5 C/C++ Compiler and Library Manual for Blackfin Processors.
Now you have to attach an input stream to this data set.
3-8 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors

Step 3: Attach an Input Stream

In this step you will attach an input stream to the data set.
1. Click the New button to open the Edit PGO Stream dialog box, shown in Figure 3-4.
Advanced Tutorial
Figure 3-4. Edit PGO Stream Dialog Box
An input stream maps a data file to a destination device. In this exer­cise, the input streams map the three data files to the simulator. The input stream provides the program with input as needed during execution.
For more information about streams, see the “Debugging” chapter in the VisualDSP++ 3.5 User's Guide for 16-Bit Processors.
VisualDSP++ 3.5 Getting Started Guide 3-9 for 16-Bit Processors
Exercise One: Using Profile-Guided Optimization
2. Complete the Input Source File group box as described in Table 3-1.
Table 3-1. Input Source File Group Box Settings
Field/Control Action/Value
Filename Specify a file name by clicking the file browse button and selecting the
input source file dataset_1.dat from the pgo directory.
Format The data in this file is in hexadecimal format, so leave the format set-
ting as is.
Rewind on reset or restart Select this option. When you run a program with an input stream, the
program may or may not work through all of the data in the stream. If the program encounters a reset or restart event before working through the entire data stream and this option is enabled, the next execution will start at the beginning of the input stream. Otherwise, execution will continue where it left off.
Circular Select this option. It allows the program to read through an input
stream many times during a single execution.
3. In the Destination Device group box, specify where the data from the input stream is sent. Refer to Table 3-2.
Table 3-2. Destination Device Group Box Settings
Field/Control Action/Value
Processor This field is used to specify a peripheral in another processor as the
destination device. For this tutorial, you are connected to a single processor session, so this field is disabled.
Device This field allows you to choose any stream device supported by the
simulator target as the destination. Devices can include a memory address or various peripherals. Available devices depend on which pro­cessor you are using. For more information on devices, see the hard­ware manual for your processor. The program reads the input streams from memory, so leave this field as it is.
Address Specify where in memory the input will be sent. Since the program in
this exercise reads data from address
PgoExample.c), enter this value.
0xFFD00000 (refer to
3-10 VisualDSP++ 3.5 Getting Started Guide
for 16-Bit Processors
Loading...