Targeting 56800E PDF
Targeting 56800E PDF
2 Getting Started 19
System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Installing and Registering the CodeWarrior IDE . . . . . . . . . . . . . . . . . . . . . . . . 19
Creating a Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4 Target Settings 43
Target Settings Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Target Setting Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Changing Target Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Exporting and Importing Panel Options to XML Files. . . . . . . . . . . . . . . . . 46
Restoring Target Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
CodeWarrior IDE Target Settings Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
DSP56800E-Specific Target Settings Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Target Settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
M56800E Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
C/C++ Language (C Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
C/C++ Preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
C/C++ Warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
M56800E Assembler. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
HSST_flush . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162
HSST_size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162
HSST_raw_read. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163
HSST_raw_write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164
HSST_set_log_dir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164
HSST Target Program Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165
10 Profiler 227
ffs_s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
norm_s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
ffs_l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
norm_l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
round . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
shl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
shlftNs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
shlfts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
shr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
shr_r. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
shrtNs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
L_shl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
L_shlftNs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
L_shlfts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
L_shr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
L_shr_r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
L_shrtNs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Modulo Addressing Intrinsic Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
__mod_init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
__mod_initint16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
__mod_start. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
__mod_access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
__mod_update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
__mod_stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
__mod_getint16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
__mod_setint16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
__mod_error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
Assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
Index 371
CodeWarrior IDE
The CodeWarrior IDE consists of a project manager, a graphical user interface, compilers,
linkers, a debugger, a source-code browser, and editing tools. You can edit, navigate,
examine, compile, link, and debug code, within the one CodeWarrior environment. The
CodeWarrior IDE lets you configure options for code generation, debugging, and
navigation of your project.
Unlike command-line development tools, the CodeWarrior IDE organizes all files related
to your project. You can see your project at a glance, so organization of your source-code
files is easy. Navigation among those files is easy, too.
When you use the CodeWarrior IDE, there is no need for complicated build scripts of
makefiles. To add files to your project or delete files from your project, you use your
mouse and keyboard, instead of tediously editing a build script.
For any project, you can create and manage several configurations for use on different
computer platforms. The platform on which you run the CodeWarrior IDE is called he
host. From the host, you use the CodeWarrior IDE to develop code to target various
platforms.
Note the two meanings of the term target:
• Platform Target — The operating system, processor, or microcontroller from or on
which your code will execute.
• Build Target — The group of settings and files that determine what your code is, as
well as control the process of compiling and linking.
The CodeWarrior IDE lets you specify multiple build targets. For example, a project can
contain one build target for debugging and another build target optimized for a particular
operating system (platform target). These build targets can share files, even though each
build target uses its own settings. After you debug the program, the only actions necessary
to generate a final version are selecting the project’s optimized build target and using a
single Make command.
The CodeWarrior IDE’s extensible architecture uses plug-in compilers and linkers to
target various operating systems and microprocessors. For example, the IDE uses a GNU
tool adapter for internal calls to DSP56800E development tools.
Most features of the CodeWarrior IDE apply to several hosts, languages, and build targets.
However, each build target has its own unique features. This manual explains the features
unique to the CodeWarrior Development Studio for Freescale 56800/E Digital Signal
Controllers.
For comprehensive information about the CodeWarrior IDE, see the CodeWarrior IDE
User’s Guide.
NOTE For the very latest information on features, fixes, and other matters, see the
CodeWarrior Release Notes, on the CodeWarrior IDE CD.
Table 1.1 Supported DSP56800x Processors for CodeWarrior Development Studio for
Freescale 56800/E Digital Signal Controllers
DSP56800 DSP56800E
DSP56F802 DSP56854
DSP56F803 DSP56855
DSP56F805 DSP56857
DSP56F807 DSP56858
DSP56F826 MC56F8013
DSP56F827 MC56F8014
MC56F8023
MC56F8025
MC56F8036
MC56F8037
MC56F8122
MC56F8123
MC56F8145
MC56F8146
MC56F8147
MC56F8155
MC56F8156
MC56F8157
MC56F8165
MC56F8166
MC56F8167
MC56F8322
Table 1.1 Supported DSP56800x Processors for CodeWarrior Development Studio for
Freescale 56800/E Digital Signal Controllers (continued)
DSP56800 DSP56800E
MC56F8323
MC56F8335
MC56F8345
MC56F8346
MC56F8356
MC56F8357
MC56F8365
MC56F8366
MC56F8367
References
• Your CodeWarrior IDE includes these manuals:
– CodeWarrior™ IDE User’s Guide
– CodeWarrior™ Development Studio IDE 5.6 Windows® Automation Guide
– CodeWarrior™ Development Studio for Freescale 56800/E Digital Signal
Controllers: DSP56F80x/DSP56F82x Family Targeting Manual
– CodeWarrior™ Development Studio for Freescale 56800/E Digital Signal
Controllers: MC56F8xxx/DSP5685x Family Targeting Manual
– CodeWarrior™ Builds Tools Reference for Freescale 56800/E Digital Signal
Controllers
– CodeWarrior™ Development Studio IDE 5.5 User’s Guide Profiler Supplement
– CodeWarrior™ Development Studio for Freescale™ DSP56800x Embedded
Systems Assembler Manual
– Codewarrior™ USB TAP Users Guide
– Freescale™ 56800 Family IEEE - 754 Compliant Floating-Point Library User
Manual
– Freescale™ 56800E Family IEEE - 754 Compliant Floating-Point Library User
Manual
System Requirements
Table 2.1 on page 19 lists system requirements for installing and using the CodeWarrior
IDE for DSP56800E.
Category Requirement
Hard Drive 2.0 gigabytes of free space, plus space for user projects and source
code
NOTE If the Auto Install is disabled, run the program Launch.exe in the root
directory of the CD.
b. Click Launch CodeWarrior Setup — the install wizard displays welcome page.
c. Follow the wizard instructions, accepting all the default settings.
d. At the prompt to check for updates, click the Yes button — the CodeWarrior
updater opens.
2. To check for updates:
NOTE If the updater already has Internet connection settings, you may proceed
directly to substep f.
a. Click the Settings button — the Updater Settings dialog box appears.
b. Click the Load Settings button — the updater loads settings from your Windows
control panel.
c. Modify the settings, as appropriate.
d. If necessary, enter the proxy username and the password.
e. Click the Save button — the Updater Settings dialog box disappears.
f. In the updater screen, click the Check for Updates button.
g. If updates are available, follow the on-screen instructions to download the updates
to your computer.
h. When you see the message, “Your version … is up to date”, click the OK button —
the message box closes.
i. Click the updater Close button — the installation resumes.
j. At the prompt to restart the computer, select the Yes option button.
k. Click the Finish button — the computer restarts, completing installation.
3. To register the CodeWarrior software:
a. Select Start> Programs>Freescale CodeWarrior>CW for DSC56800
R8.0>CodeWarrior IDE.
b. Select Help > Register Product — the Freescale registration page appears.
NOTE In the next screen you will be asked to confirm your Registration code by
clicking Continue a second time. After registration is complete, you will
receive an email with the activation code and directions on how to activate
your product.
i. For the default selection: Ethernet Address — determine your ethernet address:
Launch a Command Prompt window
Enter ipconfig /all
Copy the Physical Address value of the first Ethernet adapter listed
Paste value into the "Node Lock ID for license" text box (remove spaces or dashes)
j. Click Continue Activation.
k. Click Continue to confirm the Host ID and License Authorization Code.
The website will display your license keys along with instructions on installing the
license. Copy and paste these keys into the top of the "license.dat" file located at the root
of your CodeWarrior installation directory. Your product should now be fully licensed and
operational.
Table 2.2 on page 23 lists the directories created during full installation.
To test your system, follow the instructions of the next section to create a project.
Directory Contents
Directory Contents
Creating a Project
To test software installation, create a sample project. Follow these steps:
1. Select Start>Freescale CodeWarrior>CW for DSC56800 R8.0>CodeWarrior
IDE. The IDE starts; the main window appears.
To create a DSP56800x project use either the:
• DSP56800x new project wizard
• DSP56800x EABI stationery
To create a new project with the DSP56800x new project wizard, please see the sub-
section “Creating a New Project with the DSP56800x New Project Wizard.”
To create a new project with the DSP56800x EABI stationery, please see the sub-section
“Creating a New Project with the DSP56800x EABI Stationery.”
4. In the Location text box, type the location where you want to save this project or
choose the default location.
5. Click OK. The DSP56800x New Project Wizard — Target dialog box (Figure
2.3 on page 26) appears.
Figure 2.4 DSP56800x New Project Wizard — Program Choice Dialog Box
8. Select the example main() program for this project, such as Simple C.
9. Click Next. The DSP56800x New Project Wizard — Finish dialog box (Figure
2.5 on page 28) appears.
NOTE For more details of the DSP56800x new project wizard, please see Appendix
B.
This completes project creation. You are ready to edit project contents, according to
the optional steps below.
NOTE Stationery projects include source files that are placeholders for your own files.
If a placeholder file has the same name as your file (such as main.c), you
must replace the placeholder file with your source file.
a. Method 1: From the main-window menu bar, select Project>Add Files. Then use
the Select files to add dialog box to specify the files.
b. Method 2: Drag files from the desktop or Windows Explorer to the project
window.
13. (Optional) Edit code in the source files.
a. Double-click the filename in the project window (or select the filename, then press
the Enter key).
b. The IDE opens the file in the editor window; you are ready to edit file contents.
NOTE Stationery is a set of project templates, including libraries and place-holders for
source code. Using stationery is the quickest way to create a new project.
c. In the Project name text box, type: NewProj1. (When you save this project, the
IDE automatically will add the .mcp extension to its filename.)
3. In the New window, click the OK button. The New Project window (Figure 2.7 on
page 30) appears, listing board-specific project stationery.
NOTE You should select a simulator target if your system is not connected to a
development board. If you do have a development board, your target selection
must correspond to the board’s processor.
c. Click the OK button. A project window opens, listing the folders for project
NewProj1.mcp. Figure 2.9 on page 32 shows this project window docked in the
IDE main window.
NOTE The IDE has the same functionality whether subordinate windows (such as the
project window) are docked, floating, or child.
To undock the project window, right-click its title tab, then select Floating or
Child from the context menu. To dock a floating window, right-click its title
bar, then select Docked from the context menu.
5. This completes project creation. You are ready to edit project contents, according to
the optional steps below.
NOTE Stationery projects include source files that are placeholders for your own files.
If a placeholder file has the same name as your file (such as main.c), you
must remove the placeholder file before adding your source file.
CodeWarrior IDE
The CodeWarrior IDE lets you create software applications. It controls the project
manager, the source-code editor, the class browser, the compiler, linker, and the debugger.
You use the project manager to organize all the files and settings related to your project.
You can see your project at a glance and easily navigate among source-code files. The
CodeWarrior IDE automatically manages build dependencies.
A project can have multiple build targets. A build target is a separate build (with its own
settings) that uses some or all of the files in the project. For example, you can have both a
debug version and a release version of your software as separate build targets within the
same project.
The CodeWarrior IDE has an extensible architecture that uses plug-in compilers and
linkers to target various operating systems and microprocessors. The CodeWarrior CD
includes a C compiler for the DSP56800E family of processors. Other CodeWarrior
software packages include C, C++, and Java compilers for Win32, Mac® OS, Linux, and
other hardware and software combinations.
The IDE includes:
• CodeWarrior Compiler for DSP56800E — an ANSI-compliant C compiler, based
on the same compiler architecture used in all CodeWarrior C compilers. Use this
compiler with the CodeWarrior linker for DSP56800E to generate DSP56800E
applications and libraries.
NOTE The CodeWarrior compiler for DSP56800E does not support C++.
Development Process
The CodeWarrior IDE helps you manage your development work more effectively than
you can with a traditional command-line environment. Figure 3.1 on page 37 depicts
application development using the IDE.
Create/Manage Project
Specify Target
Settings (2) Notes:
(1) Use any combination: stationery
Edit Files (3) (template) files, library files,
or your own source files.
(2) Compiler, linker, debugger
settings; target specification;
optimizations.
Build (Make) Project
(3) Edit source and resource files.
Compile Project
(4) Possible corrections:
adding a file, changing
settings, or editing a file.
no
Success?
yes
Link Project
no
Success?
yes
Debug Project
no
Error-Free?
yes
Release
End
Project Files
A CodeWarrior project consists of source-code, library, and other files. The project
window (Figure 3.2 on page 38) lists all files of a project, letting you:
• Add files,
• Remove files,
• Specify the link order,
• Assign files to build targets, and
• Direct the IDE to generate debug information for files.
NOTE Figure 3.2 on page 38 shows a floating project window. Alternatively, you can
dock the project window in the IDE main window or make it a child window.
You can have multiple project windows open at the same time; if the windows
are docked, their tabs let you control which one is at the front of the main
window.
The CodeWarrior IDE automatically handles the dependencies among project files, and
stores compiler and linker settings for each build target. The IDE tracks which files have
changed since your last build, recompiling only those files during your next project build.
A CodeWarrior project is analogous to a collection of makefiles, as the same project can
contain multiple builds. Examples are a debug version and a release version of code, both
part of the same project. As earlier text explained, build targets are such different builds
within a single project.
Editing Code
The CodeWarrior text editor handles text files in MS-DOS® , Windows®, UNIX, and
Mac® OS formats.
To edit a source-code file (or any other editable project file), either:
• Double-click its filename in the project window, or
• Select (highlight) the filename, then drag the highlighted filename to the
CodeWarrior main window.
The IDE opens the file in the editor window (Figure 3.3 on page 40). This window lets
you switch between related files, locate particular functions, mark locations within a file,
or go to a specific line of code.
NOTE Figure 3.3 on page 40 shows a floating editor window. Alternatively, you can
dock the editor window in the IDE main window or make it a child window.
NOTE It is possible to compile a single source file. To do so, highlight its filename in
the project window, then select Project > Compile, from the main-window
menu bar. Another useful option is compiling all modified files of the build
target: select Project>Bring Up to Date from the main-window menu bar.
In UNIX and other command-line environments, the IDE stores object code in a binary
(.o or .obj) file. On Windows targets, the IDE stores and manages object files internally
in the data folder.
A proprietary compiler architecture at the heart of the CodeWarrior IDE handles multiple
languages and platform targets. Front-end language compilers generate an intermediate
representation (IR) of syntactically correct source code. This IR is memory-resident and
language-independent. Back-end compilers generate code from the IR for specific
platform targets. As Figure 3.4 on page 41 depicts, the CodeWarrior IDE manages this
whole process.
This architecture means that the CodeWarrior IDE uses the same front-end compiler to
support multiple back-end platform targets. In some cases, the same back-end compiler
can generate code from a variety of languages. User benefits of this architecture include:
• An advance in the C/C++ front-end compiler means an immediate advance in all
code generation.
• Optimizations in the IR mean that any new code generator is highly optimized.
• Targeting a new processor does not require compiler-related changes in source code,
simplifying porting.
Freescale builds all compilers as plug-in modules. The compiler and linker components
are modular plug-ins. Freescale publishes this API, so that developers can create custom
or proprietary tools. For more information, go to Freescale Support:
http://www.Freescale.com/MW/Support
When compilation succeeds, building moves on to linking. The IDE linker:
• Links the object files into one executable file. (You use the M56800E Target settings
panel to name the executable file.)
• In case of errors, issues appropriate error messages and halts.
The IDE uses linker command files to control the linker, so you do not need to specify a
list of object files. The Project Manager tracks all the object files automatically; it lets you
specify the link order.
When linking succeeds, you are ready to test and debug your application.
Debugging
To debug your application, select Project>Debug from the main-window menu bar.
The debugger window opens, displaying your program code.
Run the application from within the debugger, to observe results. The debugger lets you
set breakpoints, and check register, parameter, and other values at specific points of code
execution.
When your code executes correctly, you are ready to add features, to release the
application to testers, or to release the application to customers.
NOTE Use the DSP56800E project stationery when you create a new project.
M56800E Target on
page 50
C/C++ Preprocessor on
page 55
C/C++ Warnings on
page 57
M56800E Assembler on
page 62
M56800E Processor on
page 64
Remote Debugging on
page 76
M56800E Target
Settings (Debugging)
Remote Debug
Options on page 82
The left side of the Target Settings window contains a list of target settings panels
that apply to the current build target.
2. To view the Target Settings panel:
Click on the name of the Target Settings panel in the Target Settings panels list
on the left side of the Target Settings window.
The CodeWarrior IDE displays the target settings panel that you selected.
3. Change the settings in the panel.
4. Click OK.
Access Paths Use this panel to select the paths that the
CodeWarrior IDE searches to find files in your project. You
can add several kinds of paths including absolute and
project-relative.
See IDE User Guide.
Build Extras Use this panel to set options that affect the way the
CodeWarrior IDE builds a project, including the use of a
third-party debugger.
See IDE User Guide.
File Mappings Use this panel to associate a file name extension, such
as.c, with a plug-in compiler.
See IDE User Guide.
Source Trees Use this panel to define project-specific source trees (root
paths) for use in your projects.
See IDE User Guide.
Custom Keywords Use this panel to change the colors that the
CodeWarrior IDE uses for different types of text.
See IDE User Guide.
Global Optimizations Use this panel to configure how the compiler optimizes the
object code.
See IDE User Guide.
Debugger Settings Use this panel to specify settings for the CodeWarrior
debugger.
Target Settings
Use the Target Settings panel (Figure 4.2 on page 49) to specify a linker. This selection
also specifies your target. Table 4.3 on page 49 explains the elements of the Target
Settings panel.
The Target Settings window changes its list of panels to reflect your linker choice. As
your linker choice determines which other panels are appropriate, it should be your first
settings action.
Target Name Sets or changes the name of a build For your development
text box target. convenience, not the name of
the final output file. (Use the
M56800E Target panel to
name the output file.)
Output Tells the IDE where to save the Default: the directory that
Directory text executable file. To specify a different contains the project file.
box output directory, click the Choose
button, then use the access-path
dialog box to specify a directory. (To
delete such an alternate directory,
click the Clear button.)
Save Project Controls whether multiple project Default: Clear — project entries
Entries Using files can have the same name: must have unique names.
Relative
• Clear — Each project
Paths entry must have a unique
checkbox name.
• Checked — The IDE uses
relative paths to save
project entries; entry
names need not be
unique.
M56800E Target
Use the M56800E Target panel (Figure 4.3 on page 50) to specify the project type and
the name of the output file. Table 4.4 on page 51 explains the elements of this panel.
Output File Specifies the name of the output file. End application filenames with
Name text the .elf extension; end library
box filenames with the .lib
extension.
NOTE Be sure to name libraries with the extension .lib. It is possible to use a
different extension, but this requires a file-mapping entry in the File Mappings
panel. For more information, see the IDE User Guide.
NOTE Always disable the following options, which do not apply to the DSP56800E
compiler: Legacy for-scoping and Pool Strings.
IPA list box Specifies Interprocedural Analysis When the Program option is
(IPA): selected the Disable
Deadstripping option on the
Off — IPA is disabled
linker preference panel must
File — inlining is deferred to the end be enabled.
of the file processing
Inline Depth Together with the ANSI Keyword If you call an inline function, the
list box Only checkbox, specifies whether to compiler inserts the function
inline functions: code, instead of issuing calling
instructions. Inline functions
Don’t Inline — do not inline any
execute faster, as there is no
Smart — inline small functions to a call. But overall code may be
depth of 2 to 4 larger if function code is
repeated in several places.
1 to 8 — Always inline functions to
the number’s depth
Always inline — inline all functions,
regardless of depth
Require Checked — Compiler does not allow This option helps prevent
Function functions that do not have errors from calling a function
Prototypes prototypes. before its declaration or
checkbox definition.
Clear — Compiler allows functions
without prototypes. To check whether this option is
in effect, use the
__option(require_prototypes)
command.
C/C++ Preprocessor
The C/C++ Preprocessor (Figure 4.5 on page 56) panel controls how the preprocessor
interprets source code. By modifying the settings on this panel, you can control how the
preprocessor translates source code into preprocessed code.
More specifically, the C/C++ Preprocessor panel provides an editable text field that can be
used to #define macros, set #pragmas, or #include prefix files.
Table 4.6 on page 56 provides information about the options in this panel.
Use prefix Controls whether a *.pch or *.pch++ This option defaults to “off” to
text in file incorporates the prefix text into correspond with previous
precompiled itself. versions of the compiler that
header ignore the prefix file when
building precompiled headers.
If any #pragmas are imported
from old C/C++ Language (C
Only) Panel settings, this
option is set to “on”.
C/C++ Warnings
Use the C/C++ Warnings panel (Figure 4.6 on page 58) to specify C language features for
the DSP56800E. Table 4.7 on page 59 explains the elements of this panel.
NOTE The CodeWarrior compiler for DSP56800E does not support C++.
M56800E Assembler
Use the M56800E Assembler panel (Figure 4.7 on page 62) to specify the format of the
assembly source files and the code that the DSP56800E assembler generates. Table 4.8 on
page 63 explains the elements of this panel.
Emit Checked — Assembler warns when This option helps optimize the
Warnings for a hardware stall occurs upon cycle count.
Hardware execution.
Stalls
Clear — Assembler does not issue
checkbox
such warnings.
Allow legacy Checked — Assembler permits Selecting this option sets the
instructions legacy DSP56800 instruction Default Data Memory Model
checkbox syntax. and Default Program Memory
Model values to 16 bits.
Clear — Assembler does not permit
this legacy syntax.
Pad Pipeline Checked — Mandatory for using the If you select this option, you
for Debugger debugger. Inserts NOPs after should select the same option
checkbox certain branch instructions to make in the M56800E Processor
breakpoints work reliably. Settings panel. Selecting this
option increases code size by 5
Clear — Does not insert such
percent. But not selecting this
NOPs.
option risks nonrecovery after
the debugger comes to
breakpoint branch instructions.
Prefix File Specifies a file to be included at the Lets you include common
text box beginning of every assembly file of definitions without using an
the project. include directive in every file.
M56800E Processor
Use the M56800E Processor panel (Figure 4.8 on page 65) to specify the kind of code the
compiler creates. This panel is available only if the current build target uses the M56800E
Linker. Table 4.9 on page 65 explains the elements of this panel.
Globals live Checked — Compiler uses 24-bit This checkbox is available only
in lower addressing for pointer and stack if the Large Data Model
memory operations, 16-bit addressing for checkbox is checked.
checkbox access to global and static data.
Clear — Compiler uses 24-bit
addressing for all data access.
Pad pipeline Checked — Mandatory for using the If you select this option, you
for debugger debugger. Inserts NOPs after should select the same option
checkbox certain branch instructions to make in the M56800E Assembler
breakpoints work reliably. panel. Selecting this option
increases code size by 5
Clear — Does not insert such
percent. But not selecting this
NOPs.
option risks nonrecovery after
the debugger comes to
breakpoint branch instructions.
2. Counted loops in C, provided that the loop counter value is less than 65536, and that
there are no jumps to subroutines inside the loop.
If you enable separate character data sections, the compiler puts character data (and
structures containing character data) into these sections:
• .data.char — initialized static or global character data objects
• .bss.char — uninitialized static or global character data objects
• .const.data.char — const qualified character objects and static string data
You can locate these data sections in the lower half of the memory map, making sure that
the data can be addressed.
ELF Disassembler
Use the ELF Disassembler panel (Figure 4.9 on page 68) to specify the content and
display format for disassembled object files. Table 4.10 on page 69 explains the elements
of this panel. (To view a disassembled module, select Project>Disassemble from the
main-window menu bar.)
Verbose Info Checked — ELF file includes For the .symtab section,
checkbox additional information. additional information includes
numeric equivalents for some
Clear — ELF file does not include
descriptive constants. For the
additional information.
.line and .debug sections,
additional information includes
an unstructured hex dump.
M56800E Linker
Use the M56800E Linker panel (Figure 4.10 on page 71) to specify linker behavior of the
linker. (This panel is only available if the current build target uses the M56800E Linker.)
Table 4.11 on page 72 explains the elements of this panel.
Store Full Checked — Linker includes full path This checkbox is available only
Path Names names for source files. (Default) if the Generate Symbolic Info
checkbox checkbox is checked.
Clear — Linker uses only file
names.
Generate Checked — Linker generates a link A link map shows which file
Link Map map. Enables subordinate provided the definition of each
checkbox checkboxes List Unused Objects, object and function, the
Show Transitive Closure, and address of each object and
Annotate Byte Symbols. function, a memory map of
section locations, and values of
Clear — Linker does not generate a
linker-generated symbols. It
link map.
also lists unused but
unstripped symbols.
List Unused Checked — Linker includes unused This checkbox is available only
Objects objects in the link map. if the Generate Link Map
checkbox checkbox is checked.
Clear — Linker does not include
unused objects in the link map.
Show Checked — Link map includes a list Text after this table includes an
Transitive of all objects that main( ) references. example list.
Closure
Clear — Link map does not include This checkbox is available only
checkbox
this list. if the Generate Link Map
checkbox is checked.
Entry Point Specifies the program starting point Text after this table includes
text box — the first function the linker uses additional information about
when the program runs. the entry point.
Force Active Directs the linker to include symbols Separate multiple symbols with
Symbols text in the link, even if those symbols are single spaces.
box not referenced. Makes symbols
immune to deadstripping.
Check the Show Transitive Closure checkbox to have the link map include the list of
objects main( ) references. Consider the sample code of Listing 4.1 on page 74. If the
Show Transitive Closure option is in effect and you compile this code, the linker generates
a link map file that includes the list of Listing 4.2 on page 75.
return 1;
}
Use the Entry Point text box to specify the starting point for a program. The default
function this text box names is in the startup code that sets up the DSP56800E
environment before your code executes. This function and its corresponding startup code
depend on your stationery selection.
For hardware-targeted stationery, the startup code is on the path:
support\<name of hardware, e.g., M56852E>\startup
For simulator-targeted stationery, the startup code is on the path:
support\M56800E\init
The startup code performs such additional tasks as clearing the hardware stack, creating an
interrupt table, and getting the addresses for the stack start and exception handler. The
final task for the startup code is calling your main() function.
Check the Annotate Byte Symbols checkbox to have the link map include the B annotation
for byte addresses and no B annotation for word addresses (Listing 4.3 on page 75).
int myint;
char mychar;
Remote Debugging
Use the Remote Debugging panel (Figure 4.11 on page 76, Figure 4.12 on page 76) to set
parameters for communication between a DSP56800E board or Simulator and the
CodeWarrior DSP56800E debugger. Table 4.12 on page 77 explains the elements of this
panel.
JTAG Clock Specifies the JTAG clock speed for This list box is available only if
Speed text local hardware connection. (Default the Connection list box
box is 500 kilohertz.) specifies Local Hardware
Connection (CSS). The HTI will
not work properly with a clock
speed over 500 kHz.
If you click the Yes button, the previous breakpoint is cleared and the new breakpoint is
set.
If you click the Yes to all button, the Auto-clear previous hardware
breakpoint option is enabled and the previously set breakpoint is cleared out without
prompting for every subsequent occurrence.
If you click the No button, the previous breakpoint is kept and the new breakpoint request
is ignored.
Use Checked — After a reset, the IDE The Use initialization file text
initialization uses an optional hardware box specifies the file.
file checkbox initialization file before downloading
Text immediately after this
code.
table gives more information
Clear — IDE does not use a about initialization files.
hardware initialization file.
An initialization file consists of text instructions telling the debugger how to initialize the
hardware after reset, but before downloading code. You can use initialization file
commands to assign values to registers and memory locations, and to set up flash memory
parameters.
The initialization files of your IDE are on the path:
{CodeWarrior path}\M56800E Support\initialization
The name of each initialization file includes the number of the corresponding processor,
such as 568345. Each file with “_ext” enables the processor’s external memory. If the
processor has Flash memory, the initialization file with “_flash” enables both Flash and
external memory.
To set up an initialization file:
1. In the debugging M56800E Target panel, check the Use initialization file checkbox.
2. Specify the name of the initialization file, per either substep a or b:
a. Type the name in the Use initialization file text box. If the name is not a full
pathname, the debugger searches for the file in the project directory. If the file is
not in this directory, the debugger searches on the path:
{CodeWarrior path}\M56800E Support\initialization
directory.
b. Click the Choose button; the Choose file dialog box appears. Navigate to the
appropriate file. When you select the file, the system puts its name in the Use
initialization file text box.
Each text line of a command file begins with a command or the comment symbol #. The
system ignores comment lines, as well as blank lines.
Table 4.14 on page 81 lists the supported commands and their arguments. For a more
detailed description of the Flash Memory commands see “Flash Memory Commands.”
pins, the window shows pin numbers and signals. Additionally, you can have this
window show a scrollable block diagram of the microprocessor.
• CPU Structure window — This window shows the relationships of all target-
microprocessor elements, in an expandable-tree representation.
• CPU Types Overview — This reference window lists all CPUs that your Processor
Expert version supports.
• Memory Map — This window shows the CPU address space, plus mapping for
internal and external memory.
• Resource Meter — This window shows the resource allocation for the target
microprocessor.
• Peripheral Usage Inspector — This window shows which bean allocates each on-
chip peripheral.
• Installed Beans Overview — This reference window provides information about all
installed beans in your Processor Expert version.
• Driver generation — The PEI suggests, connects, and generates driver code for
embedded-system hardware, peripherals, and algorithms.
• Top-Down Design — A developer starts design by defining application behavior,
rather than by focussing on how the microcontroller works.
• Extensible beans library — This library supports many microprocessors,
peripherals, and virtual devices.
• Beans wizard — This external tool helps developers create their own custom beans.
• Extensive help information — You access this information either by selecting Help
from the Program Expert menu, or by clicking the Help button of any Processor
Expert window or dialog box.
When you start code design, the PEI generates commented code from the bean settings.
This code generation takes advantage of the Processor Expert CPU knowledge system and
solution bank, which consists of hand-written, tested code optimized for efficiency.
To add new functionalities, you select and configure additional beans, then restart code
design. Another straightforward expansion of PEI code is combining other code that you
already had produced with different tools.
The bean selector’s tree structures list all available beans; double-clicking the name adds
the bean to your project. Clicking the Quick Help button opens or closes an explanation
pane that describes the highlighted bean.
Once you determine the appropriate beans, you use the Bean Inspector (Figure 5.3 on
page 89) to fine tune each bean, making it optimal for your application.
Using the Bean Inspector to set a bean’s initialization properties automatically adds bean
initialization code to CPU initialization code. You use the Bean Inspector to adjust bean
properties, so that generated code is optimal for your application.
Beans greatly facilitate management of on-chip peripherals. When you choose a peripheral
from bean properties, the PEI presents all possible candidates. But the PEI indicates which
candidates already are allocated, and which are not compatible with current bean settings.
Open Processor none Opens the PEI for the current project.
Expert
(Available only if the current project does
not already involve the PEI.)
View (continued) Target CPU Structure Opens the CPU Structure window, which
uses an expandible tree structure to
portray the processor.
Bean Selector
The Bean Selector window (Figure 5.4 on page 93) explains which beans are available,
helping you identify those most appropriate for your application project. To open this
window, select Processor Expert > View > Bean Selector, from the main-window menu
bar.
The Bean Categories page, at the left side of this window, lists the available beans in
category order, in an expandable tree structure. Green string bean symbols identify beans
that have available licenses. Grey string bean symbols identify beans that do not have
available licenses.
The On-Chip Peripherals page lists beans available for specific peripherals, also in an
expandable tree structure. Yellow folder symbols identify peripherals fully available.
Light blue folder symbols identify partially used peripherals. Dark blue folder symbols
identify fully used peripherals.
Bean names are black; bean template names are blue. Double-click a bean name to add it
to your project.
Click the Quick Help button to add the explanation pane to the right side of the window, as
Figure 5.4 on page 93 shows. This pane describes the selected (highlighted) bean. Use the
scroll bars to read descriptions that are long.
Click the two buttons at the bottom of the window to activate or deactivate filters. If the
all/CPU filter is active, the window lists only the beans for the target CPU. If the license
filter is active, the window lists only the beans for which licenses are available.
Bean Inspector
The Bean Inspector window (Figure 5.5 on page 95) lets you modify bean properties and
other settings. To open this window, select Processor Expert > View > Bean Inspector,
from the main-window menu bar.
This window shows information about the currently selected bean — that is, the
highlighted bean name in the project-window Processor Expert page. The title of the Bean
Inspector window includes the bean name.
The Bean Inspector consists of Properties, Methods, Events, and Comment pages. The
first three pages have these columns:
• Item names — Items to be set. Double-click on group names to expand or collapse
this list. For the Method or Event page, double-clicking on an item may open the file
editor, at the corresponding code location.
• Selected settings — Possible settings for your application. To change any ON/OFF-
type setting, click the circular-arrow button. Settings with multiple possible values
have triangle symbols: click the triangle to open a context menu, then select the
appropriate value. Timing settings have an ellipsis (...) button: click this button to
open a setting dialog box.
NOTE If you have specified a target compiler, the Bean Inspector includes an
additional Build options page for the CPU bean.
If your project includes external peripherals, the Bean Inspector includes an
additional Used page. Clicking a circular-arrow button reserves a resource for
connection to an external device. Clicking the same button again frees the
resource.
The Basic, Advanced, and Expert view mode buttons, at the bottom of the window, let you
change the detail level of Bean Inspector information.
The Bean Inspector window has its own menu bar. Selections include restoring default
settings, saving the selected bean as a template, changing the bean’s icon, disconnecting
from the CPU, and several kinds of help information.
Arrows on pins indicate input, output, or bidirectional signals. As you move your cursor
over the processor pins, text boxes at the bottom of this window show the pin numbers and
signal names.
Use the control buttons at the left edge of this window to modify the depiction of the
processor. One button, for example, changes the picture view the CPU package with
peripherals. However, as Figure 5.7 on page 98 shows, it is not always possible for the
picture of a sophisticated processor to display internal peripherals.
In such a case, you can click the Always show internal peripheral devices control
button. Figure 5.8 on page 99 shows that this expands the picture size, as necessary, to
allow the peripheral representations. This view also includes bean icons (blue circles)
attached to the appropriate processor pins. Use the scroll bars to view other parts of the
processor picture.
Click the Show CPU Block Diagram to change the picture to a block diagram, as Figure
5.9 on page 100 shows. Use the scroll bars to view other parts of the diagram. (You can
bring up the block diagram as you open the Target CPU window, by selecting Processor
Expert > View > Target CPU Block Diagram, from the main-window menu bar.)
Other control buttons at the left edge of the window let you:
• Show bean icons attached to processor pins.
• Rotate the CPU picture clockwise 90 degrees.
• Toggle default and user-defined names of pins and peripherals.
• Print the CPU picture.
NOTE As you move your cursor over bean icons, peripherals, and modules, text boxes
or floating hints show information such as names, descriptions, and the
allocating beans.
And note these additional mouse control actions for the Target CPU window:
• Clicking a bean icon selects the bean in the project window’s Processor Expert page.
• Double-clicking a bean icon opens the Bean Inspector, displaying information for
that bean.
• Right-clicking a bean icon, a pin, or a peripheral opens the corresponding context
menu.
• Double-clicking an ellipsis (...) bean icon opens a context menu of all beans using
parts of the peripheral. Selecting one bean from this menu opens the Bean Inspector.
• Right-clicking an ellipsis (...) bean icon opens a context menu of all beans using parts
of the peripheral. Selecting one bean from this menu opens the bean context menu.
Pause your cursor over any block of the map to bring up a brief description.
Right-click the window to open a context menu that lets you add the selected CPU to the
project, expand the tree structure, collapse the tree structure, or get help information.
Resource Meter
The Resource Meter window (Figure 5.12 on page 104) shows the usage or availability
of processor resources. To open this window, select Processor Expert > View >
Resource Meter, from the main-window menu bar.
This window’s View menu lets you change the display contents, such as showing driver
status and information, restricting the kinds of beans the display covers, and so on.
The pages of this window reflect the peripheral categories: I/O, interrupts, timers, and
channels. The columns of each page list peripheral pins, signal names, and the allocating
beans.
Pausing your cursor over various parts of this window brings up brief descriptions of
items. This window’s View menu lets you expand or collapse the display.
d. In the Project name text box, enter a name for the project, such as LEDcontrol.
e. Click the OK button. The New Project window replaces the New window.
f. In the Project Stationery list, select TestApplications > Tools > LED > 56858.
g. Click the OK button.
h. Click the OK button. The IDE:
• Opens the project window, docking it the left of the main window. This project
window includes a Processor Expert page.
• Opens the Target CPU window, as Figure 5.15 on page 107 shows. This window
shows the CPU package and peripherals view.
• Opens the Bean Selector window, behind the Target CPU window.
NOTE If new bean icons do not appear in the Processor Expert page, the system still
may have added them to the project. Close the project, then reopen it. When
you bring the Processor Expert page to the front of the project window, the
page should show the new bean icons.
a. In the Bean Categories page of the Bean Selector window, expand the Interrupts
subentry.
b. Double-click the ExtInt bean name two times. The IDE adds these beans to your
project; new bean icons appear in the Processor Expert page.
c. You may close the Bean Inspector window.
5. Rename the eight beans GPIO_C0 — GPIO_C3, GPIO_D6, GPIO_D7, IRQA, and
IRQB.
a. In the project window’s Processor Expert page, right-click the name of the first
BitIO bean. A context menu appears.
b. Select Rename Bean. A change box appears around the bean name.
c. Type the new name GPIO_C0, then press the Enter key. The list shows the new
name; as Figure 5.17 on page 109 shows, this name still ends with BitIO.
d. Repeat substeps a, b, and c for each of the other BitIO beans, renaming them
GPIO_C1, GPIO_C2, GPIO_C3, GPIO_D6, and GPIO_D7.
e. Repeat substeps a, b, and c for the two ExtInt beans, renaming them IRQA and
IRQB. (Figure 5.18 on page 110 shows the Processor Expert page at this point.)
e. In the project window’s Processor Expert page, select the bean name GPIO_C1.
The Bean Inspector information changes accordingly.
f. Use the Pin for I/O middle-column list box to select
GPIOC1_MOSI1_TB1_PHASEB1.
g. Repeat substeps e and f, for bean GPIO_C2, to change its associated pin to
GPIOC2_MISO1_TB2_INDEX1.
h. Repeat substeps e and f, for bean GPIO_C3, to change its associated pin to
GPIOC3_SSA_B_TB3_HOME1.
i. Repeat substeps e and f, for bean GPIO_D6, to change its associated pin to
GPIOD6_TxD1.
j. Repeat substeps e and f, for bean GPIO_D7, to change its associated pin to
GPIOD7_RxD1.
k. In the project window’s Processor Expert page, select the bean name IRQA. The
Bean Inspector information changes accordingly.
l. Use the Pin middle-column list box to select IRQA_B.
m. Repeat substeps k and l, for bean IRQB, to change its associated pin to IRQB_B.
n. You may close the Bean Inspector window.
7. Enable BitIO SetDir, ClrVal, and SetVal functions.
a. In the Processor Expert page, click the plus-sign control for the GPIO_C0 bean.
The function list expands: red X symbols indicate disabled functions, green check
symbols indicate enabled functions.
b. Double-click function symbols as necessary, so that only SetDir, ClrVal, and
SetVal have green checks. (Figure 5.20 on page 112 shows this configuration.)
NOTE Listing 5.1 on page 113 shows these new lines as bold italics.
NOTE Listing 5.2 on page 116 shows custom entries as bold italics. Processor Expert
software generated all other code of the file.
/*
** #################################################################
**
** Filename : Events.C
**
** Project : LEDcontrol
**
** Processor : DSP56F836
**
** Beantype : Events
**
** Version : Driver 01.00
**
** Compiler : Metrowerks DSP C Compiler
**
** Date/Time : 3/24/2003, 1:18 PM
**
** Abstract :
**
** This is user's event module.
** Put your event handler code here.
**
** Settings :
**
**
** Contents :
**
** IRQB_OnInterrupt - void IRQB_OnInterrupt(void);
** IRQA_OnInterrupt - void IRQA_OnInterrupt(void);
**
**
** (c) Copyright UNIS, spol. s r.o. 1997-2002
**
** UNIS, spol. s r.o.
** Jundrovska 33
** 624 00 Brno
** Czech Republic
**
** http : www.processorexpert.com
** mail : info@processorexpert.com
**
** #########################################################
*/
/* MODULE Events */
#include "IRQA.h"
#include "IRQB.h"
/*
** ==========================================================
** Event : IRQB_OnInterrupt (module Events)
**
** From bean : IRQB [ExtInt]
** Description :
** This event is called when the active signal edge/level
** occurs.
** Parameters : None
** Returns : Nothing
** ==========================================================
*/
#pragma interrupt called
extern short IRQB_On;
void IRQB_OnInterrupt(void)
{
IRQB_On ^=1;
/* place your IRQB interrupt procedure body here */
}
/*
** ==========================================================
** Event : IRQA_OnInterrupt (module Events)
**
** From bean : IRQA [ExtInt]
** Description :
** This event is called when the active signal edge/level
** occurs.
** Parameters : None
** Returns : Nothing
** ===================================================================
*/
#pragma interrupt called
extern short IRQA_On;
void IRQA_OnInterrupt(void)
{
IRQA_On ^= 1;
/* place your IRQA interrupt procedure body here */
/* END Events */
/*
** ########################################################
**
** This file was created by UNIS Processor Expert 03.15 for
** the Freescale DSP56x series of microcontrollers.
**
** ##########################################################
*/
/*
** ###################################################################
** Filename : LEDcontrol.C
**
** Project : LEDcontrol
**
** Processor : DSP56F836
**
** Version : Driver 01.00
**
** Compiler : Metrowerks DSP C Compiler
**
** Date/Time : 3/24/2003, 1:18 PM
**
** Abstract :
**
** Main module.
** Here is to be placed user's code.
**
** Settings :
**
**
** Contents :
**
** No public methods
**
**
** (c) Copyright UNIS, spol. s r.o. 1997-2002
**
** UNIS, spol. s r.o.
** Jundrovska 33
** 624 00 Brno
** Czech Republic
**
** http : www.processorexpert.com
** mail : info@processorexpert.com
**
** ###################################################################
*/
/* MODULE LEDcontrol */
/*
* Application Description:
* LED program for the 56836 EVM.
*
* Pattern: "Count" from 0 to 63, using LEDs to represent the bits of
the number.
*
* Pressing the IRQA button flips LED order: commands that previously
went to LED1 go to LED6, and so forth.
* Pressing the IRQB button reverses the enabled/disabled LED states.
*
*/
{
int i;
for (i=0; i<count; ++i);
}
{
switch (num)
{
case 1: GPIO_C0_ClrVal(); break;
case 2: GPIO_C1_ClrVal(); break;
case 3: GPIO_C2_ClrVal(): break;
case 4: GPIO_C3_ClrVal(); break;
case 5: GPIO_D6_ClrVal(); break;
case 6: GPIO_D7_ClrVal(); break;
}
}
else
{
switch (num)
{
case 1: GPIO_C0_SetVal(); break;
case 2: GPIO_C1_SetVal(); break;
case 3: GPIO_C2_SetVal(); break;
case 4: GPIO_C3_SetVal(); break;
case 5: GPIO_D6_SetVal(); break;
case 6: GPIO_D7_SetVal(); break;
}
}
}
void main(void)
{
/*** Processor Expert internal initialization. DON'T REMOVE THIS
CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
IRQA_On = IRQA_GetVal() ? 1 : 0;
IRQB_On = IRQB_GetVal() ? 1 : 0;
for(;;); {
CLEARLEDS;
pattern();
/* END LEDcontrol */
/*
** ###################################################################
/*
** This file was created by UNIS Processor Expert 03.15 for
** the Freescale DSP56x series of microcontrollers.
**
** ###############################################################
*/
Number Formats
This section explains how the CodeWarrior compiler implements ordinal and floating-
point number types for 56800E processors. For more information, read limits.h and
float.h, under the M56800E Support folder.
Table 6.1 on page 122 shows the sizes and ranges of ordinal data types.
Table 6.2 on page 123 shows the sizes and ranges of the floating-point types.
Y0 16 Volatile (non-
SOC)
Y 32 Volatile (non-
SOC)
X0 16 Volatile (non-
SOC)
A2 4 Volatile (non-
SOC)
A1 16 Volatile (non-
SOC)
A0 16 Volatile (non-
SOC)
A 36 Volatile (non-
SOC)
B2 4 Volatile (non-
SOC)
B1 16 Volatile (non-
SOC)
B0 16 Volatile (non-
SOC)
B 36 Volatile (non-
SOC)
C2 4 Volatile (non-
SOC)
C1 16 Non-Volatile
(SOC)
C0 16 Non-Volatile
(SOC)
C10 32 Non-Volatile
(SOC)
D2 4 Volatile (non-
SOC)
D1 16 Non-Volatile
(SOC)
D0 16 Non-Volatile
(SOC)
D10 32 Non-Volatile
(SOC)
R1 24 Volatile (non-
SOC)
R2 24 Volatile (non-
SOC)
R3 24 Volatile (non-
SOC)
R4 24 Volatile (non-
SOC)
N 24 Volatile (non-
SOC)
N3 16 Volatile (non-
SOC)
LA 24 Volatile (non-
SOC)
SR 16 Volatile (non-
SOC)
LC 16 Volatile (non-
SOC)
The compiler always must operate with the stack pointer long aligned. This means that:
• The start-up code in the runtime first initializes the stack pointer to an odd value.
• At all times after that, the stack pointer must point to an odd word address.
• The compiler never generates an instruction that adds or subtracts an odd value from
the stack pointer.
• The compiler never generates a MOVE.W or MOVEU.W instruction that uses the
X:(SP)+ or X:(SP)- addressing mode.
Once the compiler determined that inline SP modifications are consistent in the control
flow graph, the SP’s offsets used to reference local variables, function arguments, or
temps are fixed up with knowledge of inline assembly modifications of the SP. Note, you
may freely allocate local stack storage:
1. As long as it is equally modified along all branches leading to a control flow merge
point.
2. The SP is properly aligned. The SP must be modified by an amount the compiler can
determine at compile time.
A single new pragma is defined. #pragma check_inline_sp_effects
[on|off|reset] will generate a warning if the user specifies an inline assembly
instruction which modifies the SP by a run-time dependent amount. If the pragma is not
specified, then stack offsets used to access stack-based variables will be incorrect. It is the
user’s responsibility to enable #pragma check_inline_sp_effects, if they
desire to modify the SP with inline assembly and access local stack-based variables. Note
this pragma has no effect in function level assembly functions or separate assembly only
source files (.asm files).
In general, inline assembly may be used to create arbitrary flow graphs and not all can be
detected by the compiler.
For example:
REP #3
ADDA #2,SP
This example would modify the SP by three, but the compiler would only see a
modification of one. Other cases such as these might be created by the user using inline
jumps or branches. These are dangerous constructs and are not detected by the compiler.
In cases where the SP is modified by a run-time dependent amount, a warning is issued.
#pragma check_inline_sp_effects on
int func()
{
int a=1, b=1, c;
EnterCritical();
c = a+b;
ExitCritical();
This case will work because there are no control flow merge points. SP is modified
consistently along all paths from the beginning to the end of the function and is properly
aligned.
#pragma check_inline_sp_effects on
int func()
{
int a=1, b=1, c;
if (a)
{
EnterCritical();
c = a+b;
}
else {
c = b++;
}
ExitCritical();
return (b+c);
}
This example will generate the following warning because the SP entering the
‘ExitCritical’ macro is different depending on which branch is taken in the if. Therefore,
accesses to variables a, b, or c may not be correct.
#pragma check_inline_sp_effects on
int func()
{
int a=1, b=1, c;
if (a)
{
EnterCritical();
c = a+b;
}
else {
EnterCritical();
c = b++;
}
return (b+c);
}
This example is not legal since the SP is modified by run-time dependent amount.
If all inline assembly modifications to the SP along all branches are equal approaching the
exit of a function, it is not necessary to explicitly deallocate the increased stack space. The
compiler “cleans up” the extra inline assembly stack allocation automatically at the end of
the function.
#pragma check_inline_sp_effects on
int func()
{
int a=1, b=1, c;
if (a)
{
EnterCritical();
c = a+b;
}
else {
EnterCritical();
c = b++;
}
return (b+c);
}
This example does not need to call the ‘ExitCritical’ macro because the compiler will
automatically clean up the extra inline assembly stack allocation.
• Data in program memory can be loaded and stored in a limited number of DALU
registers. Because of this, a number of register save/restore sequences can appear if
there are not enough available DALU registers. This could be a problem with
computational intensive code because the operations do not take place only in
registers anymore, and the execution of the code will be slower. This can be avoided
by using as many variables in data memory as possible.
} test;
• the compiler will signal an error when an implicit conversion between a pointer to
data in data memory and a pointer to data in program memory is attempted. For
example, using the previous definitions, the compiler gives an error for this
assignment:
pxp1 = ppx1;
Explicit conversions are allowed, but they should be used with care. An explicit
conversion for the previous assignment that is accepted by the compiler is given below:
Another consequence of this restriction is that an important part of the MSL functions that
have at least an argument that is a pointer will not work with variables in program
memory. For example:
If variable argument lists are used, this problem is generally hidden. The program is
compiled with no errors from the compiler, but it doesn't work as expected. The most
common example is the printf function:
Here, the type of the arguments is lost because printf uses a variable argument list.
Thus the compiler can not signal a type mismatch and the program will compile without
errors, but it won't work as expected, because printf assumes that all the data is stored
in data memory.
MEMORY
{
.p_RAM (RWX) : ORIGIN = 0x0082, LENGTH = 0xFF3E
.p_reserved_regs (RWX) : ORIGIN = 0xFFC0, LENGTH = 0x003F
.p_RAM2 (RWX) : ORIGIN = 0xFFFF, LENGTH = 0x0000
.x_RAM (RW) : ORIGIN = 0x0001, LENGTH = 0x7FFE #
SDM xRAM limit is 0x7FFF
}
SECTIONS
{
.application_code :
{v # .text sections
* (.text)
* (rtlib.text)
* (fp_engine.text)
* (user.text)
* (.data.pmem) # program memory initalized data
* (.const.data.pmem) # program memory constant data
* (.bss.pmem) # program memory uninitialized data
} > .p_RAM
.data :
{
# .data sections
# .bss sections
* (rtlib.bss.lo)
* (rtlib.bss)
. = ALIGN(1);
_START_BSS = .;
* (.bss.char) # used if "Emit Separate Char Data
Section" enabled
* (.bss)
_END_BSS = .;
. = ALIGN(4);
_HEAP_ADDR = .;
_HEAP_SIZE = 0x100;
_HEAP_END = _HEAP_ADDR + _HEAP_SIZE;
. = _HEAP_END;
_min_stack_size = 0x200;
_stack_addr = _HEAP_END;
_stack_end = _stack_addr + _min_stack_size;
. = _stack_end;
F_heap_addr = _HEAP_ADDR;
F_heap_end = _HEAP_END;
F_Lstack_addr = _HEAP_END;
F_start_bss = _START_BSS;
F_end_bss = _END_BSS;
} > .x_RAM
}
A peculiarity of the DSP56800E architecture is byte addresses for character (1-byte) data,
but word addresses for data of all other types. To calculate a byte address, multiply the
word address by 2. An address cannot exceed the maximum physical address, so placing
character data in the upper half of memory makes the data unaddressable. (Address
registers have a fixed width.)
For example, in the small memory model (maximum data address: 64 KB), placing
character data at 0x8001 requires an access address of 0x10002. But this access address
does not fit into 16-bit storage, as the small data memory model requires. Under your
control, the compiler increases flexibility by placing all character data into specially-
named sections as described in “Emit separate character data section checkbox.” You can
locate these sections in the lower half of the memory map, making sure that the data can
be addressed.
Extended data is data located beyond the 16-bit address boundary — as if it exists in
extended (upper) memory. Memory located below the 64K boundary is lower memory.
The compiler default arrangement is using 16-bit addresses for all data accesses. This
means that absolute addresses (X:xxxx addressing mode) are limited to 16 bits. Direct
addressing or pointer registers load or store 16-bit addresses. Indexed addressing indexes
are 16-bit quantities. The compiler treats data pointers as 16-bit pointers that you may
store in single words of memory.
If the large data memory model is enabled, the compiler accesses all data by 24-bit
addressing modes. It treats data pointers as 24-bit quantities that you may store in two
words of memory. Absolute addressing occurs as 24-bit absolute addresses. Thus, you
may access the entire 24-bit data memory, locating data objects anywhere.
You do not need to change C source code to take advantage of the large data memory
model.
Examples in DSP56800E assembly code of extended data addressing are:
The large data memory model is convenient because you can place data objects anywhere
in the 24-bit data memory map. But the model is inefficient because extended data
addressing requires more program memory and additional execution cycles.
However, all global and static data of many target applications easily fit within the 64 K
word memory boundary. With this in mind, you can check the Globals live in lower
memory checkbox of the M56800E Processor settings panel. This tells the compiler to
access global and static data with 16-bit addresses, but to use 24-bit addressing for all
pointer and stack operations. This arrangement combines the flexibility of the large data
memory model with the efficiency of the small data model’s access to globals and statics.
NOTE If you check the Globals live in lower memory checkbox, be sure to store data
in lower memory.
Table 6.6 on page 143 lists ways to load a global pointer variable, at X:0x4567, into an
address register.
int * gp1;
Optimizing Code
Register coloring is an optimization specific to DSP56800E development. The compiler
assigns two (or more) register variables to the same register, if the code does not use the
variables at the same time. The code of Listing 6.6 on page 144 does not use variables i
and j at the same time, so the compiler could store them in the same register:
short i;
int j;
However, if the code included the expression MyFunc (i+j), the variables would be in
use at the same time. The compiler would store the two variables in different registers.
NOTE Optimizations Off is best for code that you will debug after compilation.
Other optimization levels include register coloring. If you compile code with
an optimization level greater than 0 and then debug the code, register coloring
could produce unexpected results.
Variables declared volatile (or those that have the address taken) are not kept in
registers and may be useful in the presence of interrupts.
3. Run Peephole Optimization. — The compiler eliminates some compare instructions
and improves branch sequences. Peephole optimizations are small and local
optimizations that eliminate some compare instructions and improve branch
sequences. To have the compiler behave this way, specify optimization Levels 1
through 4, in the Global Optimizations settings panel.
int i;
int *ip;
void main(void)
{
i &= ~1;
/* generated codes
P: 00000082: 8054022D0001 bfclr #1,X:0x00022d
*/
(*(ip))^= 1;
/* generated codes
P:00000085: F87C022C moveu.w X:0x00022c,R0
P:00000087: 84400001 bfchg #1,X:(R0)
*/
*((int*)(0x1234))|=1;
/* generated codes
P:00000089: E4081234 move.l #4660,R0
P:0000008B: 82400001 bfset #1,X:(R0)
*/
/* generated codes
P:0000008D: E708 rts
*/
union {
word Word;
struct {
word SBK :1;
word RWU :1;
word RE :1;
word TE :1;
word REIE :1;
word RFIE :1;
word TIIE :1;
word TEIE :1;
word PT :1;
word PE :1;
word POL :1;
word WAKE :1;
word M :1;
word RSRC :1;
word SWAI :1;
word LOOP :1;
} Bits;
} SCICR;
/* Code:*/
SCICR.Bits.TE = 1; /* SCICR content is 0x0800 */
SCICR.Bits.PE = 1; /* SCICR content is 0x0002 ??? */
/* generated codes
P:00000082:874802c moveu.w #SCICR,R0
P:00000084:F0E0000 move.b X:(R0),A
P:00000086:8350008 bfset #8,A1
P:00000088:9800 move.b A1,X:(R0)
*/
/* generated codes
P:00000089:F0E00001 move.b X:(R0+1),A
P:0000008B:83500002 bfset #2,A1
P:0000008D:9804 move.b A1,X:(R0+1)
*/
However, since the writes (at P:0x88 and at P:0x8D) are byte instructions and only 16 bits
can be written to the SCICR register, the other bytes look as if they are filled with zeros
before the SCICR is overwritten.
The use of byte accesses is due to a compiler optimization that tries to generate the
smallest possible memory access.
union SCICR_union{
word Word;
struct {
word SBK :1;
word RWU :1;
word RE :1;
word TE :1;
word REIE :1;
word RFIE :1;
word TIIE :1;
word TEIE :1;
word PT :1;
word PE :1;
word POL :1;
word WAKE :1;
word M :1;
word RSRC :1;
word SWAI :1;
word LOOP :1;
} Bits;
} SCICR;
/* Code: */
/* generated codes
P:00000083:F07C022C move.w X:#SCICR,A
P:00000085:907F move.w A1, X: (SP-1)
*/
localSCICR.Bits.TE = 1;
/* generated codes
P:00000086:8AB4FFFF adda #-1,SP,R0
P:00000088:F0E00000 move.b X:(R0),A
P:0000008A:83500008 bfset #8,A1
P:0000008C:9800 move.b A1,X: (R0)
*/
localSCICR.Bits.PE = 1;
/* generated codes
P:0000008D:F0E00001 move.b X: (R0+1),A
P:0000008F:83500002 bfset #2,A1
P:00000091:9804 move.b A1,x: (R0+1)
*/
SCICR.Word = localSCICR.Word;
*/ generated codes
P:00000092:B67F022C move.w X:(SP-1),X:#SCICR
*/
short a;
short b;
long c;
.....
long d = c+((long)a*(long)b);
.....
move.w X:0x000000,Y0 ; Fa
move.w X:0x000000,B ; Fb
move.l X:0x000000,A ; Fc
imac.l B1,Y0,A
NOTE To use HSST, you must launch the target side application through the
debugger.
hsst_open
A host-side client application uses this function to open a communication channel with the
low-level target. Opening a channel that has already been opened will result in the same
channel ID being returned.
Prototype
HRESULT hsst_open (
const char* channel_name,
size_t *cid );
Parameters
channel_name
Specifies the communication channel name.
cid
Specifies the channel ID associated with the communication channel.
Returns
S_OK if the call succeeds or S_FALSE if the call fails.
hsst_close
A host-side client application uses this function to close a communication channel with the
low-level target.
Prototype
HRESULT hsst_close ( size_t channel_id ) ;
Parameters
channel_id
Specifies the channel ID of the communication channel to close.
Returns
S_OK if the call succeeds or S_FALSE if the call fails.
hsst_read
A host-side client application uses this function to read data sent by the target application
without stopping the core.
Prototype
HRESULT hsst_read (
void *data,
size_t size,
size_t nmemb,
size_t channel_id,
size_t *read );
Parameters
data
Specifies the data buffer into which data is read.
size
Specifies the size of the individual data elements to read.
nmemb
Specifies the number of data elements to read.
channel_id
Specifies the channel ID of the communication channel from which to read.
read
Contains the number of data elements read.
Returns
S_OK if the call succeeds or S_FALSE if the call fails.
hsst_write
A host-side client application uses this function to write data that the target application can
read without stopping the core.
Prototype
HRESULT hsst_write (
void *data,
size_t size,
size_t nmemb,
size_t channel_id,
size_t *written );
Parameters
data
Specifies the data buffer that holds the data to write.
size
Specifies the size of the individual data elements to write.
nmemb
Specifies the number of data elements to write.
channel_id
Specifies the channel ID of the communication channel to write to.
written
Contains the number of data elements written.
Returns
S_OK if the call succeeds or S_FALSE if the call fails.
hsst_size
A host-side client application uses this function to determine the size of unread data (in
bytes) in the communication channel.
Prototype
HRESULT hsst_size (
size_t channel_id,
size_t *unread );
Parameters
channel_id
Specifies the channel ID of the applicable communication channel.
unread
Contains the size of unread data in the communication channel.
Returns
S_OK if the call succeeds or S_FALSE if the call fails.
hsst_block_mode
A host-side client application uses this function to set a communication channel in
blocking mode. All calls to read from the specified channel block indefinitely until the
requested amount of data is available. By default, a channel starts in the blocking mode.
Prototype
HRESULT hsst_block_mode ( size_t channel_id );
Parameters
channel_id
Specifies the channel ID of the communication channel to set in blocking mode.
Returns
S_OK if the call succeeds or S_FALSE if the call fails.
hsst_noblock_mode
A host-side client application uses this function to set a communication channel in non-
blocking mode. Calls to read from the specified channel do not block for data availability.
Prototype
HRESULT hsst_noblock_mode ( size_t channel_id );
Parameters
channel_id
Specifies the channel ID of the communication channel to set in non-blocking mode.
Returns
S_OK if the call succeeds or S_FALSE if the call fails.
hsst_attach_listener
Use this function to attach a host-side client application as a listener to a specified
communication channel. The client application receives a notification whenever data is
available to read from the specified channel.
HSST notifies the client application that data is available to read from the specified
channel. The client must implement this function:
void NotifiableHSSTClient:: Update (size_t descriptor, size_t
size, size_t nmemb);
HSST calls the Notifiable HSST Client:: Update function when data is
available to read.
Prototype
HRESULT hsst_attach_listener (
size_t cid,
NotifiableHSSTClient *subscriber );
Parameters
cid
Specifies the channel ID of the communication channel to listen to.
subscriber
Specifies the address of the variable of class Notifiable HSST Client.
Returns
S_OK if the call succeeds or S_FALSE if the call fails.
hsst_detach_listener
Use this function to detach a host-side client application that you previously attached as a
listener to the specified communication channel.
Prototype
HRESULT hsst_detach_listener ( size_t cid );
Parameters
cid
Specifies the channel ID of the communication channel from which to detach a previously
specified listener.
Returns
S_OK if the call succeeds or S_FALSE if the call fails.
hsst_set_log_dir
A host-side client application uses this function to set a log directory for the specified
communication channel.
This function allows the host-side client application to use data logged from a previous
High-Speed Simultaneous Transfer (HSST) session rather than reading directly from the
board.
After the initial call to hsst_set_log_dir, the CodeWarrior software examines the
specified directory for logged data associated with the relevant channel instead of
communicating with the board to get the data. After all the data has been read from the
file, all future reads are read from the board.
To stop reading logged data, the host-side client application calls hsst_set_log_dir
with NULL as its argument. This call only affects host-side reading.
Prototype
HRESULT hsst_set_log_dir (
size_t cid,
const char* log_directory );
Parameters
cid
Specifies the channel ID of the communication channel from which to log data.
log_directory
Specifies the path to the directory in which to store temporary log files.
Returns
S_OK if the call succeeds or S_FALSE if the call fails.
NOTE Before launching the program, the IDE plugin needs to be created and placed
in the folder: CodeWarrior\bin\Plugins\Com.
#include "CodeWarriorCommands.h"
#include "HSSTInterface.h"
#include <cstdio>
#include <cstdlib>
long data[buf_size];
size_t channel_1, channel_2, read_items, written_items;
return 0;
}
HSST_open
A target application uses this function to open a bidirectional communication channel with
the host. The default setting is for the function to open an output channel in buffered
mode. Opening a channel that has already been opened will result in the same channel ID
being returned.
Prototype
HSST_STREAM* HSST_open ( const char *stream );
Parameters
stream
Passes the communication channel name.
Returns
The stream associated with the opened channel.
HSST_close
A target application uses this function to close a communication channel with the host.
Prototype
int HSST_close ( HSST_STREAM *stream );
Parameters
stream
Passes a pointer to the communication channel.
Returns
0 if the call was successful or -1 if the call was unsuccessful.
HSST_setvbuf
A target application can use this function to perform the following actions:
• Set an open channel opened in write mode to use buffered mode
Prototype
int HSST_setvbuf (
HSST_STREAM *rs,
unsigned char *buf,
int mode,
size_t size );
Parameters
rs
Specifies a pointer to the communication channel.
buf
Passes a pointer to an external buffer.
mode
Passes the buffering mode as either buffered (specified as HSSTFBUF) or unbuffered
(specified as HSSTNBUF).
size
Passes the size of the buffer.
Returns
0 if the call was successful or -1 if the call was unsuccessful.
NOTE You must flush the buffers before exiting the program to ensure that all the data
that has been written is sent to the host. For more details, see HSST_flush on
page 162.
HSST_write
A target application uses this function to write data for the host-side client application to
read.
Prototype
size_t HSST_write (
void *data,
size_t size,
size_t nmemb,
HSST_STREAM *stream );
Parameters
data
Passes a pointer to the data buffer holding the data to write.
size
Passes the size of the individual data elements to write.
nmemb
Passes the number of data elements to write.
stream
Passes a pointer to the communication channel.
Returns
The number of data elements written.
HSST_read
A target application uses this function to read data sent by the host.
Prototype
size_t HSST_read (
void *data,
size_t size,
size_t nmemb,
HSST_STREAM *stream );
Parameters
data
Passes a pointer to the data buffer into which to read the data.
size
Passes the size of the individual data elements to read.
nmemb
Passes the number of data elements to read.
stream
Passes a pointer to the communication channel.
Returns
The number of data elements read.
HSST_flush
A target application uses this function to flush out data buffered in a buffered output
channel.
Prototype
int HSST_flush ( HSST_STREAM *stream );
Parameters
stream
Passes a pointer to the communication channel. The High-Speed Simultaneous Transfer
(HSST) feature flushes all open buffered communication channels if this parameter is null.
Returns
0 if the call was successful or -1 if the call was unsuccessful.
HSST_size
A target application uses this function to determine the size of unread data (in bytes) for
the specified communication channel.
Prototype
size_t HSST_size ( HSST_STREAM *stream );
Parameters
stream
Passes a pointer to the communication channel.
Returns
The number of bytes of unread data.
HSST_raw_read
A target application uses this function to read raw data from a communication channel
(without any automatic conversion for endianness while communicating).
Prototype
size_t HSST_raw_read (
void *ptr,
size_t length,
HSST_STREAM *rs );
Parameters
ptr
Specifies the pointer that points to the buffer into which data is read.
length
Specifies the size of the buffer in bytes.
rs
Specifies a pointer to the communication channel.
Returns
The number of bytes of raw data read.
NOTE This function is useful for sending data structures (e.g., C-type structures).
HSST_raw_write
A target application uses this function to write raw data to a communication channel
(without any automatic conversion for endianness while communicating).
Prototype
size_t HSST_raw_write (
void *ptr,
size_t length,
HSST_STREAM *rs );
Parameters
ptr
Specifies the pointer that points to the buffer that holds the data to write.
length
Specifies the size of the buffer in bytes.
rs
Specifies a pointer to the communication channel.
Returns
The number of data elements written.
NOTE This function is useful for sending data structures (e.g., C-type structures).
HSST_set_log_dir
A target application uses this function to set the host-side directory for storing temporary
log files. Old logs that existed prior to the call to HSST_set_log_dir() are over-
written. Logging stops when the channel is closed or when HSST_set_log_dir() is
called with a null argument. These logs can be used by the host-side function
HSST_set_log_dir.
Prototype
int HSST_set_log_dir (
HSST_STREAM *stream,
char *dir_name );
Parameters
stream
Passes a pointer to the communication channel.
dir_name
Passes a pointer to the path to the directory in which to store temporary log files.
Returns
0 if the call was successful or -1 if the call was unsuccessful.
NOTE To restart the program after execution, click on Restart HSST as shown in
Figure 7.1 on page 166.
#include <stdio.h>
#include <stdlib.h>
#include "HSST.h"
long i, test_buffer[buf_size];
int main ( )
{
HSST_STREAM *channel_1, *channel_2;
int written_items=0;
int read_items=0;
return 0;
}
NOTE For an HSST example, see the HSST example in this path:
{CodeWarrior path}(CodeWarrior_Examples)\
DSP56800E_hsst_client-to-client
3. Configure the data target dialog box and filter dialog box.
4. Run your program to display the data (Figure 8.2 on page 168).
Memory
The Target Memory dialog box lets you graph memory contents in real-time.
Data Type
The Data Type list box lets you select the type of data to be plotted.
Data Unit
The Data Units text field lets you enter a value for number of data units to be plotted. This
option is only available when you select Memory Region Changing Over Time.
Registers
The Target Registers dialog box lets you graph the value of registers in real-time.
Select registers from the left column, and click the -> button to add them to the list of
registers to be plotted.
Variables
The Target Globals dialog box lets you graph the value of global variables in real-time.
(See Figure 8.5 on page 171.)
Select global variables from the left column, and click the -> button to add them to the list
of variables to be plotted.
HSST
The Target HSST dialog box lets you graph the value of an HSST stream in real-time.
(See Figure 8.6 on page 172.)
NOTE To plot HSST data, the data visualization tool needs its own HSST channel.
Make sure your program opens a separate channel exclusively for the data
visualization window. This will avoid impacting data transmissions on other
channels.
Channel Name
The Channel Name text field lets you specify the name of the HSST stream to be plotted.
Data Type
The Data Type list box lets you select the type of data to be plotted.
Scaling
The default scaling settings of the data visualization tools automatically scale the graph
window to fit the existing data points.
To override the automatic scaling, uncheck a scaling checkbox to enable the text field and
enter your own value.
To scale either axis logarithmically, enable the Logarithmic Scale option of the
corresponding axis.
Display
The Display settings let you change the maximum number of data points that are plotted
on the graph.
NOTE For a data visualization example that uses HSST, see the data visualization
example in this path:
{CodeWarrior path}(CodeWarrior_Examples)\
hsst_Data_Visualization
NOTE When you import a Makefile into the CodeWarrior IDE to create a
CodeWarrior project, the IDE asks you to specify the type of debugger
interface (remote connection) you want to use. To debug the generated
CodeWarrior project, you must properly configure the remote connection you
selected when you created the project.
NOTE The specific remote connections that appear in the Remote Connections list
differ between CodeWarrior products and hosts.
The Remote Connections preference panel lists all of the remote connections of which
the CodeWarrior IDE is aware. You use this preference panel to add your own remote
connections, remove remote connections, and configure existing remote connections to
suit your needs.
To add a new remote connection, click Add.
To configure an existing remote connection, select it and click Change.
To remove an existing remote connection, select it and click Remove.
A debugger protocol is the protocol the IDE uses to debug the target system. This setting
generally relates specifically to the particular device you use to physically connect to the
target system.
A connection type is the type of connection (such as CCS, USBTAP, or Simulator) the
CodeWarrior IDE uses to communicate with and control the target system.
Table 9.1 on page 178 describes each of the supported debugger protocols.
CCS 56800E Protocol Plugin Select to use a CCS hardware target system.
Each of these protocols supports one or more types of connections (CCS, USBTAP, and
Simulator). “Editing Remote Connections” on page 178 describes each supported
connection type and how to configure them.
CCS 56800E Protocol Plugin CCS Remote Connection on page 179, USBTAP on
page 181
To configure a remote connection to correspond to your particular setup, you must edit the
connection settings. You access the settings with the Edit Connection dialog box. You
can view this dialog box in one of these ways:
• In the Remote Connections IDE preference panel, select a connection from the list,
and click Edit. The Edit Connection dialog box appears.
• In the Remote Connections IDE preference panel, click Add to create a new remote
connection. The New Connection dialog box appears.
• In the Remote Debugging target settings panel, select a connection from the
Connection list box, then click the Edit Connection button. The Edit Connection
dialog box appears.
This section describes the settings for each connection type:
• CCS Remote Connection on page 179
• USBTAP on page 181
• Simulator on page 183
Table 9.3 on page 180 describes the options in this dialog box.
Option Description
Name Enter the name you want to use to refer to this remote
connection within the CodeWarrior IDE.
Use Remote CCS Check to debug code on a target system when the system
already has CCS running and connected.
Option Description
Server IP Address Enter the Internet Protocol (IP) address assigned to the
target system.
Port # Enter the port number on the target system to which the IDE
should connect for CCS operations. The default port number
for CCS hardware connections is 41475. Enter 41476 for the
CCS Simulator.
Specify CCS Executable Check to use another CCS executable file rather than the
default CCS executable file:
CWInstall\ccs\bin\ccs.exe
Multi-Core Debugging Check to debug code on a target system with multiple cores
where you need to specify the JTAG chain for debugging.
Click Choose to specify the JTAG initialization file. A JTAG
initialization file contains the names and order of the boards /
cores you want to debug.
Note: this option has no effect for the 56800E Digital Signal
Controller.
CCS Timeout Enter the duration (in seconds) after which the CCS should
attempt to reconnect to the target system if a connection
attempt fails.
USBTAP
Use this connection type to configure how the IDE uses CodeWarrior USB TAP device to
connect with the target system. This connection type is available only when the CCS
56800E Protocol Plugin debugger protocol is selected.
Figure 9.4 on page 182 shows the settings that are available to you when you select
USBTAP from the Connection Type list box in the Edit Connection dialog box.
Table 9.4 on page 182 describes the options in this dialog box.
Option Description
Name Enter the name you want to use to refer to this remote
connection within the CodeWarrior IDE.
Option Description
CCS Timeout Enter the maximum number of seconds the debugger should
wait for a response from CCS. By default, the debugger
waits up to 10 seconds for responses.
Multi-Core Debugging Check to debug code on a target system with multiple cores
where you need to specify the JTAG chain for debugging.
Click Choose to specify the JTAG initialization file. A JTAG
initialization file contains the names and order of the boards /
cores you want to debug.
Note: this option has no effect for the 56800E Digital Signal
Controller.
Reset Target on Launch Check to have the debugger send a reset signal to the target
system when you start debugging.
Clear to prevent the debugger from resetting the target
device when you start debugging.
Simulator
Use this connection type to configure the behavior of the simulator. This connection type
is available only when the 56800E Simulator Protocol Plugin debugger protocol is
selected.
Figure 9.5 on page 184 shows the setting that are available to you when you select
Simulator from the Connection Type list box in the Edit Connection dialog box.
Table 9.5 on page 184 describes the options in this dialog box.
Option Description
Name Enter the name you want to use to refer to this remote
connection within the CodeWarrior IDE.
Option Description
Name Enter the name you want to use to refer to this remote
connection within the CodeWarrior IDE.
Use default serial Check if you only have one USB TAP device connected to
number the host computer.
Clear if you have more than one USB TAP device connected
to the host computer. When this checkbox is checked, the
USB TAP Serial Number text box is available.
USB TAP Serial Number If you have more than one USB TAP connected to the host
computer, enter the serial number of the USB TAP you want
to use for debugging.
CCS Timeout Enter the maximum number of seconds the debugger should
wait for a response from CCS. By default, the debugger
waits up to 10 seconds for responses.
Interface Clock Select the clock frequency for the Ethernet TAP device. We
Frequency recommended you set this to 4 MHz.
Mem Read Delay Enter the number of additional processor cycles (in the
range: 0 through 65024) the debugger should insert as a
delay for completion of memory read operations. By default,
the debugger delays for 350 cycles.
Mem Write Delay Enter the number of additional processor cycles (in the
range: 0 through 65024) the debugger should insert as a
delay for completion of memory write operations. By default,
the debugger does not delay.
Reset Target on Launch Check to have the debugger send a reset signal to the target
system when you start debugging.
Clear to prevent the debugger from resetting the target
device when you start debugging.
Option Description
Force Shell Download Check to have the debugger start the Ethernet TAP shell
when you start debugging.
Clear to prevent the debugger from starting the Ethernet
TAP shell when you start debugging.
Do not use fast Check to have the debugger use a standard (slow)
download procedure to write to memory on the target system.
Clear to have the debugger use an optimized (fast)
download procedure to write to memory on the target
system.
Enable Logging Check to have the IDE display a log of all debugger
transactions during the debug session. If this checkbox is
checked, a protocol logging window appears when you
connect the debugger to the target system.
Note: If you set the AMCTAP_LOG_FILE environment
variable, the IDE directs log messages to the specified file.
This section explains how to control the debugger by modifying the appropriate settings
panels.
To properly debug DSP56800E software, you must set certain preferences in the Target
Settings window. The M56800E Target panel is specific to DSP56800E
development. The remaining settings panels are generic to all build targets.
Other settings panels can affect debugging. Table 9.7 on page 186 lists these panels.
NOTE Projects are set to debug locally by default. The protocol the debugger uses to
communicate with the target board, for example, PCI, is determined by how
you installed the CodeWarrior software. To modify the protocol, make changes
in the Freescale Command Converter Server window ().
If you specify that the CodeWarrior IDE start the command converter server on a
remote machine, specify the IP address of the remote machine on your network (as
described in “Setting Up a Remote Connection.”)
• Default Settings
By default, the command converter server listens on port 41475. You can specify a
different port number for the debugger to connect to if needed (as described in
“Setting Up a Remote Connection.”) This is necessary if the CCS is configured to a
port other than 41475.
After you have specified the correct settings for the command converter server (or verified
that the default settings are correct), you can download programs to a target board for
debugging.
The CodeWarrior IDE starts the command converter server at the appropriate time if you
are debugging on a local target.
Before debugging on a board connected to a remote machine, ensure the following:
• The command converter server is running on the remote host machine.
• Nobody is debugging the board connected to the remote host machine.
NOTE If the software rejects this command, your CodeWarrior HTI may be an earlier
version. Try instead the command: config cc nhti:address, or the
command: config cc Panther:address, substituting for address
the IP address of the HTI.
6. Press Enter.
7. Type the following command to save the configuration:
config save
8. Press Enter.
5. Enter the Port # to which the command converter server listens or use the default port,
which is 41475.
6. Click the OK button.
NOTE Source code is shown only for files that are in the project folder or that have
been added to the project in the project manager, and for which the IDE has
created debug information. You must navigate the file system in order to locate
sources that are outside the project folder and not in the project manager, such
as library source files.
Breakpoint
Setting
NOTE To remove the breakpoint, click the red dot. The red dot disappears.
For more details on how to set breakpoints and use watchpoints, see the CodeWarrior IDE
User’s Guide.
NOTE For the DSP56800E only one watchpoint is available. This watchpoint is only
available on hardware targets.
NOTE To view peripheral registers, select the appropriate processor form the
processor list box in the M56800E Target Settings Panel.
Viewing X: Memory
You can view X memory space values as hexadecimal values with ASCII equivalents.
You can edit these values at debug time.
NOTE On targets that have Flash ROM, you cannot edit those values in the memory
window that reside in Flash memory.
NOTE The Source pane in the Program window needs to be the active one in order
for the Data > View Memory to be activated.
NOTE You also can enter the symbolic name whose value you want to view by typing
its name in the Display field of the Memory window.
NOTE The other view options (Disassembly, Source and Mixed) do not apply when
viewing X memory.
Viewing P: Memory
You can view P memory space and edit the opcode hexadecimal values at debug time.
NOTE On targets that have Flash ROM, you cannot edit those values in the memory
window that reside in Flash memory.
Load/Save Memory
From the menu bar of the Freescale CodeWarrior window, select Debug > 56800E >
Load/Save Memory to display the Load/Save Memory dialog box (Figure
9.21 on page 203).
Use this dialog box to load and save memory at a specified location and size with a user-
specified file. You can associate a key binding with this dialog box for quick access. Press
the Tab key to cycle through the dialog box displays, which lets you quickly make
changes without using the mouse.
NOTE By default, the History combo box displays the most recent settings on
subsequent viewings.
Radio Buttons
The Load/Save Memory dialog box has two radio buttons:
• Load Memory
• Save Memory
The default is Load Memory.
With the Save Memory radio button selected, clicking OK reads the memory from the
target piece by piece and writes it to the specified file. The status field is updated with the
current progress of the operation.
Browse Button
Clicking the Browse button displays OPENFILENAME or SAVEFILENAME,
depending on whether you selected the Load Memory or Save Memory radio
button.
Fill Memory
From the menu bar of the Freescale CodeWarrior window, select Debug > 56800E >
Fill Memory to display the Fill Memory dialog box (Figure 9.22 on page 205).
Use this dialog box to fill memory at a specified location and size with user- specified raw
memory data. You can associate a key binding with this dialog box for quick access. Press
the Tab key to cycle through the dialog box display, which lets you quickly make
changes without using the mouse.
NOTE By default, the History combo box displays the most recent settings on
subsequent viewings.
actually write 0xBEEF on the target. Optionally, the string could have been set to
0xBEEF and this would do the same thing. Integers are interpreted so that the equivalent
signed integer is written to the target.
ASCII Strings
ASCII strings can be quoted to have literal interpretation of spaces inside the quotes.
Otherwise, spaces in the string are ignored. Note that if the ASCII strings are not quoted
and they are numbers, it is possible to create illegal numbers. If the number is illegal, an
error message is displayed.
Save/Restore Registers
From the menu bar of the Freescale CodeWarrior window, select Debug > 56800E >
Save/Restore Registers to display the Save/Restore Registers dialog box
(Figure 9.23 on page 208).
Use this dialog box to save and restore register groups to and from a user-specified file.
Radio Buttons
The Save/Restore Registers dialog box has two radio buttons:
• Save Registers
• Restore Registers
The default is Save Registers.
Browse Button
Clicking the Browse button displays OPENFILENAME or SAVEFILENAME,
depending on whether you selected the Restore Registers or Save Registers
radio button.
NOTE These features are only available when debugging with a hardware target.
For more information on the debugging capabilities of the EOnCE, see the EOnCE
chapter of your processor’s user manual.
Special Counters
This feature lets you use the special counting function of the EOnCE unit.
To open the EOnCE Special Counter panel (Figure 9.25 on page 211):
1. From the menu bar, select DSP56800E > Special Counter.
This panel is non-modal and will update itself whenever the processor stops.
NOTE Using the 40-bit counter will disable stepping in the debugger.
• Counter function
This pull down list allows you to choose which counting function to use.
• Set trigger(s)
Pushing this button opens the Set Trigger panel. For more information on using
this panel, see “Set Trigger Panel.”.
• Perform action
This pull down list lets you select the action that occurs when the correct conditions
are met, as set in the Set Trigger panel and the On condition pull down list.
• On condition
This pull down list lets you set the order in which a trigger and counter reaching zero
must occur to perform the action specified in Perform action.
• Counter value
This edit box should be preloaded with a non-zero counter value when setting the
counter. The counter will proceed backward until a stop condition occurs. The edit
box will contain the value of the counter and will be updated whenever the processor
stops.
Trace Buffer
The trace buffer lets you view the target addresses of change-of-flow instructions that the
program executes. The trace buffer is configured with the Trace Buffer Setup panel
(Figure 9.26 on page 213).
To open this panel:
1. From the IDE menu bar, select DSP56800E > Setup Trace Buffer.
To view the contents of the trace buffer (Figure 9.27 on page 214):
1. From the IDE menu bar, select DSP56800E > Dump Trace Buffer.
To clear triggers set with the Trace Buffer Setup panel (Figure 9.26 on page 213):
1. From the menu bar, select DSP56800E > Clear Triggers.
The Trace Buffer Setup panel options are:
• Capture Events
Select this set of checkboxes to specify which instructions get captured by the trace
buffer.
– Change of flow not taken
Select this checkbox to capture target addresses of conditional branches and
jumps that are not taken.
– Interrupt
Select this checkbox to capture addresses of interrupt vector fetches and target
addresses of RTI instructions.
– Subroutine
Select this checkbox to capture target addresses of JSR, BSR, and RTS
instructions.
• Data mask
When a data compare trigger is selected, this edit box becomes available. This value
specifies which bits of the data value are compared.
• Invert data compare
When a data compare trigger is selected, this checkbox becomes available. When
checked, the comparison result of the data value is inverted (logical NOT).
• Breakpoint counter
This edit box specifies the number of times a sub-trigger preceded by a # (see above)
must occur to cause a trigger.
• Advanced trigger
This pull down list contains options for combining triggers. The types of triggers that
can be combined are triggers set in this panel and core events.
• Core events
This set of checkboxes specify which core events are allowed to enter the breakpoint
logic and cause a trigger.
– DEBUGEV trigger enabled
When this checkbox is selected, the DEBUGEV instruction causes a core event.
– Overflow trigger enabled
When this checkbox is selected, overflow and saturation conditions in the
processor cause core events.
• Use step counter to execute
When this checkbox is selected, the processor steps through additional
instructions after a trigger is signalled. The number of instructions to be stepped
is specified in the edit box that is enabled when this checkbox is checked.
NOTE The simulator also enables the DSP56800E menu for retrieving the machine
cycle count and machine instruction count when debugging.
NOTE The data memory of the 56800E simulator is read-only from X:0xFF80 to
X:0xFFFF.
Cycle/Instruction Count
From the menu bar of the Freescale CodeWarrior window, select 56800E > Display
Cycle/Instruction count. The following window appears (Figure 9.29 on
page 218):
NOTE Cycle counting is not accurate while single stepping through source code in the
debugger. It is only accurate while running. Thus, the cycle counter is more of
a profiling tool than an interactive tool.
Press the Reset button to zero out the current machine-cycle and machine-instruction
readings.
Memory Map
Figure 9.30 Simulator Memory Map
1FFFFF $FFFFFF
Reserved
$FFCO
Program
Memory
Space
X Data
Memory
Space
$7F
Interrupt
Vectors
$0 $0
P: X:
NOTE Figure 9.30 on page 219 is the memory map configuration for the simulator.
Therefore, the simulator does not simulate each DSP568xx device’s specific
memory map, but assumes the memory map of the DSP56824.
In the Register Details window, type the name of the register (e.g., OMR, SR, IPR,
etc.) in the Description File field. The applicable register and its values appears.
By default, the CodeWarrior IDE looks in the following path when searching for register
description files.
\CodeWarrior\bin\Plugins\support\Registers\M56800E\GPR
Register description files must end with the .xml extension. Alternatively, you can use
the Browse button to locate the register description files.
Using the Format list box in the Register Details window, you can change the format in
which the CodeWarrior IDE displays the registers.
Using the Text View list box in the Register Details window, you can change the text
information the CodeWarrior IDE displays.
3. You may have to add additional access paths in the Access Path preference panel in
order to see all of the source code.
4. Choose Project > Debug to begin debugging the application.
NOTE When you debug a .elf file without a project, the IDE sets the Build before
running setting on the Build Settings panel of the IDE Preference panels to
Never. Consequently, if you open another project to debug after debugging a
.elf file, you must change the Build before running setting before you can
build the project.
The project that the CodeWarrior tools uses to create a new project for the given .elf file
is 56800E_Default_Project.xml, which is in the directory located in the path:
CodeWarrior\bin\plugins\support
You can create your own version of this file to use as a default setting when opening a
.elf file:
1. Create a new project with the default setting you want.
2. Export the project to xml format.
3. Rename the xml format of the project to 56800E_Default_Project.xml and place it in
the support directory.
NOTE Back up or rename the original version of the default xml project before
overwriting it with your own customized version.
System-Level Connect
The CodeWarrior DSP56800E debugger lets you connect to a loaded target board and
view system registers and memory. A system-level connect does not let you view
symbolic information during a connection.
NOTE The following procedure explains how to connect in the context of developing
and debugging code on a target board. However, you can select the Debug >
Connect command anytime you have a project window open, even if you
have not yet downloaded a file to your target board.
NOTE If you use the phase locked loop (PLL) to change the system speed and you are
using software or automatic breakpoints, you will need to enable the alternate
flash download sequence, as described by the “target_code_sets_hfmclkd”
command in the following section.
set_hfmclkd <value>
This command writes the value which represents the clock divider for the flash memory
to the hfmclkd register.
The value for the set_hfmclkd command depends on the frequency of the clock. If
you are using a supported EVM, this value should not be changed from the value provided
in the default initialization file. However, if you are using an unsupported board and the
clock frequency is different from that of the supported EVM, a new value must be
calculated as described in the user’s manual of the particular processor that you are using.
set_hfm_base <address>
This command sets the address of hfm_base, which is where the flash control registers
are mapped in X: memory.
set_hfm_config_base <address>
This command sets the address of hfm_config_base, which is where the flash
security values are written in program flash memory. If this command is present, the
debugger used the address to mimic part of the hardware reset behavior by copying the
protection values from the configuration field to the appropriate flash control registers.
set_hfm_verify_erase 1 | 0
If you set this to 1, the debugger verifies that the flash memory has been erased, and alerts
you if the erase failed. If this command is omitted, the flash erase is not verified.
set_hfm_verify_program 1 | 0
If you set this to 1, the debugger verifies that the flash has been programmed correctly,
and alerts you if the programming failed. If you omit this command, flash programming is
not verified.
target_code_sets_hfmclkd 1 | 0
If you set this to 1, the debugger uses an alternate launch sequence. First, the flash
memory is loaded. Next, the processor is reset to clear the hfmclkd register to allow the
correct divider to be set for the new system speed (as set by the PLL). Finally, if needed,
the RAM is loaded.
When this option is enabled, the hfmclkd register needs to be loaded in the startup code.
For more details on setting the hfmclkd register, see the chapter “Flash Memory” in the
MC56F8300 Peripheral User Manual. For a demo of the proper use of this feature, see the
example code.
Flash Lock/Unlock
The Flash Lock and Flash Unlock commands let you control the Flash security state.
The Flash Lock command enables the Flash security state. In this state, you can not read
the memory or the registers.
The Flash Unlock command disables the Flash security. This results in all the Flash
memory being erased.
NOTE The Flash Lock and Flash Unlock commands can only be enabled if the
debugger session is not running.
• The M56800E cannot single step over certain two and three-word uninterrupted
sequences. However, the debugger compensates using software breakpoints and the
trace buffer to allow single stepping in these situations. But, if these techniques
cannot be used (e.g., debugging in ROM or the trace buffer in use) single stepping
over these sequences results in the processor executing each instruction in the
sequence before stopping. The execution will be correct. Just be aware of this "slide"
in these situations.
• Debugging an application involves single-stepping through code. But if you don't
modify interrupts that are part of normal code execution, the debugger could jump to
interrupt-handler code, instead of stepping to the next instruction. By default, The
CodeWarrior debugger for DSC automatically masks all interrupt levels when the
user single steps over an instruction or a function and unmasks them afterwards.
Therefore, the user is advised to be aware of the temporary interrupt mask enable
values in Status Register (SR) when stepping over an inline assembly instruction that
copies the value of SR to another location.
NOTE For more information on the profiler library and its usage, see the CodeWarrior
Development Studio IDE 5.5 User’s Guide Profiler Supplement.
6. Enable profiling by setting the Generate code for profiling option in the M56800E
Processor settings panel or by using the profile on | off pragma to select individual
functions to profile.
NOTE For a profiler example, see the profiler example in this path:
{CodeWarrior path}(CodeWarrior_Examples)\
SimpleProfiler
NOTE To make sure that the C compiler recognizes the asm keyword, you must clear
the ANSI Keywords Only checkbox of the C/C++ Language (C Only)
settings panel.
Differences in calling conventions mean that you cannot re-use DSP56800
assembly code in the DSP56800E compiler.
Listing 11.1 on page 230 shows how to use the asm keyword with braces, to specify that
an entire function is in assembly language.
The function header can be any valid C function header; the local declarations are any
valid C local declarations.
Listing 11.2 on page 230 shows how to use the asm keyword with braces, to specify that a
block of statements or a single statement is in assembly language.
NOTE If you apply the asm keyword to one statement or a block of statements within
a function, you must not define local variables within any of the inline-
assembly statements.
8. To optimize a block of inline assembly source code, use the inline assembly directive
.optimize_iasm on before the code block. Then use the directive
.optimize_iasm off at the end of the block. (Omitting .optimize_iasm
off means that optimizations continue to the end of the function.)
Listing 11.7 on page 232 shows the C calling statement for this inline-assembly-language
function.
int x = 4, y = 2;
Listing 11.8 on page 233 is an example of a complete assembly language function. This
function writes two 16-bit integers to program memory. A separate function is required for
writing to P: memory, because C pointer variables allow access only to X: data memory.
The first parameter is a short value and the second parameter is the 16-bit address.
;”my_asm.asm”
SECTION user ;map to user defined section in CODE
ORG P: ;put the following program in P
;memory
Listing 11.9 on page 233 shows the C calling statement for this assembly language
function.
// other code...
}
Intrinsic Functions
This section explains CodeWarrior intrinsic functions. It consists of these sections:
• Implementation on page 234
• Fractional Arithmetic on page 235
• Intrinsic Functions for Math Support on page 236
• Modulo Addressing Intrinsic Functions on page 267
Implementation
The CodeWarrior IDE for DSP56800E has intrinsic functions to generate inline-assembly-
language instructions. These intrinsic functions are a CodeWarrior extension to ANSI C.
Use intrinsic functions to target specific processor instructions. For example:
• Intrinsic functions let you pass in data for specific optimized computations. For
example, ANSI C data-representation rules may make certain calculations
inefficient, forcing the program to jump to runtime math routines. Such calculations
would be coded more efficiently as assembly language instructions and intrinsic
functions.
• Intrinsic functions can control small tasks, such as enabling saturation. One method
is using inline assembly language syntax, specifying the operation in an asm block,
every time that the operation is required. But intrinsic functions let you merely set
the appropriate bit of the operating mode register.
The IDE implements intrinsic functions as inline C functions in file
intrinsics_56800E.h, in the MSL directory tree. These inline functions contain
mostly inline assembly language code. An example is the abs_s intrinsic, defined as:
Fractional Arithmetic
Many of the intrinsic functions use fractional arithmetic with implied fractional values.
An implied fractional value is a symbol declared as an integer type, but calculated as a
fractional type. Data in a memory location or register can be interpreted as fractional or
integer, depending on program needs.
All intrinsic functions that generate multiply or divide instructions perform fractional
arithmetic on implied fractional values. (These intrinsic functions are DIV, MPY, MAC,
MPYR, and MACR) The relationship between a 16-bit integer and a fractional value is:
Fractional Value = Integer Value / (215)
The relationship between a 32-bit integer and a fractional value is similar:
Fractional Value = Long Integer Value / (231)
Table 11.1 on page 236 on page 236 shows how 16- and 32-bit values can be interpreted
as either fractional or integer values.
L_negate on mult_r on
page 240 page 252
turn_off_sat on norm_l on
page 245 page 257
div_ls4q on L_shlfts on
page 249 page 265
L_shr_r on
page 266
L_shrtNs on
page 267
Absolute/Negate
The intrinsic functions of the absolute-value/negate group are:
• abs_s on page 239
• negate on page 239
• L_abs on page 240
• L_negate on page 240
abs_s
Absolute value of a 16-bit integer or fractional value returning a 16-bit result. Returns
0x7FFF for an input of 0x8000.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word16 abs_s(Word16 svar1)
Example
int result, s1 = 0xE000; /* - 0.25 */
result = abs_s(s1);
// Expected value of result: 0x2000 = 0.25
negate
Negates a 16-bit integer or fractional value returning a 16-bit result. Returns 0x7FFF for
an input of 0x8000.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word16 negate(Word16 svar1)
Example
int result, s1 = 0xE000; /* - 0.25 */
result = negate(s1);
// Expected value of result: 0x2000 = 0.25
L_abs
Absolute value of a 32-bit integer or fractional value returning a 32-bit result. Returns
0x7FFFFFFF for an input of 0x80000000.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word32 L_abs(Word32 lvar1)
Example
long result, l = 0xE0000000; /* - 0.25 */
result = L_abs(s1);
// Expected value of result: 0x20000000 = 0.25
L_negate
Negates a 32-bit integer or fractional value returning a 32-bit result. Returns 0x7FFFFFFF
for an input of 0x80000000.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word32 L_negate(Word32 lvar1)
Example
long result, l = 0xE0000000; /* - 0.25 */
result = L_negate(s1);
// Expected value of result: 0x20000000 = 0.25
Addition/Subtraction
The intrinsic functions of the addition/subtraction group are:
• add on page 241
• sub on page 241
• L_add on page 242
• L_sub on page 243
add
Addition of two 16-bit integer or fractional values, returning a 16-bit result.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word16 add(Word16 src_dst, Word16 src2)
Example
short s1 = 0x4000; /* 0.5 */
short s2 = 0x2000; /* 0.25 */
short result;
result = add(s1,s2);
// Expected value of result: 0x6000 = 0.75
sub
Subtraction of two 16-bit integer or fractional values, returning a 16-bit result.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word16 sub(Word16 src_dst, Word16 src2)
Example
short s1 = 0x4000; /* 0.5 */
short s2 = 0xE000; /* -0.25 */
short result;
result = sub(s1,s2);
// Expected value of result: 0x6000 = 0.75
L_add
Addition of two 32-bit integer or fractional values, returning a 32-bit result.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word32 L_add(Word32 src_dst, Word32 src2)
Example
long la = 0x40000000; /* 0.5 */
long lb = 0x20000000; /* 0.25 */
long result;
result = L_add(la,lb);
// Expected value of result: 0x60000000 = 0.75
L_sub
Subtraction of two 32-bit integer or fractional values, returning a 32-bit result.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word32 L_sub(Word32 src_dst, Word32 src2)
Example
long la = 0x40000000; /* 0.5 */
long lb = 0xE0000000; /* -0.25 */
long result;
result = L_sub(la,lb);
// Expected value of result: 0x60000000 = 0.75
Control
The intrinsic functions of the control group are:
• stop on page 243
• wait on page 244
• turn_off_conv_rndg on page 244
• turn_off_sat on page 245
• turn_on_conv_rndg on page 245
• turn_on_sat on page 245
stop
Generates a STOP instruction which places the processor in the low power STOP mode.
Prototype
void stop(void)
Usage
stop();
wait
Generates a WAIT instruction which places the processor in the low power WAIT mode.
Prototype
void wait(void)
Usage
wait();
turn_off_conv_rndg
Generates a sequence for disabling convergent rounding by setting the R bit in the OMR
register and waiting for the enabling to take effect.
NOTE
Prototype
void turn_off_conv_rndg(void)
Usage
turn_off_conv_rndg();
turn_off_sat
Generates a sequence for disabling automatic saturation in the MAC Output Limiter by
clearing the SA bit in the OMR register and waiting for the disabling to take effect.
Prototype
void turn_off_sat(void)
Usage
turn_off_sat();
turn_on_conv_rndg
Generates a sequence for enabling convergent rounding by clearing the R bit in the OMR
register and waiting for the enabling to take effect.
Prototype
void turn_on_conv_rndg(void)
Usage
turn_on_conv_rndg();
turn_on_sat
Generates a sequence for enabling automatic saturation in the MAC Output Limiter by
setting the SA bit in the OMR register and waiting for the enabling to take effect.
Prototype
void turn_on_sat(void)
Usage
turn_on_sat();
Deposit/Extract
The intrinsic functions of the deposit/extract group are:
extract_h
Extracts the 16 MSBs of a 32-bit integer or fractional value. Returns a 16-bit value. Does
not perform saturation. When an accumulator is the destination, zeroes out the LSP
portion. Corresponds to truncation when applied to fractional values.
Prototype
Word16 extract_h(Word32 lsrc)
Example
long l = 0x87654321;
short result;
result = extract_h(l);
// Expected value of result: 0x8765
extract_l
Extracts the 16 LSBs of a 32-bit integer or fractional value. Returns a 16-bit value. Does
not perform saturation. When an accumulator is the destination, zeroes out the LSP
portion.
Prototype
Word16 extract_l(Word32 lsrc)
Example
long l = 0x87654321;
short result;
result = extract_l(l);
L_deposit_h
Deposits the 16-bit integer or fractional value into the upper 16 bits of a 32-bit value, and
zeroes out the lower 16 bits of a 32-bit value.
Prototype
Word32 L_deposit_h(Word16 ssrc)
Example
short s1 = 0x3FFF;
long result;
result = L_deposit_h(s1);
// Expected value of result: 0x3fff0000
L_deposit_l
Deposits the 16-bit integer or fractional value into the lower 16 bits of a 32- bit value, and
sign extends the upper 16 bits of a 32-bit value.
Prototype
Word32 L_deposit_l(Word16 ssrc)
Example
short s1 = 0x7FFF;
long result;
result = L_deposit_l(s1);
// Expected value of result: 0x00007FFF
Division
The intrinsic functions of the division group are:
div_s
Single quadrant division, that is, both operands are of positive 16-bit fractional values,
returning a 16-bit result. If both operands are equal, returns 0x7FFF (occurs naturally).
Prototype
Word16 div_s(Word16 s_numerator, Word16 s_denominator)
Example
short s1=0x2000; /* 0.25 */
short s2=0x4000; /* 0.5 */
short result;
result = div_s(s1,s2);
// Expected value of result: 0.25/0.5 = 0.5 = 0x4000
div_s4q
Four quadrant division of two 16-bit fractional values, returning a 16-bit result.
Prototype
Word16 div_s4q(Word16 s_numerator, Word16 s_denominator)
Example
short s1=0xE000;/* -0.25 */
result = div_s4q(s1,s2);
// Expected value of result: -0.25/-0.5 = 0.5 = 0x4000
div_ls
Single quadrant division, that is, both operands are positive two 16-bit fractional values,
returning a 16-bit result. If both operands are equal, returns 0x7FFF (occurs naturally).
Prototype
Word16 div_ls(Word32 l_numerator, Word16 s_denominator)
Example
long l =0x20000000;/* 0.25 */
short s2=0x4000;/* 0.5 */
short result;
result = div_ls(l,s2);
// Expected value of result: 0.25/0.5 = 0.5 = 0x4000
div_ls4q
Four quadrant division of a 32-bit fractional dividend and a 16-bit fractional divisor,
returning a 16-bit result.
Prototype
Word16 div_ls4q(Word32 l_numerator, Word16 s_denominator)
Example
long l =0xE0000000;/* -0.25 */
short s2=0xC000;/* -0.5 */
short result;
result = div_ls4q(s1,s2);
// Expected value of result: -0.25/-0.5 = 0.5 = 0x4000
Multiplication/MAC
The intrinsic functions of the multiplication/MAC group are:
• mac_r on page 250
• msu_r on page 251
• mult on page 252
• mult_r on page 252
• L_mac on page 253
• L_msu on page 253
• L_mult on page 254
• L_mult_ls on page 255
mac_r
Multiply two 16-bit fractional values and add to 32-bit fractional value. Round into a 16-
bit result, saturating if necessary. When an accumulator is the destination, zeroes out the
LSP portion.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
OMR’s R bit was set to 1 at least 3 cycles before this code, that is, 2’s complement
rounding, not convergent rounding.
Prototype
Word16 mac_r(Word32 laccum, Word16 sinp1, Word16 sinp2)
Example
short s1 = 0xC000;/* - 0.5 */
short s2 = 0x4000;/* 0.5 */
short result;
long Acc = 0x0000FFFF;
result = mac_r(Acc,s1,s2);
// Expected value of result: 0xE001
msu_r
Multiply two 16-bit fractional values and subtract this product from a 32-bit fractional
value. Round into a 16-bit result, saturating if necessary. When an accumulator is the
destination, zeroes out the LSP portion.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
OMR’s R bit was set to 1 at least 3 cycles before this code, that is, 2’s complement
rounding, not convergent rounding.
Prototype
Word16 msu_r(Word32 laccum, Word16 sinp1, Word16 sinp2)
Example
short s1 = 0xC000;/* - 0.5 */
short s2 = 0x4000;/* 0.5 */
short result;
long Acc = 0x20000000;
result = msu_r(Acc,s1,s2);
// Expected value of result: 0x4000
mult
Multiply two 16-bit fractional values and truncate into a 16-bit fractional result. Saturates
only for the case of 0x8000 x 0x8000. When an accumulator is the destination, zeroes out
the LSP portion.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word16 mult(Word16 sinp1, Word16 sinp2)
Example
short s1 = 0x2000;/* 0.25 */
short s2 = 0x2000;/* 0.25 */
short result;
result = mult(s1,s2);
// Expected value of result: 0.625 = 0x0800
mult_r
Multiply two 16-bit fractional values, round into a 16-bit fractional result. Saturates
only for the case of 0x8000 x 0x8000. When an accumulator is the destination, zeroes out
the LSP portion.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
OMR’s R bit was set to 1 at least 3 cycles before this code, that is, 2’s complement
rounding, not convergent rounding.
Prototype
Word16 mult_r(Word16 sinp1, Word16 sinp2)
Example
short s1 = 0x2000;/* 0.25 */
short s2 = 0x2000;/* 0.25 */
short result;
result = mult_r(s1,s2);
// Expected value of result: 0.0625 = 0x0800
L_mac
Multiply two 16-bit fractional values and add to 32-bit fractional value, generating a 32-
bit result, saturating if necessary.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word32 L_mac(Word32 laccum, Word16 sinp1, Word16 sinp2)
Example
short s1 = 0xC000;/* - 0.5 */
short s2 = 0x4000;/* 0.5 */
long result, Acc = 0x20000000;/* 0.25 */
result = L_mac(Acc,s1,s2);
// Expected value of result: 0
L_msu
Multiply two 16-bit fractional values and subtract this product from a 32-bit fractional
value, saturating if necessary. Generates a 32-bit result.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word32 L_msu(Word32 laccum, Word16 sinp1, Word16 sinp2)
Example
short s1 = 0xC000;/* - 0.5 */
short s2 = 0xC000;/* - 0.5 */
long result, Acc = 0;
result = L_msu(Acc,s1,s2);
// Expected value of result: 0.25
L_mult
Multiply two 16-bit fractional values generating a signed 32-bit fractional result. Saturates
only for the case of 0x8000 x 0x8000.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word32 L_mult(Word16 sinp1, Word16 sinp2)
Example
short s1 = 0x2000;/* 0.25 */
short s2 = 0x2000;/* 0.25 */
long result;
result = L_mult(s1,s2);
// Expected value of result: 0.0625 = 0x08000000
L_mult_ls
Multiply one 32-bit and one-16-bit fractional value, generating a signed 32-bit fractional
result. Saturates only for the case of 0x80000000 x 0x8000.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word32 L_mult_ls(Word32 linp1, Word16 sinp2)
Example
long l1 = 0x20000000;/* 0.25 */
short s2 = 0x2000;/* 0.25 */
long result;
result = L_mult(l1,s2);
// Expected value of result: 0.625 = 0x08000000
Normalization
The intrinsic functions of the normalization group are:
• ffs_s on page 255
• norm_s on page 256
• ffs_l on page 256
• norm_l on page 257
ffs_s
Computes the number of left shifts required to normalize a 16-bit value, returning a 16-bit
result (finds 1st sign bit). Returns a shift count of 31 for an input of 0x0000.
NOTE Does not actually normalize the value! Also see the intrinsic norm_s on
page 256 which handles the case where the input == 0x0000 differently.
Prototype
Word16 ffs_s(Word16 ssrc)
Example
short s1 = 0x2000;/* .25 */
short result;
result = ffs_s(s1);
// Expected value of result: 1
norm_s
Computes the number of left shifts required to normalize a 16-bit value, returning a 16-bit
result. Returns a shift count of 0 for an input of 0x0000.
NOTE Does not actually normalize the value! This operation is not optimal on the
DSP56800E because of the case of returning 0 for an input of 0x0000. See the
intrinsic ffs_s on page 255 which is more optimal but generates a different
value for the case where the input == 0x0000.
Prototype
Word16 norm_s(Word16 ssrc)
Example
short s1 = 0x2000;/* .25 */
short result;
result = norm_s(s1);
// Expected value of result: 1
ffs_l
Computes the number of left shifts required to normalize a 32-bit value, returning a 16-bit
result (finds 1st sign bit). Returns a shift count of 31 for an input of 0x00000000.
NOTE Does not actually normalize the value! Also, see the intrinsic norm_l on
page 257 which handles the case where the input == 0x00000000 differently.
Prototype
Word16 ffs_l(Word32 lsrc)
Example
long ll = 0x20000000;/* .25 */
short result;
result = ffs_l(ll);
// Expected value of result: 1
norm_l
Computes the number of left shifts required to normalize a 32-bit value, returning a 16-bit
result. Returns a shift count of 0 for an input of 0x00000000.
NOTE Does not actually normalize the value! This operation is not optimal on the
DSP56800E because of the case of returning 0 for an input of 0x00000000. See
the intrinsic ffs_l on page 256 which is more optimal but generates a different
value for the case where the input == 0x00000000.
Prototype
Word16 norm_l(Word32 lsrc)
Example
long ll = 0x20000000;/* .25 */
short result;
result = norm_l(ll);
// Expected value of result: 1
Rounding
The intrinsic function of the rounding group is:
• round on page 258
round
Rounds a 32-bit fractional value into a 16-bit result. When an accumulator is the
destination, zeroes out the LSP portion.
Assumptions
OMR’s R bit was set to 1 at least 3 cycles before this code, that is, 2’s complement
rounding, not convergent rounding.
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word16 round(Word32 lvar1)
Example
long l = 0x12348002;/*if low 16 bits = 0xFFFF > 0x8000 then
add 1 */
short result;
result = round(l);
// Expected value of result: 0x1235
Shifting
The intrinsic functions of the shifting group are:
• shl on page 259
• shlftNs on page 260
• shlfts on page 260
• shr on page 261
• shr_r on page 262
• shrtNs on page 263
shl
Arithmetic shift of 16-bit value by a specified shift amount. If the shift count is positive, a
left shift is performed. Otherwise, a right shift is performed. Saturation may occur during a
left shift. When an accumulator is the destination, zeroes out the LSP portion.
NOTE This operation is not optimal on the DSP56800E because of the saturation
requirements and the bidirectional capability. See the intrinsic shlftNs on
page 260 or shlfts on page 260 which are more optimal.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word16 shl(Word16 sval2shft, Word16 s_shftamount)
Example
short result;
short s1 = 0x1234;
short s2 = 1;
result = shl(s1,s2);
// Expected value of result: 0x2468
shlftNs
Arithmetic shift of 16-bit value by a specified shift amount. If the shift count is positive, a
left shift is performed. Otherwise, a right shift is performed. Saturation does not occur
during a left shift. When an accumulator is the destination, zeroes out the LSP portion.
NOTE Ignores upper N-5 bits of s_shftamount except the sign bit (MSB).
Prototype
Word16 shlftNs(Word16 sval2shft, Word16 s_shftamount)
Example
short result;
short s1 = 0x1234;
short s2 = 1;
result = shlftNs(s1,s2);
// Expected value of result: 0x2468
shlfts
Arithmetic left shift of 16-bit value by a specified shift amount. Saturation does occur
during a left shift if required. When an accumulator is the destination, zeroes out the LSP
portion.
Assumptions
Assumed s_shftamount is positive.
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word16 shlfts(Word16 sval2shft, Word16 s_shftamount)
Example
short result;
short s1 = 0x1234;
short s2 = 3;
result = shlfts(s1,s2);
// Expected value of result: 0x91a0
shr
Arithmetic shift of 16-bit value by a specified shift amount. If the shift count is positive, a
right shift is performed. Otherwise, a left shift is performed. Saturation may occur during a
left shift. When an accumulator is the destination, zeroes out the LSP portion.
NOTE This operation is not optimal on the DSP56800E because of the saturation
requirements and the bidirectional capability. See the intrinsic shrtNs on
page 263 which is more optimal.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word16 shr(Word16 sval2shft, Word16 s_shftamount)
Example
short result;
short s1 = 0x2468;
short s2= 1;
result = shr(s1,s2);
// Expected value of result: 0x1234
shr_r
Arithmetic shift of 16-bit value by a specified shift amount. If the shift count is positive, a
right shift is performed. Otherwise, a left shift is performed. If a right shift is performed,
then rounding performed on result. Saturation may occur during a left shift. When an
accumulator is the destination, zeroes out the LSP portion.
NOTE This operation is not optimal on the DSP56800E because of the saturation
requirements and the bidirectional capability. See the intrinsic shrtNs on
page 263 which is more optimal.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word16 shr_r(Word16 s_val2shft, Word16 s_shftamount)
Example
short result;
short s1 = 0x2468;
short s2= 1;
result = shr(s1,s2);
// Expected value of result: 0x1234
shrtNs
Arithmetic shift of 16-bit value by a specified shift amount. If the shift count is positive, a
right shift is performed. Otherwise, a left shift is performed. Saturation does not occur
during a left shift. When an accumulator is the destination, zeroes out the LSP portion.
NOTE Ignores upper N-5 bits of s_shftamount except the sign bit (MSB).
Prototype
Word16 shrtNs(Word16 sval2shft, Word16 s_shftamount)
Example
short result;
short s1 = 0x2468;
short s2= 1;
result = shrtNs(s1,s2);
// Expected value of result: 0x1234
L_shl
Arithmetic shift of 32-bit value by a specified shift amount. If the shift count is positive, a
left shift is performed. Otherwise, a right shift is performed. Saturation may occur during a
left shift. When an accumulator is the destination, zeroes out the LSP portion.
NOTE This operation is not optimal on the DSP56800E because of the saturation
requirements and the bidirectional capability. See the intrinsic L_shlftNs on
page 264 or L_shlfts on page 265 which are more optimal.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word32 L_shl(Word32 lval2shft, Word16 s_shftamount)
Example
long result, l = 0x12345678;
short s2 = 1;
result = L_shl(l,s2);
// Expected value of result: 0x2468ACF0
L_shlftNs
Arithmetic shift of 32-bit value by a specified shift amount. If the shift count is positive, a
left shift is performed. Otherwise, a right shift is performed. Saturation does not occur
during a left shift.
NOTE Ignores upper N-5 bits of s_shftamount except the sign bit (MSB).
Prototype
Word32 L_shlftNs(Word32 lval2shft, Word16 s_shftamount)
Example
long result, l = 0x12345678;
short s2= 1;
result = L_shlftNs(l,s2);
// Expected value of result: 0x2468ACF0
L_shlfts
Arithmetic left shift of 32-bit value by a specified shift amount. Saturation does occur
during a left shift if required.
Assumptions
Assumed s_shftamount is positive.
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word32 L_shlfts(Word32 lval2shft, Word16 s_shftamount)
Example
long result, l = 0x12345678;
short s1 = 3;
L_shr
Arithmetic shift of 32-bit value by a specified shift amount. If the shift count is positive, a
right shift is performed. Otherwise, a left shift is performed. Saturation may occur during a
left shift. When an accumulator is the destination, zeroes out the LSP portion.
NOTE This operation is not optimal on the DSP56800E because of the saturation
requirements and the bidirectional capability. See the intrinsic L_shrtNs on
page 267 which is more optimal.
Assumptions
OMR’s SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word32 L_shr(Word32 lval2shft, Word16 s_shftamount)
Example
long result, l = 0x24680000;
short s2= 1;
result = L_shrtNs(l,s2);
// Expected value of result: 0x12340000
L_shr_r
Arithmetic shift of 32-bit value by a specified shift amount. If the shift count is positive, a
right shift is performed. Otherwise, a left shift is performed. If a right shift is performed,
then rounding performed on result. Saturation may occur during a left shift.
Assumptions
OMR's SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data
ALU results enabled.
Prototype
Word32 L_shr_r(Word32 lval2shft, Word16 s_shftamount)
Example
long l1 = 0x41111111;
short s2 = 1;
long result;
result = L_shr_r(l1,s2);
// Expected value of result: 0x20888889
L_shrtNs
Arithmetic shift of 32-bit value by a specified shift amount.If the shift count is positive, a
right shift is performed. Otherwise, a left shift is performed. Saturation does not occur
during a left shift.
NOTE Ignores upper N-5 bits of s_shftamount except the sign bit (MSB).
Prototype
Word32 L_shrtNs(Word32 lval2shft, Word16 s_shftamount)
Example
long result, l = 0x24680000;
short s2= 1;
result = L_shrtNs(l,s2);
// Expected value of result: 0x12340000
Address Data
0x100 0.68
0x101 0.73
0x102 0.81
0x103 0.86
0x104 0.90
0x105 0.95
The CodeWarrior C compiler for DSP56800E uses intrinsic functions to create and
manipulate modulo buffers. Normally, a modulo operation, such as the % operator,
requires a runtime function call to the arithmetic library. For normally timed critical DSP
loops, this binary operation imposes a large execution-time overhead.
The CodeWarrior implementation, however, replaces the runtime call with an efficient
implementation of circular-address modification, either by using hardware resources or by
manipulating the address mathematically.
Processors such as the DSP56800E have on-chip hardware support for modulo buffers.
Modulo control registers work with the DSP pointer update addressing modes to access a
range of addresses instead of a continuous, linear address space. But hardware support
imposes strict requirements on buffer address alignment, pointer register resources, and
limited modulo addressing instructions. For example, R0 and R1 are the only registers
available for modulo buffers.
Accordingly, the CodeWarrior C compiler uses a well-defined set of instrinsic APIs to
implement modulo buffers.
__mod_init
Initialize a modulo buffer pointer with arbitrary data using the address specified by the
<addr_expr>. This function expects a byte address. <addr_expr> is an arbitrary C
expression which normally evaluates the address at the beginning of the modulo buffer,
although it may be any legal buffer address. The <mod_desc> evaluates to a compile time
constant of either 0 or 1, represented by the modulo pointers R0 or R1, respectively. The
<mod_sz> is a compile time integer constant representing the size of the modulo buffer in
bytes. The <data_sz> is a compile time integer constant representing the size of data being
stored in the buffer in bytes. <data_sz> is usually derived from the sizeof() operator.
The __mod_init function may be called independently for each modulo pointer register.
If __mod_error has not been previously called, no record of __mod_init errors are saved.
If __mod_error has been previously called, __mod_init may set one of the error condition
in the static memory location defined by __mod_error. (See __mod_error description for a
complete list of error conditions).
Prototype
void __mod_init (
int <mod_desc>,
void * <addr_expr>,
int <mod_sz>,
int <data_sz> );
Example
Initialize a modulo buffer pointer with a buffer size of 3 and where each element is a
structure:
__mod_init(0, (void *)&struct_buf[0], 3, sizeof(struct
mystruct) );
__mod_initint16
Initialize modulo buffer pointer with integer data. The __mod_initint16 function behaves
similarly to the __mod_init function, except that word addresses are used to initialize the
modulo pointer register.
Prototype
void __mod_initint16(
int <mod_desc>,
int * <addr_expr>,
int <mod_sz> );
Example
Initialize an integer modulo buffer pointer with a buffer size of 10.
__mod_initint16(0, &int_buf[9], 10);
__mod_start
Write the modulo control register. The __mod_start function simply writes the modulo
control register (M01) for each modulo pointer register which has been previously
initialized. The values written to M01 depends on the size of the modulo buffer and which
pointers have been initialized.
Prototype
void __mod_start( void );
__mod_access
Retrieve the modulo pointer. The __mod_access function returns the modulo pointer value
specified by <mod_desc> in the R2 register, as per calling conventions. The value
returned is a byte address. The data in the modulo buffer may be read or written by a cast
and dereference of the resulting pointer.
Prototype
void *__mod_access( int <mod_desc>);
Example
Assign a value to the modulo buffer at the current pointer.
*((char *)__mod_access(0)) = (char)i;
__mod_update
Update the modulo pointer. The __mod_update function updates the modulo pointer by
the number of data type units specified in <amount>. <amount> may be negative. Of
course, the pointer will wrap to the beginning of the modulo buffer if the pointer is
advanced beyond the modulo boundaries. <amount> must be a compile time constant.
Prototype
void __mod_update( int <mod_desc>, int <amount>);
Example
Advance the modulo pointer by 2 units.
__mod_update(0, 2);
__mod_stop
Reset modulo addressing to linear addressing. This function writes the modulo control
register with a value which restore linear addressing to the R0 and R1 pointer registers.
Prototype
void __mod_stop( int <mod_desc );
__mod_getint16
Retrieve a 16-bit signed value from the modulo buffer and update the modulo pointer.This
function returns an integer value from the location pointed to by the modulo pointer. The
function then updates the modulo pointer by <amount> integer units (<amount>*2 bytes).
<amount> must be a compile time constant.
Prototype
int __mod_getint16( int <mod_desc>, int <amount> );
Example
Retrieve an integer value from a modulo buffer and update the modulo buffer pointer by
one word.
int y;
y = __mod_getint16(0, 1);
__mod_setint16
Write a 16-bit signed integer to the modulo buffer and update the pointer. This function
evaluates <int_expr> and copies the value to the location pointed to by the modulo
pointer. The modulo pointer is then updated by <amount>. <amount> must be a compile
time constant.
Prototype
int __mod_setint16( int <mod_desc>, int <int_expr>, int
<amount> );
Example
Write the modulo buffer with a value derived from an expression, do not update modulo
pointer.
__mod_setint16( 0, getrandomint(), 0 );
__mod_error
Set up a modulo error variable. This function registers a static integer address to hold the
error results from any of the modulo buffer API calls. The function returns 0 if it is
successful, 1 otherwise. The argument must be the address of a static, global integer
variable. This variable holds the result of calling each of the previously defined API
functions. This allows the user to monitor the status of the error variable and take action if
the error variable is non-zero. Typically, the user would use __mod_error during
development and remove it once debugging is complete. __mod_error generates no code,
although the error variable may occupy a word of memory. A non-zero value in the error
variable indicates a misuse of the one of the API functions. Once the error variable is set it
is reset when __mod_stop is called. The error variable contains the error number of the
last error. A successful call to an API function will not reset the error variable; only
__mod_stop will reset the error variable.
Prototype
int __mod_error( int * <static_object_addr>);
Example
Register the error number variable
static int myerrno;
assert( __mod_error(&myerrno) == 0 ) ;
/* Convenient
defines for modulo descriptors */
#define M0 0
#define M1 1
__mod_start();
int_buf[0] and wraps when the pointer value exceeds int_buf[9]. The
pointer is updated by 1 unit each time through the loop */
for ( i=0;
i<100; i++ )
{
*((int
*)__mod_access(M0)) = i;
__mod_update(M0,
1);
if ( err_code ) {
printf ( “__mod_initint16 failed\n” ) };
__mod_start();
for ( i=100;
i>0; i-- ) {
__mod_setint16(M0, i, -1);
}
__mod_stop();
Points to Remember
As you use modulo buffer intrinsic functions, keep these points in mind:
1. You must align modulo buffers properly, per the constraints that the M56800E User’s
Manual explains. There is no run-time validation of alignment. Using the modulo
buffer API on unaligned buffers will cause erratic, unpredictable behavior during data
accesses.
2. Calling __mod_start() to write to the modulo control register effectively changes
the hardware’s global-address-generation state. This change of state affects all user
function calls, run-time supporting function calls, standard library calls, and interrupts.
3. You must account for any side-effects of enabling modulo addressing. Such a side-
effect is that R0 and R1update in a modulo way.
4. If you need just one modulo pointer is required, use the R0 address register. Enabling
the R1 address register for modulo use also enables the R0 address register for modulo
use. This is true even if __mod_init() or __mod_initint16() have not
explicitly initialized R0.
5. A successful API call does not clear the error code from the error variable. Only
function __mod_stop clears the error code.
Code Meaning
Code Meaning
__mod_stop none
__mod_start none
Memory Segment
In the memory segment, available memory is divided into segments. The memory segment
format looks like Listing 12.1 on page 279.
MEMORY {
segment_1 (RWX): ORIGIN = 0x8000, LENGTH = 0x1000
segment_2 (RWX): ORIGIN = AFTER(segment_1), LENGTH = 0
The first memory segment definition (segment_1) can be broken down as follows:
• the (RWX) portion of the segment definition pertains to the ELF access permission of
the segment. The (RWX) flags imply read, write, and execute access.
• ORIGIN represents the start address of the memory segment (in this case 0x8000).
• LENGTH represents the size of the memory segment (in this case 0x1000).
Memory segments with RWX attributes are placed into P: memory while RW attributes
are placed into X: memory.
If you cannot predict how much space a segment will occupy, you can use the function
AFTER and LENGTH = 0 (unlimited length) to fill in the unknown values.
Closure Blocks
The linker is very good at deadstripping unused code and data. Sometimes, however,
symbols need to be kept in the output file even if they are never directly referenced.
Interrupt handlers, for example, are usually linked at special addresses, without any
explicit jumps to transfer control to these places.
Closure blocks provide a way to make symbols immune from deadstripping. The closure
is transitive, meaning that symbols referenced by the symbol being closed are also forced
into closure, as are any symbols referenced by those symbols, and so on.
NOTE The closure blocks need to be in place before the SECTIONS definition in the
linker command file.
• Section-level
A variant is REF_INCLUDE. It keeps a section in the link, but only if the file where it is
coming from is referenced. This is very useful to include version numbers. Listing 12.4 on
page 281 shows an example of this.
REF_INCLUDE {.version}
Sections Segment
Inside the sections segment, you define the contents of your memory segments, and define
any global symbols to be used in the output file.
The format of a typical sections block looks like Listing 12.5 on page 281.
NOTE As shown in Listing 12.5 on page 281, the .bss section always needs to be
put at the end of a segment or in a standalone segment, because it is not a
loadable section.
SECTIONS {
.section_name : #the section name is for your reference
{ #the section name must begin with a '.'
filename.c (.text) #put the .text section from filename.c
filename2.c (.text) #then the .text section from filename2.c
filename.c (.data)
filename2.c (.data)
filename.c (.bss)
filename2.c (.bss)
. = ALIGN (0x10); #align next section on 16-byte boundary.
} > segment_1 #this means "map these contents to segment_1"
.next_section_name:
{
more content descriptions
Alignment
To align data on a specific word-boundary, use the ALIGN on page 293 and
ALIGNALL on page 293 commands to bump the location counter to the preferred
boundary. For example, the following fragment uses ALIGN to bump the location counter
to the next 16-byte boundary. An example is given in Listing 12.6 on page 282.
file.c (.text)
. = ALIGN (0x10);
file.c (.data) # aligned on a word boundary.
You can also align data on a specific word-boundary with ALIGNALL, as shown in
Listing 12.7 on page 282.
file.c (.text)
ALIGNALL (0x10); #everything past this point aligned on word boundary
file.c (.data)
Arithmetic Operations
Standard C arithmetic and logical operations may be used to define and use symbols in the
linker command file. Table 12.1 on page 283 shows the order of precedence for each
operator. All operators are left-associative.
Precedence Operators
highest (1) - ˜ !
2 * / %
3 + -
4 >> <<
6 &
7 |
8 &&
9 ||
NOTE The shift operator shifts two-bits for each shift operation. The divide operator
performs division and rounding.
Comments
Comments may be added by using the pound character (#) or C++ style double-slashes (/
/). C-style comments are not accepted by the LCF parser. Listing 12.8 on page 283 shows
examples of valid comments.
Deadstrip Prevention
The M56800E linker removes unused code and data from the output file. This process is
called deadstripping. To prevent the linker from deadstripping unreferenced code and
data, use the FORCE_ACTIVE on page 294, KEEP_SECTION on page 295, and
REF_INCLUDE on page 297 directives to preserve them in the output file.
_dec_num = 99999999;
_hex_num_ = 0x9011276;
Variables that are defined within a SECTIONS section can only be used within a
SECTIONS section in a linker command file.
Global Variables
Global variables are accessed in a linker command file with an ‘F’ prepended to the
symbol name. This is because the compiler adds an ‘F’ prefix to externally defined
symbols.
Listing 12.10 on page 284 shows an example of using a global variable in a linker
command file. This example sets the global variable _foot, declared in C with the
extern keyword, to the location of the address location current counter.
F_foot = .;
If you use a global symbol in an LCF, as in Listing 12.10 on page 284, you can access it
from C program sources as shown in Listing 12.11 on page 284.
Integral Types
The syntax for linker command file expressions is very similar to the syntax of the C
programming language. All integer types are long or unsigned long.
Octal integers (commonly know as base eight integers) are specified with a leading zero,
followed by numeral in the range of zero through seven. Listing 12.13 on page 285 shows
valid octal patterns that you can put into your linker command file.
_octal_number = 012;
_octal_number2 = 03245;
Decimal integers are specified as a non-zero numeral, followed by numerals in the range
of zero through nine. To create a negative integer, use the minus sign (-) in front of the
number. Listing 12.14 on page 285 shows examples of valid decimal integers that you can
write into your linker command file.
_dec_num = 9999;
_decimalNumber = -1234;
_somenumber = 0x0F21;
_fudgefactorspace = 0XF00D;
_hexonyou = 0xcafe;
NOTE When assigning a value to a pointer variable, the value is in byte units despite
that in the linked map (.xMAP file), the variable value appears in word units.
File Selection
When defining the contents of a SECTION block, specify the source files that are
contributing to their sections.
In a large project, the list can become very long. For this reason, you have to use the
asterisk (*) keyword. The * keyword represents the filenames of every file in your project.
Note that since you have already added the .text sections from the main.c,
file2.c, and file3.c files, the * keyword does not include the .text sections
from those files again.
Function Selection
The OBJECT on page 297 keyword allows precise control over how functions are placed
within a section. For example, if the functions pad and foot are to be placed before
anything else in a section, use the code as shown in the example in Listing 12.16 on
page 286.
SECTIONS {
.program_section :
{
OBJECT (Fpad, main.c)
OBJECT (Ffoot, main.c)
* (.text)
} > ROOT
}
NOTE If an object is written once using the OBJECT function selection keyword, the
same object will not be written again if you use the '*' file selection keyword.
MEMORY {
.text (RWX) : ORIGIN = 0x8000, LENGTH = 0x0 # code (p:)
.data (RW) : ORIGIN = 0x3000, LENGTH = 0x0 # data (x:)->
RAM
}
SECTIONS{
.main_application :
{
# .text sections
*(.text)
*(.rtlib.text)
*(.fp_engine.txt)
*(user.text)
} > .text
__ROM_Address = 0x2000
.data : AT(__ROM_Address) # ROM Address definition
{
# .data sections
F__Begin_Data = .; # Start location for RAM (0x3000)
*(.data) # Write data to the section (ROM)
*(fp_state.data);
*(rtlib.data);
F__End_Data = .; # Get end location for RAM
# .bss sections
* (rtlib.bss.lo)
* (.bss)
F__ROM_Address = __ROM_Address
} > .data
}
To make the runtime copy from ROM to RAM, you need to know where the data starts in
ROM (__ROM_Address) and the size of the block in ROM you want to copy to RAM.
In the following example (Listing 12.18 on page 288), copy all variables in the data
section from ROM to RAM in C code.
Listing 12.18 ROM to RAM Copy From C After Writing Data Flash
#include <stdio.h>
#include <string.h>
int GlobalFlash = 6;
a = GlobalFlash;
return;
}
.data_in_p_flash_ROM : AT(__pROM_data_start)
{
__xRAM_data_start = .;
* (.data.char)
* (.data)
etc.
.executing_code :
{
# .text sections
etc
} > .p_flash_ROM
.example_data_section :
{
WRITEB 0x48; // 'H'
WRITEB 0x69; // 'i'
WRITEB 0x21; // '!'
}
. (location counter)
The period character (.) always maintains the current position of the output location.
Since the period always refers to a location in a SECTIONS on page 297 block, it
can not be used outside a section definition.
A period may appear anywhere a symbol is allowed. Assigning a value to period that is
greater than its current value causes the location counter to move, but the location counter
can never be decremented.
This effect can be used to create empty space in an output section. In the example below,
the location counter is moved to a position that is 0x1000 words past the symbol
FSTART_.
Example
.data :
{
*(.data)
*(.bss)
FSTART_ = .;
. = FSTART_ + 0x1000;
__end = .;
} > DATA
ADDR
The ADDR function returns the address of the named section or memory segment.
Prototype
ADDR (sectionName | segmentName | symbol)
In the example below, ADDR is used to assign the address of ROOT to the symbol
__rootbasecode.
Example
MEMORY{
ROOT (RWX) : ORIGIN = 0x8000, LENGTH = 0
}
SECTIONS{
.code :
{
__rootbasecode = ADDR(ROOT);
*(.text);
} > ROOT
}
NOTE In order to use segmentName with this command, the segmentName must start
with the period character even though segmentNames are not required to start
with the period character by the linker, as is the case with sectionName.
ALIGN
The ALIGN function returns the value of the location counter aligned on a boundary
specified by the value of alignValue. The alignValue must be a power of two.
Prototype
ALIGN(alignValue)
Note that ALIGN does not update the location counter; it only performs arithmetic. To
update the location counter, use an assignment such as:
Example
. = ALIGN(0x10); #update location counter to 16
#byte alignment
ALIGNALL
ALIGNALL is the command version of the ALIGN function. It forces the minimum
alignment for all the objects in the current segment to the value of alignValue. The
alignValue must be a power of two.
Prototype
ALIGNALL(alignValue);
Unlike its counterpart ALIGN on page 293, ALIGNALL is an actual command. It updates
the location counter as each object is written to the output.
Example
.code :
{
ALIGNALL(16); // Align code on 16 byte boundary
* (.init)
* (.text)
FORCE_ACTIVE
The FORCE_ACTIVE directive allows you to specify symbols that you do not want the
linker to deadstrip. You must specify the symbol(s) you want to keep before you use the
SECTIONS on page 297 keyword.
Prototype
FORCE_ACTIVE{ symbol[, symbol] }
INCLUDE
The INCLUDE command let you include a binary file in the output file.
Prototype
INCLUDE filename
KEEP_SECTION
The KEEP_SECTION directive allows you to specify sections that you do not want the
linker to deadstrip. You must specify the section(s) you want to keep before you use the
SECTIONS on page 297 keyword.
Prototype
KEEP_SECTION{ sectionType[, sectionType] }
MEMORY
The MEMORY directive allows you to describe the location and size of memory segment
blocks in the target. This directive specifies the linker the memory areas to avoid, and the
memory areas into which it links the code and date.
The linker command file may only contain one MEMORY directive. However, within the
confines of the MEMORY directive, you may define as many memory segments as you
wish.
Prototype
MEMORY { memory_spec }
The memory_spec is:
segmentName (accessFlags) : ORIGIN = address, LENGTH = length, [COMPRESS] [>
fileName]
segmentName can include alphanumeric characters and underscore '_' characters.
accessFlags are passed into the output ELF file (Phdr.p_flags). The
accessFlags can be:
• R-read
• W-write
• X-executable (for P: memory placement)
ORIGIN address is one of the following:
an AFTER command Use the AFTER(name [,name]) command to tell the linker to
place the memory segment after the specified segment. In
the example below, overlay1 and overlay2 are placed after
the code segment. When multiple memory segments are
specified as parameters for AFTER, the highest memory
address is used.
Example
memory{
code (RWX) : ORIGIN = 0x8000, LENGTH = 0
overlay1 (RWX) : ORIGIN = AFTER(code), LENGTH = 0
overlay2 (RWX) : ORIGIN = AFTER(code), LENGTH = 0
data (RW) : ORIGIN = 0x1000, LENGTH = 0
}
ORIGIN is the assigned address.
LENGTH is one of the following:
a value greater than If you try to put more code and data into a memory segment
zero than your specified length allows, the linker stops with an
error.
autolength by specifying When the length is 0, the linker lets you put as much code
zero and data into a memory segment as you want.
NOTE There is no overflow checking with autolength. The linker can produce an
unexpected result if you use the autolength feature without leaving enough free
memory space to contain the memory segment. For this reason, when you use
autolength, use the AFTER keyword to specify origin addresses.
> fileName is an option to write the segment to a binary file on disk instead of an ELF
program header. The binary file is put in the same folder as the ELF output file. This
option has two variants:
OBJECT
The OBJECT keyword allows control over the order in which functions are placed in the
output file.
Prototype
OBJECT (function, sourcefile.c)
It is important to note that if you write an object to the output file using the OBJECT
keyword, the same object will not be written again by either the GROUP keyword or the '*'
wildcard.
REF_INCLUDE
The REF_INCLUDE directive allows you to specify sections that you do not want the
linker to deadstrip, but only if they satisfy a certain condition: the file that contains the
section must be referenced. This is useful if you want to include version information from
your source file components. You must specify the section(s) you want to keep before you
use the SECTIONS on page 297 keyword.
Prototype
REF_INCLUDE{ sectionType [, sectionType]}
SECTIONS
A basic SECTIONS directive has the following form:
Prototype
SECTIONS { <section_spec> }
section_spec is one of the following:
Example
SECTIONS {
.text : {
F_textSegmentStart = .;
footpad.c (.text)
. = ALIGN (0x10);
padfoot.c (.text)
F_textSegmentEnd = .;
} > TEXT
.data : { *(.data) } > DATA
.bss : { *(.bss) > BSS
*(COMMON)
}
}
SIZEOF
The SIZEOF function returns the size of the given segment or section. The return value is
the size in bytes.
Prototype
SIZEOF(sectionName | segmentName | symbol)
NOTE In order to use segmentName with this command, the segmentName must start
with the period character even though segmentNames are not required to start
with the period character by the linker, as is the case with sectionName.
SIZEOFW
The SIZEOFW function returns the size of the given segment or section. The return value
is the size in words.
Prototype
SIZEOFW(sectionName | segmentName | symbol)
NOTE In order to use segmentName with this command, the segmentName must start
with the period character even though segmentNames are not required to start
with the period character by the linker, as is the case with sectionName.
WRITEB
The WRITEB command inserts a byte of data at the current address of a section.
Prototype
WRITEB (expression);
expression is any expression that returns a value 0x00 to 0xFF.
WRITEH
The WRITEH command inserts two bytes of data at the current address of a section.
Prototype
WRITEH (expression);
expression is any expression that returns a value 0x0000 to 0xFFFF.
WRITEW
The WRITEW command inserts 4 bytes of data at the current address of a section.
Prototype
WRITEW (expression);
expression is any expression that returns a value 0x00000000 to 0xFFFFFFFF.
Usage
To call the command-line tools, use the following format:
The compiler automatically calls the linker by default and any options from the linker is
passed on by the compiler to the assembler. However, you may choose to only compile
with the –c flag. In this case, the assembler will only assemble and will not call the linker.
Also, available are environment variables. These are used to provide path information for
includes or libraries, and to specify which libraries are to be included. You can specify the
variables listed in Table 13.2 on page 302.
These are the target-specific variables, and will only work with the DSP56800E tools. The
generic variables MWCIncludes, MWLibraries, MWLibraryFiles, and
MWAsmIncludes apply to all target tools on your system (such as Windows). If you only
have the DSP56800E tools installed, then you may use the generic variables if you prefer.
Response File
In addition to specifying commands in the argument list, you may also specify a “response
file”. A response file’s filename begins with an ‘@’ (for example, @file), and the contents
of the response file are commands to be inserted into the argument list. The response file
supports standard UNIX-style comments. For example, the response file @file, contain
the following:
Arguments
General Command-Line Options
----------------------------------------------------------------------
General Command-Line Options
All the options are passed to the linker unless otherwise noted.
Please see '-help usage' for details about the meaning of this help.
----------------------------------------------------------------------
-help [keyword[,...]] # global; for this tool;
# display help
zero
# means no maximum; default is 0
-maxwarnings max # specify maximum number of warnings to print,
# zero means no maximum; default is 0
-msgstyle keyword # global; set error/warning message style
mpw # use MPW message style
std # use standard message style; default
gcc # use GCC-like message style
IDE # use CW IDE-like message style
parseable # use context-free machine-parseable
message
# style
#
-[no]stderr # global; use separate stderr and stdout
streams;
# if using -nostderr, stderr goes to
stdout
Compiler
----------------------------------------------------------------
Preprocessing, Precompiling, and Input File Control Options
----------------------------------------------------------------
-c # global; compile only, do not link
-[no]codegen # global; generate object code
-[no]convertpaths # global; interpret #include filepaths
specified
# for a foreign operating system; i.e.,
# <sys/stat.h> or <:sys:stat.h>; when
enabled,
# '/' and ':' will separate directories and
# cannot be used in filenames (note: this is
# not a problem on Win32, since these
# characters are already disallowed in
# filenames; it is safe to leave the option
# 'on'); default
-cwd keyword # specify #include searching semantics: before
# searching any access paths, the path
# specified by this option will be searched
proj # begin search in current working directory;
# default
source # begin search in directory of source file
explicit # no implicit directory; only search '-I' or
# '-ir' paths
include # begin search in directory of referencing
# file
#
-D+ | -d[efine # cased; define symbol 'name' to 'value' if
name[=value] # specified, else '1'
-[no]defaults # global; passed to linker;
# same as '-[no]stdinc'; default
-dis[assemble] # global; passed to all tools;
# disassemble files to stdout
-E # global; cased; preprocess source files
-EP # global; cased; preprocess and strip out
#line
# directives
-ext extension # global; specify extension for generated object
# files; with a leading period ('.'), appends
# extension; without, replaces source file's
# extension; for 'extension', maximum length 14
# chars; default is none
-gccinc[ludes] # global; adopt GCC #include semantics: add '-I'
# paths to system list if '-I-' is not
# specified, and search directory of
# referencing file first for #includes (same as
# '-cwd include')
-i- | -I- # global; change target for '-I' access paths to
# the system list; implies '-cwd explicit';
# while compiling, user paths then system paths
# are searched when using '#include "..."; only
# system paths are searched with '#include
# <...>'
-I+ | -i p # global; cased; append access path to current
# #include list(see '-gccincludes' and '-I-')
-ir path # global; append a recursive access path to
# current #include list
-[no]keepobj[ects] # global; keep object files generated after
# invoking linker; if disabled, intermediate
# object files are temporary and deleted
after
# link stage; objects are always kept when
# compiling
-M # global; cased; scan source files for
# dependencies and emit Makefile, do not
# generate object code
-MM # global; cased; like -M, but do not list
system
# include files
-MD # global; cased; like -M, but write dependency
# map to a file and generate object code
-MMD # global; cased; like -MD, but do not list
system
# include files
-make # global; scan source files for dependencies
and
# emit Makefile, do not generate object
code -nofail # continue working after errors in earlier
files
-nolink # global; compile only, do not link
-noprecompile # do not precompile any files based on the
# filename extension
-nosyspath # global; treat #include <...> like #include
# "..."; always search both user and system
# path lists
-o file|dir # specify output filename or directory for
object
#
file(s) or text output, or output filename
# for linker if called
-P # global; cased; preprocess and send output to
# file; do not generate code
-precompile file|di # generate precompiled header from source;
write
# header to 'file' if specified, or put
header
# in 'dir'; if argument is "", write header
to
# source-specified location; if neither is
# defined, header filename is derived from
# source filename; note: the driver can tell
# whether to precompile a file based on its
# extension; '-precompile file source' then
is
# the same as '-c -o file source'
-preprocess # global; preprocess source files
-prefix file # prefix text file or precompiled header onto
all
# source files
-S # global; cased; passed to all tools;
# disassemble and send output to file
-[no]stdinc # global; use standard system include paths
# (specified by the environment variable
# %MWCIncludes%); added after all system '-
I'
# paths; default
-U+ | -u[ndefine] name # cased; undefine symbol 'name'
----------------------------------------------------------------------
Front-End C/C++ Language Options
----------------------------------------------------------------------
-ansi keyword # specify ANSI conformance options, overriding
on';
# for 'n', range 0 - 8
#
-iso_templates on|off # enable ISO C++ template parser (note:
this
# requires a different MSL C++ library);
# default is off
-[no]mapcr # reverse mapping of '\n' and '\r' so that
# '\n'==13 and '\r'==10 (for Macintosh
MPW
# compatability)
-msext keyword # [dis]allow Microsoft VC++ extensions
on # enable extensions: redefining macros,
# allowing XXX::yyy syntax when
declaring
# method yyy of class XXX,
# allowing extra commas,
# ignoring casts to the same type,
# treating function types with
equivalent
# parameter lists but different return
types
# as equal,
# allowing pointer-to-integer conversions,
# and various syntactical differences
off # disable extensions; default on non-
x86
# targets
#
-[no]multibyte[aware] # enable multi-byte character encodings
for
# source text, comments, and strings
-once # prevent header files from being processed
more
# than once
-pragma # define a pragma for the compiler such as
# "#pragma ..."
-r[equireprotos] # require prototypes
-relax_pointers # relax pointer type-checking rules
-RTTI on|off # select run-time typing information (for
C++);
# default is on
-som # enable Apple's Direct-to-SOM
implementation
-som_env_check # enables automatic SOM environment and
new
# allocation checking; implies -som
-stdkeywords on|off # allow only standard keywords; default is
off
-str[ings] keyword[,...] # specify string constant options
[no]reuse # reuse strings; equivalent strings are
the
# same object; default
[no]pool # pool strings into a single data
object
[no]readonly # make all string constants read-only
#
-strict on|off # specify ANSI strictness checking; default
is
# off
-trigraphs on|off # enable recognition of trigraphs; default is
off
-wchar_t on|off # enable wchar_t as a built-in C++ type;
default
# is on
----------------------------------------------------------------------
Optimizer Options
----------------------------------------------------------------------
DSP M56800E CodeGen Options
----------------------------------------------------------------------
-DO keyword # for this tool;
# specify hardware DO loops
off # no hardware DO loops; default
nonested # hardware DO loops but no nested ones
nested # nested hardware DO loops
#
-padpipe # for this tool;
# pad pipeline for debugger
-ldata | -largedata # for this tool;
# data space not limited to 64K
-globalsInLowerMemory # for this tool;
# globals live in lower memory; implies '-
large
# data model'
-sprog | -smallprog # for this tool;
# program space limited to 64K
----------------------------------------------------------------------
Debugging Control Options
----------------------------------------------------------------------
-g # global; cased; generate debugging
information;
# same as '-sym full'
-sym keyword[,...] # global; specify debugging options
off # do not generate debugging
information;
# default
on # turn on debugging information
full[path] # store full paths to source files
#
----------------------------------------------------------------------
C/C++ Warning Options
----------------------------------------------------------------------
-w[arn[ings]] # global; for this tool;
keyword[,...] # warning options
off # passed to all tools;
# turn off all warnings
on # passed to all tools;
# turn on most warnings
[no]cmdline # passed to all tools;
# command-line driver/parser warnings
[no]err[or] | # passed to all tools;
[no]iserr[or] # treat warnings as errors
all # turn on all warnings, require
prototypes
[no]pragmas | # illegal #pragmas
[no]illpragmas #
[no]empty[decl] # empty declarations
[no]possible | # possible unwanted effects
[no]unwanted #
[no]unusedarg # unused arguments
[no]unusedvar # unused variables
[no]unused # same as -w
[no]unusedarg,[no]unusedvar
[no]extracomma | # extra commas
[no]comma #
[no]pedantic | # pedantic error checking
[no]extended #
[no]hidevirtual | # hidden virtual functions
[no]hidden[virtual] #
[no]implicit[conv] # implicit arithmetic conversions
Linker
----------------------------------------------------------------------
Command-Line Linker Options
----------------------------------------------------------------------
ELF Linker Options
----------------------------------------------------------------------
-[no]dead[strip] # enable dead-stripping of unused code;
default
-force_active # specify a list of symbols as undefined;
useful
symbol[,...] # to force linking of static libraries
#
-keep[local] on|off # keep local symbols (such as relocations and
# output segment names) generated during
link;
# default is on
-m[ain] symbol # set main entry point for application or
shared
# library; use '-main ""' to specify no entry
# point; for 'symbol', maximum length 63
chars;
# default is 'FSTART_'
-map [keyword[,...]] # generate link map file
closure # calculate symbol closures
unused # list unused symbols
#
-sortbyaddr # sort S-records by address; implies '-srec'
-srec # generate an S-record file; ignored when
# generating static libraries
-sreceol keyword # set end-of-line separator for S-record
file;
# implies '-srec'
mac # Macintosh ('\r')
dos # DOS ('\r\n'); default
unix # Unix ('\n')
#
-sreclength length # specify length of S-records (should be a
# multiple of 4); implies '-srec'; for
# 'length', range 8 - 252; default is 64
-usebyteaddr # use byte address in S-record file;
implies
# '-srec'
-o file # specify output filename
----------------------------------------------------------------------
DSP M56800E Project Options
----------------------------------------------------------------------
-application # global; generate an application; default
-library # global; generate a static library
----------------------------------------------------------------------
DSP M56800E CodeGen Options
----------------------------------------------------------------------
-ldata | -largedata # data space not limited to 64K
----------------------------------------------------------------------
Linker C/C++ Support Options
----------------------------------------------------------------------
-Cpp_exceptions on|off # enable or disable C++ exceptions; default
is on
-dialect | -lang keyword # specify source language
c # treat source as C++ unless its extension
is
# '.c', '.h', or '.pch'; default
c++ # treat source as C++ always
#
----------------------------------------------------------------------
Debugging Control Options
----------------------------------------------------------------------
-g # global; cased; generate debugging
information;
# same as '-sym full'
-sym keyword[,...] # global; specify debugging options
off # do not generate debugging
information;
# default
on # turn on debugging information
full[path] # store full paths to source files
#
----------------------------------------------------------------------
Warning Options
----------------------------------------------------------------------
-w[arn[ings]] # global; warning options
keyword[,...] #
off # turn off all warnings
----------------------------------------------------------------------
ELF Disassembler Options
----------------------------------------------------------------------
-show keyword[,...] # specify disassembly options
only|none # as in '-show none' or, e.g.,
# '-show only,code,data'
all # show everything; default
[no]code | [no]text # show disassembly of code sections;
default
[no]comments # show comment field in code; implies '-
show
# code'; default
[no]extended # show extended mnemonics; implies '-
show
# code'; default
[no]data # show data; with '-show verbose', show
hex
# dumps of sections; default
[no]debug | [no]sym # show symbolics information; default
[no]exceptions # show exception tables; implies '-show
data';
# default
[no]headers # show ELF headers; default
[no]hex # show addresses and opcodes in code
# disassembly; implies '-show code';
default
[no]names # show symbol table; default
[no]relocs # show resolved relocations in code and
# relocation tables; default
[no]source # show source in disassembly; implies '-
show
# code'; with '-show verbose', displays
# entire source file in output, else
shows
# only four lines around each function;
# default
[no]xtables # show exception tables; default
[no]verbose # show verbose information, including hex
dump
# of program segments in
applications;
# default
#
Assembler
----------------------------------------------------------------------
Assembler Control Options
----------------------------------------------------------------------
-[no]case # identifiers are case-sensitive; default
-[no]debug # generate debug information
-[no]macro_expand # expand macro in listin output
-[no]assert_nop # add nop to resolve pipeline dependency;
default
-[no]warn_nop # emit warning when there is a pipeline
# dependency
-[no]warn_stall # emit warning when there is a hardware stall
-[no]legacy # allow legacy DSP56800 instructions(imply
# data/prog 16)
-[no]debug_workaround # Pad nop workaround debuggin issue in
some
# implementation; default
-data keyword # data memory compatibility
16 # 16 bit; default
24 # 24 bit
#
-prog keyword # program memory compatibility
16 # 16 bit; default
19 # 19 bit
21 # 21 bit
#
CodeWarrior\M56800E Support\msl\MSL_C\DSP_56800E\projects\MSL C
56800E.mcp
Do not modify any of the source files included with MSL. If you need to make changes
based on your memory configuration, make changes to the runtime libraries.
Ensure that you include one or more of the header files located in the following directory:
CodeWarrior\M56800E Support\msl\MSL_C\DSP_56800E\inc
When you add the relative-to-compiler path to your project, the appropriate MSL and
runtime files will be found by your project. If you create your project from Stationery, the
new project will have the proper support access path.
Library Configurations
There are Large Data Model and Small Data Model versions of all libraries. (Small
Program Model default is off for all library and Stationery targets.)
Metrowerks Standard Library (MSL) provides standard C library support.
The Runtime libraries provide the target-specific low-level functions below the high-level
MSL functions. There are two types of Runtime libraries:
• JTAG-based Host I/O
• HSST-based Host I/O.
For each project requiring standard C library support, a matched pair of MSL and
Runtime libraries are required (SDM or LDM pairs).
The HSST library is added to HSST client-to-client DSP56800E targets. For more
information see “High-Speed Simultaneous Transfer” on page 151.
NOTE DSP56800E stationery creates new projects with LDM and SDM targets and
the appropriate libraries.
Variables Address
To change the locations of these default values, modify the linker command file in your
DSP56800E project.
NOTE Ensure that the stack and heap memories reside in data memory.
Definitions
Stack
The stack is a last-in-first-out (LIFO) data structure. Items are pushed on the stack and
popped off the stack. The most recently added item is on top of the stack. Previously
added items are under the top, the oldest item at the bottom. The "top" of the stack may be
in low memory or high memory, depending on stack design and use. M56800E uses a 16-
bit-wide stack.
Heap
Heap is an area of memory reserved for temporary dynamic memory allocation and
access. MSL uses this space to provide heap operations such as malloc. M56800E does not
have an operating system (OS), but MSL effectively synthesizes some OS services such as
heap operations.
BSS
BSS is the memory space reserved for uninitialized data. The compiler will put all
uninitialized data here. If the Zero initialized globals live in data instead of BSS
checkbox in the M56800E Processor Panel is checked, the globals that are initialized to
zero reside in the .data section instead of the .bss section. The stationery init code
zeroes this area at startup. See the M56852 init (startup) code in this chapter for general
information and the stationery init code files for specific target implementation details.
NOTE Instead of accessing the original Stationery files themselves (in the Stationery
folder), create a new project using Stationery which will make copies of the
specific target board files such as the LCF.
Runtime Initialization
The default init function is the bootstrap or glue code that sets up the DSP56800E
environment before your code executes. This function is in the init file for each board-
specific stationery project. The routines defined in the init file performs other tasks such as
clearing the hardware stack, creating an interrupt table, and retrieving the stack start and
exception handler addresses.
The final task performed by the init function is to call the main() function.
The starting point for a program is set in the Entry Point field in the M56800E
Linker on page 71 settings panel.
The project for the DSP56800E runtime is:
When creating a project from R1.1 or later Stationery, the associated init code is specific
to the DSP56800E board. See the startup folder in the new project folder for the init code.
; -------------------------------------------------------
;
; 56852_init.asm
; sample
description: main entry point to C code.
; setup runtime for C and call main
;
; -------------------------------------------------------
;===============================
; OMR mode bits
;===============================
NL_MODE EQU $8000
CM_MODE EQU $0100
XP_MODE EQU $0080
R_MODE EQU $0020
SA_MODE EQU $0010
section rtlib
XREF F_stack_addr
org p:
GLOBAL Finit_M56852_
SUBROUTINE "Finit_M56852_",Finit_M56852_,Finit_M56852END-
Finit_M56852_
Finit_M56852_:
;
; setup the OMr with the values required by C
;
bfset #NL_MODE,omr ; ensure NL=1 (enables nsted DO
loops)
nop
nop
bfclr #(CM_MODE|XP_MODE|R_MODE|SA_MODE),omr ; ensure CM=0
(optional for C)
; ensure XP=0 to enable harvard architecture
; ensure R=0 (required for C)
; ensure SA=0 (required for C)
jsr F__init_sections
; Call main()
endsec
EOnCE Library
The EOnCE (Enhanced On Chip Emulator) library provides functions, which allows your
program to control the EOnCE. The library lets you set and clear triggers for breakpoints,
watchpoints, program traces, and counters. With several option enumerations, the library
greatly simplifies using the EOnCE from within the core, and thus eliminates the need for
a DSP56800E User Manual. The library and the debugger are coordinated so that the
debugger does not overwrite a trigger set by the library, and vice versa.
To use the EOnCE library, you must include it in your project. The name of the file is
eonce 56800E lmm.lib and it is located at:
CodeWarrior\M56800ESupport\eonce\lib
The Large Data Model option must be enabled in the M56800E Processor
preference panel. Any source file that contains code that calls any of the EOnCE Library
functions must #include eonceLib.h. This header file is located at:
CodeWarrior\M56800E Support\eonce\include
The library functions are listed below:
• _eonce_Initialize on page 327
• _eonce_SetTrigger on page 328
• _eonce_SetCounterTrigger on page 329
_eonce_Initialize
Initializes the library by setting the necessary variables.
Prototype
void _eonce_Initialize( unsigned long baseAddr, unsigned int
units )
Parameters
baseAddrunsigned long
Specifies the location in X: memory where the EOnCE registers are located.
unitsunsigned int
Specifies the number of EOnCE breakpoint units available.
Remarks
This function must be called before any other library function is called. Its parameters are
dependent on the processor being used. Instead of calling this function directly, one of the
defined macros can be called in its place. These include _eonce_Initialize56838E(),
_eonce_Initialize56852E(), and _eonce_Initialize56858E(). These macros call
_eonce_Initialize with the correct parameters for the 56838, 56852, and 56858,
respectively.
Returns
Nothing.
_eonce_SetTrigger
Sets a trigger condition used to halt the processor, cause an interrupt, or start and stop the
trace buffer. This function does not set triggers for special counting functions.
Prototype
int _eonce_SetTrigger( unsigned int unit, unsigned long
options, unsigned long value1, unsigned long value2,
unsigned long mask, unsigned int counter )
Parameters
unitunsigned int
Specifies which breakpoint unit to use.
optionsunsigned long
Describes the behavior of the trigger. For more information on the identifiers for this
parameter, please see the sub-section “Definitions” on page 322.
value1unsigned long
Specifies the address or data value to compare as defined by the options parameter.
value2unsigned long
Specifies the address or data value to compare as defined by the options parameter.
maskunsigned long
Specifies which bits of value2 to compare.
counterunsigned int
Specifies the number of successful comparison matches to count before completing trigger
sequence as defined by the options parameter
Remarks
This function sets all triggers, except those used to define the special counting function
behavior. Carefully read the list of defined identifiers that can be OR’ed into the options
parameter.
Returns
Error code as defined in the sub-section “Definitions.”
_eonce_SetCounterTrigger
Sets a trigger condition used for special counting functions.
Prototype
int _eonce_SetCounterTrigger( unsigned int unit, unsigned
long options, unsigned long value1, unsigned long value2,
unsigned long mask, unsigned int counter, unsigned long
counter2 )
Parameters
unitunsigned int
Specifies which breakpoint unit to use.
optionsunsigned long
Describes the behavior of the trigger. For more information on the identifiers for this
parameter, please see the sub-section “Definitions” on page 322.
value1unsigned long
Specifies the address or data value to compare as defined by the options parameter.
value2unsigned long
Specifies the address or data value to compare as defined by the options parameter.
maskunsigned long
Specifies which bit of value2 to compare.
counterunsigned int
Specifies the value used to pre-load the counter, which proceeds backward when
EXTEND_COUNTER is OR’ed into the options parameter. counter contains the least
significant 16-bits.
counter2unsigned long
Specifies the value used to pre-load the counter, which proceeds backward. When
EXTEND_COUNTER is OR’ed into the options parameter. counter2 contains the most
significant 24-bits. However, when EXTEND_COUNTER is not OR’ed counter2 should
be set to 0.
Remarks
This function is used to set special counting function triggers. The special counting
options are defined in the sub-section “Definitions.” Carefully read the list of defined
identifiers that can be OR’ed into the options parameter.
Returns
Error code as defined in the sub-section “Definitions.”
_eonce_ClearTrigger
Clears a previously set trigger.
Prototype
int _eonce_ClearTrigger( unsigned int unit )
Parameters
unitunsigned int
Specifies which breakpoint unit to use.
Remarks
This function clears a trigger set with the _eonce_SetTrigger or
_eonce_SetCounterTrigger functions.
Returns
Error code as defined in the sub-section “Definitions.”
_eonce_GetCounters
Retrieves the values in the two counter registers.
Prototype
int _eonce_GetCounters( unsigned int unit, unsigned int
*counter, unsigned long *counter2 )
Parameters
unitunsigned int
Specifies which breakpoint unit to use.
counterunsigned int *
Holds the value of the counter, or the least significant 16-bits, if the counter has been
extended to 40-bits.
counter2unsigned long *
Holds the most significant 24-bits if the counter has been extended to 40-bits. This
parameter must be a valid pointer even if the counter has not been extended.
Remarks
This function retrieves the value of the counter of the specified breakpoint unit. This
function is most useful when using the special counting function of the breakpoint, but can
also be used to retrieve the trigger occurrence counter.
Returns
Error code as defined in the sub-section “Definitions.”
_eonce_GetCounterStatus
Retrieves the status of the breakpoint counter.
Prototype
int _eonce_GetCounters( char *counterIsZero, char
*counterIsStopped)
Parameters
counterIsZero char *
Returns a 1 if the breakpoint counter has reached zero.
counterIsStopped char *
Returns a 1 if the breakpoint counter has been stopped by a Counter Stop Trigger.
Remarks
This function returns the state of the breakpoint counter when using the special counting
function.
Returns
Error code as defined in the sub-section “Definitions.”
_eonce_SetupTraceBuffer
Configures the behavior of the trace buffer.
Prototype
int _eonce_SetupTraceBuffer( unsigned int options )
Parameters
optionsunsigned int
Describes the behavior of the trace buffer. Please see the section Definitions for more
information on the identifiers for this parameter.
Remarks
Sets the behavior of the trace buffer. Triggers can also be set to start and stop trace buffer
capture using the _eonce_SetTrigger function.
Returns
Error code as defined in the sub-section “Definitions.”
_eonce_GetTraceBuffer
Retrieves the contents of the trace buffer.
Prototype
int _eonce_GetTraceBuffer( unsigned int *count, unsigned long
*buffer )
Parameters
countunsigned int *
Passes in the size of the buffer; if 0 is passed in, the contents of the trace buffer are not
retrieved, instead the number of entries in the trace buffer are returned in count.
bufferunsigned long *
Points to an array in which the contents of the trace buffer are returned starting with the
oldest entry.
Remarks
This function retrieves the addresses contained in the trace buffer. The addresses represent
the program execution point when certain change-of-flow events occur. The trace buffer
behavior, including capture events, can be configured using _eonce_SetupTraceBuffer.
Returns
Error code as defined in the sub-section “Definitions.”
_eonce_ClearTraceBuffer
Clears the contents of the trace buffer.
Prototype
int _eonce_ClearTraceBuffer( )
Parameters
None.
Remarks
This function clears the trace buffer and is useful when you want a fresh set of data. It is
necessary to resume capturing when the trace buffer is full and configured to stop
capturing.
Returns
Error code as defined in the sub-section “Definitions.”
_eonce_StartTraceBuffer
Resumes trace buffer capturing.
Prototype
int _eonce_StartTraceBuffer( )
Parameters
None.
Remarks
This function causes the trace buffer to immediately start capturing.
Returns
Error code as defined in the sub-section “Definitions.”
_eonce_HaltTraceBuffer
Halts trace buffer capturing.
Prototype
int _eonce_HaltTraceBuffer( )
Parameters
None.
Remarks
Causes the trace buffer to immediately stop capturing.
Returns
Error code as defined in the sub-section “Definitions.”
_eonce_EnableDEBUGEV
Allows or disallows a DEBUGEV instruction to cause a core event in breakpoint unit 0.
Prototype
int _eonce_EnableDEBUGEV( char enable )
Parameters
enablechar
If a non-zero value, allows the DEBUGEV instruction to cause a core event. If a zero
value, prevents the DEBUGEV instruction from causing a core event.
Remarks
This function configures the behavior for the DEBUGEV instructions. For a core event to
occur, breakpoint unit 0 must be activated by setting a trigger using the
_eonce_SetTrigger or _eonce_SetCounterTrigger functions.
Returns
Error code as defined in the sub-section “Definitions.”
_eonce_EnableLimitTrigger
Allows or disallows a limit trigger to cause a core event in breakpoint unit 0.
Prototype
int _eonce_EnableLimitTrigger( char enable )
Parameters
enablechar
If a non-zero value, allows this instruction to cause a core event. If a zero value, prevents
this instruction from causing a core event.
Remarks
This function configures the behavior for overflow and saturation conditions in the
processor core. For a core event to occur, breakpoint unit 0 must be activated by setting a
trigger using the _eonce_SetTrigger or _eonce_SetCounterTrigger functions.
Returns
Error code as defined in the sub-section “Definitions.”
Definitions
This sub-section defines:
• Return Codes on page 336
• Normal Trigger Modes on page 337
• Counter Trigger Modes on page 338
• Data Selection Modes on page 340
• on page 340Counter Function Modes on page 340
• Normal Unit Action Options on page 341
• Counter Unit Action Options on page 341
• Accumulating Trigger Options on page 342
• Miscellaneous Trigger Options on page 343
• Trace Buffer Capture Options on page 343
• Trace Buffer Full Options on page 344
• Miscellaneous Trace Buffer Option on page 345
Return Codes
Every function except _eonce_Initialize returns one of the error codes in Table 14.4 on
page 336.
EONCE_ERR_NONE No error.
B1PA_N
B1PR_N
B1PW_N
B2PF_N
B1XA_OR_B2PF_N
B1XA_N_OR_B2PF
B1PF_OR_B2PF_N
B1PA_OR_B2PF_N
B1PA_N_OR_B2PF
B1PF_OR_N_B2PF
B1PA_OR_N_B2PF
B1XR_AND_N_B2DR
B1XW_AND_N_B2DW
B1XA_AND_N_B2DRW
B1PF_N_THEN_B2PF
B2PF_THEN_B1PF_N
B1PA_N_THEN_B2PF
B1PA_THEN_B2PF_N
B2PF_N_THEN_B1PA
B2PF_THEN_B1PA_N
B1XA_N_THEN_B2PF
B1XA_THEN_B2PF_N
B2PF_N_THEN_B1XA
B2PF_THEN_B1XA_N
B1XW_N_THEN_B2PF
B1XW_THEN_B2PF_N
B2PF_N_THEN_B1XW
B2PF_THEN_B1XW_N
B1XR_N_THEN_B2PF
B1XR_THEN_B2PF_N
B2PF_N_THEN_B1XR
B2PF_THEN_B1XR_N
B1PF_STB_B2PF_HTB
B1PA_STB_B2PF_HTB
B2PF_STB_B1PA_HTB
Defined Identifier Key for Normal Trigger Modes
A memory access
R memory read
W memory write
B1PA
B1PR
B1PW
B2PF
B1XA_OR_B2PF
B1PF_OR_B2PF
B1PA_OR_B2PF
B1XR_AND_B2DR
B1XW_AND_B2DW
B1XA_AND_B2DRW
B1PF_THEN_B2PF
B1PA_THEN_B2PF
B2PF_THEN_B1PA
B1XA_THEN_B2PF
B2PF_THEN_B1XA
B1XW_THEN_B2PF
B2PF_THEN_B1XW
B1XR_THEN_B2PF
B2PF_THEN_B1XR
B1PF_SC_B2PF_HC
B1PA_SC_B2PF_HC
B2PF_SC_B1PA_HC
A memory access
R memory read
W memory write
Defined Description
Identifiers
One of the defined identifiers in Table 14.12 on page 343 must be OR’ed into the options
parameter of the _eonce_SetTrigger function when a breakpoint unit other than unit 0 is
being configured.
Overview
The DSP56800x New Project Wizard supports the DSP56800x processors listed in Table
B.1 on page 349.
Table B.1 Supported DSP56800x Processors for the New Project Wizard
DSP56800 DSP56800E
DSP56F802 DSP56854
DSP56F803 DSP56855
DSP56F805 DSP56857
DSP56F807 DSP56858
DSP56F826 MC56F8013
DSP56F827 MC56F8014
MC56F8023
MC56F8025
MC56F8036
MC56F8037
MC56F8122
MC56F8123
Table B.1 Supported DSP56800x Processors for the New Project Wizard (continued)
DSP56800 DSP56800E
MC56F8145
MC56F8146
MC56F8147
MC56F8155
MC56F8156
MC56F8157
MC56F8165
MC56F8166
MC56F8167
MC56F8322
MC56F8323
MC56F8335
MC56F8345
MC56F8346
MC56F8356
MC56F8357
MC56F8365
MC56F8366
MC56F8367
Wizard rules for the DSP56800x New Project Wizard are described in the following sub-
sections:
• Page Rules on page 351
• Resulting Target Rules on page 352
• on page 353Rule Notes on page 353
Click on the following link for details about the DSP56800x New Project Wizard
Graphical User Interface:
Page Rules
The page rules governing the wizard page flow for the simulator and the different
processors are shown in the Table B.2 on page 351, Table B.3 on page 351, Table B.4 on
page 352, and Table B.5 on page 352.
Table B.2 Page Rules for the Simulator, DSP56F801 (60 and 80 MHz), DSP56F802,
MC56F801x, MC56F802x, MC56F803x, MC56F812x, and MC56F832x
DSP56F801 60 MHz
DSP56F801 80 MHz
DSP56F802
MC56F801x
MC56F802x
MC56F803x
MC56F812x
MC56F832x
Table B.3 Page Rules for the DSP56F803, DSP56F805, DSP56F807, DSP56F826, and
DSP56F827
DSP56F807
DSP56F826
DSP56F827
Table B.4 Page Rules for the DSP56852, DSP56853, DSP56854, DSP56855, DSP56857,
and DSP56858
DSP56854
DSP56855
DSP56857
DSP56858
Table B.5 Page Rules for the MC56F814x, MC56F815x, MC56F816x, MC56F833x,
MC56F834x, MC56F835x, and MC56F836x
MC56F816x
MC56F833x
MC56F834x
MC56F835x
MC56F836x
56800 Simulator Target with Non-HostIO Library and Target with Host IO
Library
DSP5685x (Small Data Model and Small Data Model with HSST) or
(Large Data Model and Large Data Model with HSST)
Rule Notes
Additional notes for the DSP56800x New Project Wizard rules are:
• The DSP56800x New Project Wizard uses the DSP56800x EABI Stationery for all
projects. Anything that is in the DSP56800x EABI
Stationery will be in the wizard-created projects depending on the wizard choices.
• The DSP56800x EABI Stationery has all possible targets, streamlined and tuned
with the DSP56800x New Project Wizard in mind.
• The DSP56800x New Project Wizard creates the entire simulator project with all the
available targets in context of “Stationery as documentation and example.”
Target Pages
When invoked, the New Project Wizard first shows a dynamically created list of
supported target families and processors or simulators. Each DSP56800x family is
associated with a subset of supported processors and a simulator (Figure B.3 on page 357,
Figure B.4 on page 358, Figure B.5 on page 359, Figure B.6 on page 360, Figure B.7 on
page 361, Figure B.8 on page 362, Figure B.9 on page 363, Figure B.10 on page 364, and
Figure B.11 on page 365).
Figure B.3 DSP56800x New Project Wizard Target Dialog Box (DSP56F80x)
Figure B.4 DSP56800x New Project Wizard Target Dialog Box (DSP56F82x)
Figure B.5 DSP56800x New Project Wizard Target Dialog Box (DSP5685x)
Figure B.6 DSP56800x New Project Wizard Target Dialog Box (MC56F801x)
Figure B.7 DSP56800x New Project Wizard Target Dialog Box (MC56F802x)
Figure B.8 DSP56800x New Project Wizard Target Dialog Box (MC56F803x)
Figure B.9 DSP56800x New Project Wizard Target Dialog Box (MC56F81xx)
Figure B.10 DSP56800x New Project Wizard Target Dialog Box (MC56F8xxx)
Figure B.11 DSP56800x New Project Wizard Target Dialog Box (Simulators)
One target family and one target processor or simulator must be selected before continuing
to the next wizard page.
NOTE Depending on which processor you select, different screens will appear
according to the “Page Rules” on page 351.
If you choose the simulator, then the DSP56800x New Project Wizard - Program Choice
page appears (see “Program Choice Page” on page 365. )
When you click Next, the Wizard jumps to the appropriate page determined by the “Page
Rules” on page 351.
Figure B.13 DSP56800x New Project Wizard - 56800E Data Memory Model Page
When you click Next, the Wizard jumps to the appropriate page determined by the “Page
Rules” on page 351.
When you click Next, the Wizard jumps to the appropriate page determined by the “Page
Rules” on page 351.
Finish Page
When you click the Finish button on the Finish Page (Figure B.15 on page 369), the
project creation process start.
L M
L_abs intrinsic function 240 M5600E target panel 50, 51
L_add intrinsic function 242 M56800E assembler panel 62, 64
L_deposit_h intrinsic function 247 M56800E linker panel 71–75
L_deposit_l intrinsic function 247 M56800E processor panel 64
L_mac intrinsic function 253 M56800E target (debugging) panel 77–82
L_msu intrinsic function 253 mac_r intrinsic function 250, 251
L_mult intrinsic function 254 math support intrinsic functions 236–267
L_mult_ls intrinsic function 255 MEMORY linker keyword 295, 297
X
X memory, viewing 199–200
XML files
exporting and importing panel options 46