CodeWarrior™ Development Studio for Motorola® 56800/E Hybrid Controllers: MC56F83xx/DSP5685x Family Targeting Manual Revised 2003/08/15
Metrowerks, the Metrowerks logo, and CodeWarrior are trademarks or registered trademarks of Metrowerks Corp. in the US and/or other countries. All other tradenames and trademarks are the property of their respective owners. Copyright © Metrowerks Corporation. 2003. ALL RIGHTS RESERVED.
Table of Contents Table of Contents 1 Introduction 9 CodeWarrior IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Motorola 56800/E Hybrid Controllers . . . . . . . . . . . . . . . . . . 11 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2 Getting Started 13 System Requirements . . . . . . . . . . . . . . . . . . . . . . . . 13 Installing the CodeWarrior IDE . . . . . . . . . . . . . . . . . . . . 13 Creating a Project . . . . . . . . . . . . . . . . . . . . . . . . .
Table of Contents C/C++ Preprocessor . . . . . . . . . . . . . . . . . . . . . . . 48 C/C++ Warnings . . . . . . . . . . . . . . . . . . . . . . . . . 50 M56800E Assembler . . . . . . . . . . . . . . . . . . . . . . . 54 M56800E Processor . . . . . . . . . . . . . . . . . . . . . . . 56 ELF Disassembler . . . . . . . . . . . . . . . . . . . . . . . . 59 M56800E Linker . . . . . . . . . . . . . . . . . . . . . . . . . 61 Remote Debugging . . . . . . . . . . . . . . . . . . . . . . . .
Table of Contents User Stack Allocation . . . . . . . . . . . . . . . . . . . . . . . . 120 Data Alignment Requirements . . . . . . . . . . . . . . . . . . . . . 125 Word and Byte Pointers . . . . . . . . . . . . . . . . . . . . . . 126 Reordering Data for Optimal Usage . . . . . . . . . . . . . . . . . 126 Code and Data Storage . . . . . . . . . . . . . . . . . . . . . . . . 127 Large Data Model Support . . . . . . . . . . . . . . . . . . . . . . 129 Extended Data Addressing Example . . . . . . . . . .
Table of Contents Fill Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 Save/Restore Registers . . . . . . . . . . . . . . . . . . . . . . . . 202 EOnCE Debugger Features . . . . . . . . . . . . . . . . . . . . . . 204 Set Hardware Breakpoint Panel . . . . . . . . . . . . . . . . . . . 204 Special Counters . . . . . . . . . . . . . . . . . . . . . . . . . 205 Trace Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . 207 Set Trigger Panel . . . . . . . . . . . . . . . . . . . . .
Table of Contents 10 ELF Linker and Command Language 287 Structure of Linker Command Files . . . . . . . . . . . . . . . . . . . 287 Memory Segment Closure Blocks . . . . . . . . . . . . . . . . . . . . . . . . 288 . . . . . . . . . . . . . . . . . . . . . . . . . 288 Sections Segment . . . . . . . . . . . . . . . . . . . . . . . . 289 Linker Command File Syntax . . . . . . . . . . . . . . . . . . . . . 290 Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 Arithmetic Operations .
Table of Contents Removing "illegal object_c on pragma directive" Warning . . . . . . . . . . 354 B DSP56800x New Project Stationery Wizard 355 High-Level Design . . . . . . . . . . . . . . . . . . . . . . . . . 355 Page Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . 357 Resulting Target Rules . . . . . . . . . . . . . . . . . . . . . . 359 Rule Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 DSP56800x New Project Stationery Wizard Graphical User Interface . . . . .
1 Introduction This manual explains how to use the CodeWarrior™ Integrated Development Environment (IDE) to develop code for the DSP56800E family of processors (MC56F3xx and DSP56F5x). This chapter contains the following sections: • CodeWarrior IDE • Motorola 56800/E Hybrid Controllers • References 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.
Introduction CodeWarrior IDE • 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.
Introduction Motorola 56800/E Hybrid Controllers Motorola 56800/E Hybrid Controllers The Motorola 56800/E Hybrid Controllers consist of two sub-families, which are named the DSP56F80x/DSP56F82x (DSP56800) and the MC56F83xx/DSP5685x (DSP56800E). The DSP56800E is an enhanced version of the DSP56800. The processors in the the DSP56800 and DSP56800E sub-families are shown in Table 1.1.
Introduction References – Code Warrior IDE User’s Guide – Code Warrior Development Studio for Motorola 56800/E Hybrid Controllers: DSP56F80x/DSP56F82x Family Targeting Manual – Code Warrior Development Studio for Motorola 56800/E Hybrid Controllers: MC56F83xx/DSP5685x Family Targeting Manual – Assembler Reference Manual – MSL C Reference (Metrowerks Standard C libraries) – DSP56800 to DSP56800E Porting Guide. Motorola, Inc.
2 Getting Started This chapter explains the setup and installation for the CodeWarrior™ IDE, including hardware connections and communications protocols. This chapter contains these sections: • System Requirements • Installing the CodeWarrior IDE • Creating a Project System Requirements Table 2.1 lists system requirements for installing and using the CodeWarrior IDE for DSP56800E. Table 2.
Getting Started Installing the CodeWarrior IDE 1. Insert the CodeWarrior CD-ROM into your CD-ROM drive — an initial welcome screen appears. NOTE If Auto Install is disabled, run program setup.exe, in the root directory of the CD-ROM. 2. Click the Install button — the wizard welcome message box appears. 3. Follow the instructions of successive screens, clicking the Next or Yes button to accept default values. 4.
Getting Started Creating a Project NOTE Do not move the license.dat file after installation. 12. This completes installation: your CodeWarrior software is ready for use. a. Table 2.2 lists the directories created during full installation. b. To test your system, follow the instructions of the next section to create a project. Table 2.2 Installation Directories, CodeWarrior IDE for DSP56800E Directory Contents Bin The CodeWarrior IDE application and associated plug-in tools.
Getting Started Creating a Project 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 subsection “Creating a New Project with the DSP56800x New Project Wizard.” To create a new project with the DSP56800x EABI stationery, please see the subsection “Creating a New Project with the DSP56800x EABI Stationery.
Getting Started Creating a Project Figure 2.1 New Dialog Box 2. Select DSP56800x New Project Wizard. 3. In the Project Name text box, type the project name. For example, the_project. 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 2.2) appears.
Getting Started Creating a Project Figure 2.2 DSP56800x New Project Wizard — Target Dialog Box 6. Select the target board and processor a. Select the family, such as DSPF6F80x, from the DSP56800x Family list. b. Select a processor or simulator, such as 56800 simulator, from the Processors list. 7. Click Next. The DSP56800x New Project Wizard — Program Choice dialog box (Figure 2.3) appears.
Getting Started Creating a Project Figure 2.3 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.4) appears.
Getting Started Creating a Project Figure 2.4 DSP56800x New Project Wizard — Finish Dialog Box 10. Click Finish to create the new project. 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.
Getting Started Creating a Project 12. (Optional) Add source files to the project. 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.
Getting Started Creating a Project 2. Specify a new DSP56800E project named NewProj1. a. If necessary, click the Project tab to move the Project page to the front of the window. b. From the project list, select (highlight) DSP56800E EABI Stationery. NOTE Stationery is a set of project templates, including libraries and placeholders for source code. Using stationery is the quickest way to create a new project. c. In the Project name text box, type: NewProj1.
Getting Started Creating a Project 4. In the New window, click the OK button. The New Project window (Figure 2.7) appears, listing board-specific project stationery. Figure 2.7 New Project Window 5. Select the simulator C stationery target. a. Click the expand control (+) for the M56800E Simulator. The tree expands to show stationery selections.
Getting Started Creating a Project b. Select (highlight) Simple C. (Figure 2.8 shows this selection.) Figure 2.8 Simulator Simple C Selection 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 shows this project window docked in the IDE main window.
Getting Started Creating a Project 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. Figure 2.10 shows this selection. To dock a floating window, right-click its title bar, then select Docked from the context menu.
Getting Started Creating a Project Figure 2.10 Project Window (docked) 6. 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. 7. (Optional) Remove files from the project. a.
Getting Started Creating a Project b. Method 2: Drag files from the desktop or Windows Explorer to the project window. 9. (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.
Getting Started Creating a Project 28 Targeting MC56F83xx/DSP5685x Controllers
3 Development Studio Overview This chapter describes the CodeWarrior™ IDE and explains application development using the IDE. This chapter contains these sections: • CodeWarrior IDE • Development Process If you are an experienced CodeWarrior IDE user, you will recognize the look and feel of the user interface. However, you must become familiar with the DSP56800E runtime software environment. CodeWarrior IDE The CodeWarrior IDE lets you create software applications.
Development Studio Overview Development Process • 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++. • CodeWarrior Assembler for DSP56800E — an assembler that features easyto-use syntax. It assembles any project file that has a.
Development Studio Overview Development Process Figure 3.1 CodeWarrior IDE Application Development Start Create/Manage Project Manage Files (1) Specify Target (2) Settings Edit Files (3) Notes: (1) Use any combination: stationery (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.
Development Studio Overview Development Process Project Files A CodeWarrior project consists of source-code, library, and other files. The project window (Figure 3.2) 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. Figure 3.2 Project Window NOTE Figure 3.2 shows a floating project window.
Development Studio Overview Development Process 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.
Development Studio Overview Development Process NOTE Figure 3.3 shows a floating editor window. Alternatively, you can dock the editor window in the IDE main window or make it a child window. Building: Compiling and Linking For the CodeWarrior IDE, building includes both compiling and linking. To start building, you select Project>Make, from the IDE main-window menu bar.
Development Studio Overview Development Process Figure 3.4 CodeWarrior Build System 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.
Development Studio Overview Development Process 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.
4 Target Settings Each build target in a CodeWarrior™ project has its own settings. This chapter explains the target settings panels for DSP56800E software development. The settings that you select affect the DSP56800E compiler, linker, assembler, and debugger.
Target Settings Target Settings Overview • Links identify the panels specific to DSP56800E projects. Click the link to go to the explanation of that panel. • The Use column explains the purpose of generic IDE panels that also can apply to DSP56800E projects. For explanations of these panels, see the IDE User Guide. Table 4.1 Target Setting Panels Group Panel Name Target Target Settings Use Access Paths Selects the paths that the IDE searches to find files of your project.
Target Settings Target Settings Overview Table 4.1 Target Setting Panels (continued) Group Panel Name Use Editor Custom Keywords Changes colors for different types of text. Debugger Debugger Settings Specifies settings for the CodeWarrior debugger. Remote Debugging M56800E Target (Debugging) Remote Debug Options Changing Target Settings To change target settings: 1. Select Edit > Target Name Settings. Target is the name of the current build target in the CodeWarrior project.
Target Settings Target Settings Overview Figure 4.1 Target Settings Window 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.
Target Settings Target Settings Overview Exporting and Importing Panel Options to XML Files The CodeWarrior IDE can export options for the current settings panel to an Extensible Markup Language (XML) file or import options for the current settings panel from a previously saved XML file. Exporting Panel Options to XML File 1. Click the Export Panel button. 2. Assign a name to the XML file and save the file in the desired location. Importing Panel Options from XML File 1. Click the Import Panel button. 2.
Target Settings CodeWarrior IDE Target Settings Panels CodeWarrior IDE Target Settings Panels Table 4.2 lists and explains the CodeWarrior IDE target settings panels that can apply to DSP56800E. Table 4.2 Code Warrior IDE Target Settings Panels 42 Target Settings Panels Description 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.
Target Settings DSP56800E-Specific Target Settings Panels DSP56800E-Specific Target Settings Panels The rest of this chapter explains the target settings panels specific to DSP56800E development. Target Settings Use the Target Settings panel (Figure 4.2) to specify a linker. This selection also specifies your target. Table 4.3 explains the elements of the Target Settings panel. The Target Settings window changes its list of panels to reflect your linker choice.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.3 Target Settings Panel Elements (continued) Element Purpose Comments Pre-linker list box Specifies a pre-linker. Select None. (No pre-linker is available for the M56800E linker.) Post-linker list box Specifies a post-linker. Select None. (No post-linker is available for the M56800E linker.) Output Directory text box Tells the IDE where to save the executable file.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.4 M56800E Target Panel Elements Element Purpose Comments Project Type list box Specifies an Application or Library project. Application is the usual selection. Output File Name text box Specifies the name of the output file. End application filenames with the .elf extension; end library filenames with the .lib extension. NOTE Be sure to name libraries with the extension .lib.
Target Settings DSP56800E-Specific Target Settings Panels NOTE Always disable these options, which do not apply to the DSP56800E compiler: Force C++ compilation ISO C++ Template Parser Use Instance Manager Enable C++ Exceptions Enable RTTI Enable bool Support Enable wchar_t Support EC++ Compatibility Mode Legacy for-scooping Enable C99 Extensions Enable GCC Extensions Pool Strings Table 4.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.5 C/C++ Language Panel Elements (continued) Element Purpose Comments Enums Always Int checkbox Checked — Restricts all enumerators to the size of a singed int. Clear — Compiler converts unsigned int enumerators to signed int, then chooses an accommodating data type, char to long int. To check whether this restriction is in effect, use the __option(enumalwasysint) command.
Target Settings DSP56800E-Specific Target Settings Panels Figure 4.5 The C/C++ Preprocessor Panel Table 4.6 provides information about the options in this panel. Table 4.6 C/C++ Language Preprocessor Elements Element Purpose Comments Source encoding Allows you to specify the default encoding of source files. Multibyte and Unicode source text is supported. To replicate the obsolete option “Multi-Byte Aware”, set this option to System or Autodetect.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.6 C/C++ Language Preprocessor Elements (continued) Element Purpose Comments Emit #pragmas Controls whether #pragmas encountered in the source text appear in the preprocessor output. This option is essential for producing reproducible test cases for bug reports. Show full paths Controls whether file changes show the full path or the base filename of the file. Keep comments Controls whether comments are emitted in the output.
Target Settings DSP56800E-Specific Target Settings Panels Figure 4.6 C/C++ Warnings Panel Table 4.7 C/C++ Warnings Panel Elements Element Purpose Comments Illegal Pragmas checkbox Checked — Compiler issues warnings about invalid pragma statements. Clear — Compiler does not issue such warnings. According to this option, the invalid statement #pragma near_data off would prompt the compiler response WARNING: near data is not a pragma.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.7 C/C++ Warnings Panel Elements (continued) Element Purpose Comments Extended Error Checking checkbox Checked — Compiler issues warnings in response to specific syntax problems. Clear — Compiler does not perform such checks. Syntax problems are: a non-void function without a return statement, an integer or floating-point value assigned to an enum type, or an empty return statement in a function not declared void.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.7 C/C++ Warnings Panel Elements (continued) Element Purpose Comments Missing ‘return’ Statements Checked — Compiler checks for missing ‘return’ statements. Clear — Compiler does not perform such checks. See #pragma warn_missingreturn. Expression Has No Side Effect Checked — Compiler issues warning if expression has no side effect. Clear — Compiler does not perform such checks.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.7 C/C++ Warnings Panel Elements (continued) Element Purpose Comments Non-Inlined Functions checkbox Checked — Compiler issues a warning if unable to inline a function. Clear — Compiler does not issue such warnings. To check whether this option is in effect, use the __option(warn_notinlined) command. Treat All Warnings As Errors checkbox Checked — System displays warnings as error messages.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.8 M56800E Assembler Panel Elements Element Purpose Comments Generate Listing File checkbox Checked — Assembler generates a listing file during IDE assembly of source files. Clear — Assembler does not generate a listing file. A listing file contains the source file with line numbers, relocation information, and macro expansions. The filename extension is .lst.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.8 M56800E Assembler Panel Elements (continued) Element Purpose Comments Default Data Memory Model list box Specifies 16 or 24 bits as the default size. Factory setting: 16 bits. Default Program Memory Model list box Specifies 16, 19, or 21 bits as the default size. Factory setting: 19 bits. Prefix File text box Specifies a file to be included at the beginning of every assembly file of the project.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.9 M56800E Processor Panel Elements Element Purpose Comments Hardware DO Loops list box Specifies the level of hardware DO loops: If hardware DO loops are enabled, debugging will be inconsistent about stepping into loops. Test immediately after this table contains additional Do-loop information.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.9 M56800E Processor Panel Elements (continued) Element Purpose Comments Zero-initialized globals live in data instead of BSS checkbox Checked — Globals initialized to zero reside in the .data section. Clear — Globals initialized to zero reside in the .bss section. Create Assembly Output checkbox Checked — Assembler generates assembly code for each C file. Clear — Assembler does not generate assembly code for each C file.
Target Settings DSP56800E-Specific Target Settings Panels 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.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.10 ELF Disassembler Panel Elements Element Purpose Show Headers checkbox Checked — Disassembled output includes ELF header information. Clear — Disassembled output does not include this information. Show Symbol and String Tables checkbox Checked — Disassembled modules include symbol and string tables. Clear — Disassembled modules do not include these tables. Verbose Info checkbox Checked — ELF file includes additional information.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.10 ELF Disassembler Panel Elements (continued) Element Purpose Comments Show Comments checkbox Checked — Disassembler comments appear in sections that have comment columns. Clear — Disassembler does not produce comments. This checkbox is available only if the Show Code Modules checkbox is checked. Show Data Modules checkbox Checked — Disassembler outputs ELF data sections, such as .data and .bss, for the disassembled module.
Target Settings DSP56800E-Specific Target Settings Panels Figure 4.10 M56800E Linker Panel Table 4.11 M56800E Linker Panel Elements Element Purpose Comments Generate Symbolic Info checkbox Checked — Linker generates debugging information, within the linked ELF file. Clear — Linker does not generate debugging information. If you select Project>Debug from the main-window menu bar, the IDE automatically enables this option.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.11 M56800E Linker Panel Elements (continued) Element Purpose Comments List Unused Objects checkbox Checked — Linker includes unused objects in the link map. Clear — Linker does not include unused objects in the link map. This checkbox is available only if the Generate Link Map checkbox is checked. Show Transitive Closure checkbox Checked — Link map includes a list of all objects that main( ) references.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.11 M56800E Linker Panel Elements (continued) Element Purpose Comments Generate Byte Addresses checkbox Checked — Enables the linker to generate type S3 S-records in bytes. Clear — Does not enable byte generation. This checkbox is available only if the Generate S-Record File checkbox is checked. Max Record Length text box Specifies the maximum length of type S3 Srecords that the linker generates, up to 256 bytes.
Target Settings DSP56800E-Specific Target Settings Panels Listing 4.2 Link Map File: List of main( ) references # Link map of Finit_sim_ 1] interrupt_vectors.text found in 56800E_vector.asm 2] sim_intRoutine (notype,local) found in 56800E_vector.asm 2] Finit_sim_ (func,global) found in 56800E_init.asm 3] Fmain (func,global) found in M56800E_main.c 4] Ffoot (func,global) found in M56800E_main.c 4] Fpad (func,global) found in M56800E_main.c 3] F__init_sections (func,global) found in Runtime 56800E.
Target Settings DSP56800E-Specific Target Settings Panels Remote Debugging Use the Remote Debugging panel (Figure 4.11, Figure 4.12) to set parameters for communication between a DSP56800E board or Simulator and the CodeWarrior DSP56800E debugger. Table 4.12 explains the elements of this panel. NOTE Communications specifications also involve settings of the debugging M56800E Target panel (Figure 4.13). Figure 4.11 Remote Debugging Panel (56800E Simulator) Figure 4.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.12 Remote Debugging Panel Elements Element Purpose Comments Connection list box Specifies the connection type: Selecting 56800E Simulator keeps the panel as Figure 4.11 shows. Selecting Local Hardware Connection adds the JTAG Clock Speed text box to the panel, as Figure 4.12 shows. • 56800E Simulator — appropriate for testing code on the simulator before downloading code to an actual board.
Target Settings DSP56800E-Specific Target Settings Panels 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. Figure 4.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.13 Debugging M56800E Target Panel Elements Element Purpose Always reset on download checkbox Checked — IDE issues a reset to the target board each time you connect to the board. Clear — IDE does not issue a reset each time you connect to the target board. Use initialization file checkbox Checked — After a reset, the IDE uses an optional hardware initialization file before downloading code.
Target Settings DSP56800E-Specific Target Settings Panels 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.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.14 Initialization File Commands and Arguments (continued) Command Arguments Description set_hfm_programmer_base
Specifies the address where the onboard flash programmer will be loaded in P: Memory. set_hfm_prog_buffer_base Specifies where the data to be programmed will be loaded in X: Memory. set_hfm_prog_buffer_size Specifies the size of the buffer in X: Memory which will hold the data to be programmed.Target Settings DSP56800E-Specific Target Settings Panels Figure 4.
Target Settings DSP56800E-Specific Target Settings Panels Table 4.15 Remote Debug Options Panel Elements Element Purpose Comments Program Download Options area Checked Download checkboxes specify the section types to be downloaded on initial launch and on successive runs. Checked Verify checkboxes specify the section types to be verified (that is, read back to the linker). Section types: • Executable — program-code sections that have X flags in the linker command file.
Target Settings DSP56800E-Specific Target Settings Panels 74 Targeting MC56F83xx/DSP5685x Controllers
5 Processor Expert Interface Your CodeWarrior™ IDE features a Processor Expert™ plug-in interface, for rapid development of embedded applications. This chapter explains Processor Expert concepts, and Processor Expert additions to the CodeWarrior visual interface. This chapter includes a brief tutorial exercise.
Processor Expert Interface Processor Expert Overview • Target CPU window — This window depicts the target microprocessor as a simple package or a package with peripherals. As you move the cursor over this picture’s 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 targetmicroprocessor elements, in an expandable-tree representation.
Processor Expert Interface Processor Expert Overview 4. Starting code design (that is, building the application). As you create the project, the project window opens in the IDE main window. This project window has a Processor Expert page (Figure 5.1). The Processor Expert Target CPU window also appears at this time. So does the Processor Expert bean selector window, although it is behind the Target CPU window. Figure 5.
Processor Expert Interface Processor Expert Overview Processor Expert Beans Beans encapsulate the most-required functionalities for embedded applications. Examples include port bit operations, interrupts, communication timers, and A/D converters. The Bean Selector (Figure 5.2) helps you find appropriate beans by category: processor, MCU external devices, MCU internal peripherals, or on-chip peripherals. To open he bean selector, select Processor Expert > View > Bean Selector, from the main-window menu bar.
Processor Expert Interface Processor Expert Overview Figure 5.3 Bean Inspector 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.
Processor Expert Interface Processor Expert Overview Table 5.1 Processor Expert Menu Selections Item Subitem Action Open Processor Expert none Opens the PEI for the current project. (Available only if the current project does not already involve the PEI.) Code Design none Generates code, including drivers, for the current project. Access these files via the Generate Code folder, of the project-window Files page.
Processor Expert Interface Processor Expert Overview Table 5.1 Processor Expert Menu Selections (continued) Item Tools Help Help (continued) Subitem Action Peripherals Usage Inspector Opens the Peripherals Usage Inspector window, which shows which bean allocates each peripheral. Peripheral Initialization Inspector Opens the Peripherals Initialization Inspector window, which show the initialization value and value after reset for all peripheral register bits.
Processor Expert Interface Processor Expert Overview Table 5.1 Processor Expert Menu Selections (continued) Item Subitem Action Embedded Beans Categories Opens the first page of a description database of beans, organized by category. Supported CPUs, Compilers, and Debuggers Opens the list of processors and tools that the PEI plug-in supports. PESL Library User Manual Opens the Processor Expert System Library, for advanced developers. User Guide Opens a .
Processor Expert Interface Processor Expert Windows Processor Expert Windows This section illustrates important Processor Expert windows and dialog boxes. Bean Selector The Bean Selector window (Figure 5.4) 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. Figure 5.
Processor Expert Interface Processor Expert Windows 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) lets you modify bean properties and other settings.
Processor Expert Interface Processor Expert Windows • 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.
Processor Expert Interface Processor Expert Windows Target CPU Window The Target CPU window (Figure 5.6) depicts the target processor as a realistic CPU package, as a CPU package with peripherals, or as a block diagram. To open this window, select Processor Expert > View > Target CPU Package, from the mainwindow menu bar. (To have this window show the block diagram, you may select Processor Expert > View > Target CPU Block Diagram, from the main-window menu bar.) Figure 5.
Processor Expert Interface Processor Expert Windows 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 shows, it is not always possible for the picture of a sophisticated processor to display internal peripherals. Figure 5.
Processor Expert Interface Processor Expert Windows In such a case, you can click the Always show internal peripheral devices control button. Figure 5.8 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. Figure 5.
Processor Expert Interface Processor Expert Windows Click the Show MCU Block Diagram to change the picture to a block diagram, as Figure 5.9 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.) Figure 5.
Processor Expert Interface Processor Expert Windows 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 open the Bean Inspector, displaying information for that bean.
Processor Expert Interface Processor Expert Windows Memory Map Window The Memory Map window (Figure 5.10) depicts CPU address space, and the map of internal and external memory. To open this window, select Processor Expert > View > Memory Map, from the main-window menu bar. Figure 5.
Processor Expert Interface Processor Expert Windows • Cyan — FLASH memory or EEPROM • Black — External memory. Pause your cursor over any block of the map to bring up a brief description. CPU Types Overview The CPU Types Overview window (Figure 5.11) lists supported processors, in an expandable tree structure. To open this window, select Processor Expert > View > CPU Types Overview, from the main-window menu bar. Figure 5.
Processor Expert Interface Processor Expert Windows Resource Meter The Resource Meter window (Figure 5.12) shows the usage or availability of processor resources. To open this window, select Processor Expert > View > Resource Meter, from the main-window menu bar. Figure 5.
Processor Expert Interface Processor Expert Windows Installed Beans Overview The Installed Beans Overview window (Figure 5.13) shows reference information about the installed beans. To open this window, select Processor Expert > View > Installed Beans Overview, from the main-window menu bar. Figure 5.13 Installed Beans Overview Window 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 one.
Processor Expert Interface Processor Expert Windows Peripherals Usage Inspector The Peripherals Usage window (Figure 5.14) shows which bean allocates each peripheral. To open this window, select Processor Expert > View > Peripherals Usage Inspector, from the main-window menu bar. Figure 5.14 Peripherals Usage Window 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.
Processor Expert Interface Processor Expert Tutorial Processor Expert Tutorial This tutorial exercise generates code that flashes the LEDs of a DSP56836E development board. Follow these steps: 1. Create a M568346 project, using C with Processor Expert stationery. a. Start the CodeWarrior IDE, if it is not started already. b. From the main-window menu bar, select File > New. The New window appears. c. In the Project page, select (highlight) Dsp56800/E EABI Stationery. d.
Processor Expert Interface Processor Expert Tutorial 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.16 shows. This window shows the CPU package and peripherals view. • Opens the Bean Selector window, behind the Target CPU window. Figure 5.16 Project, Target CPU Windows 2. Select the sdm external memory target. a. Click the project window’s Targets tab.
Processor Expert Interface Processor Expert Tutorial a. Click the project window’s Processor Expert tab. The Processor Expert page moves to the front of the window. b. Make the Bean Selector window visible: • Minimize the Target CPU window. • Select Processor Expert > View > Bean Selector, from the main-window menu bar. c. In the Bean Categories page, expand the entry MCU internal peripherals. d. Expand the subentry Port I/O. e. Double-click the BitIO bean name six times. (Figure 5.
Processor Expert Interface Processor Expert Tutorial 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. 4. Add two ExtInt beans to the project. a. In the Bean Categories page of the Bean Selector window, expand the Interrupts subentry. b. Double-click the ExtInt bean name two times.
Processor Expert Interface Processor Expert Tutorial c. Type the new name GPIO_C0, then press the Enter key. The list shows the new name; as Figure 5.18 shows, this name still ends with BitIO. Figure 5.18 New Bean Name 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.
Processor Expert Interface Processor Expert Tutorial e. Repeat substeps a, b, and c for the two ExtInt beans, renaming them IRQA and IRQB. (Figure 5.19 shows the Processor Expert page at this point.) Figure 5.19 New Bean Names 6. Update pin associations for each bean. a. In the Processor Expert page, double-click the bean name GPIO_C0. The Bean Inspector window opens, displaying information for this bean. b. Use standard window controls to make the middle column of the Properties page about 2 inches wide.
Processor Expert Interface Processor Expert Tutorial d. Use this list box to select GPIOC0_SCLK1_TB0_PHASEA1. (Figure 5.20 depicts this selection.) Figure 5.20 New Pin Association 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.
Processor Expert Interface Processor Expert Tutorial 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.21 shows this configuration.) Figure 5.21 GPIO_C3 Enabled Functions c.
Processor Expert Interface Processor Expert Tutorial 10. Update file Events.c. a. Click the project window’s Files tab. The Files page moves to the front of the window. b. Expand the User Modules folder. c. Double-click filename Events.c. An editor window opens, displaying this file’s text. (Listing 5.1, at the end of this tutorial, shows this file’s contents.) d. Find the line IRQB_OnInterrupt(). e. Above this line, enter the new line extern short IRQB_On;. f.
Processor Expert Interface Processor Expert Tutorial This completes the Processor Expert tutorial exercise. Downloading this code to a DSP56836E development board should make the board LEDs flash in a distinctive pattern. Listing 5.1 File Events.c /* ** ################################################################# ** ** Filename : Events.C ** ** Project : LEDcontrol ** ** Processor : DSP56F836 ** ** Beantype : Events ** ** Version : Driver 01.
Processor Expert Interface Processor Expert Tutorial ** ** ######################################################### */ /* MODULE Events */ /*Including used modules for compilling procedure*/ #include "Cpu.h" #include "Events.h" #include "GPIO_C0.h" #include "GPIO_C1.h" #include "GPIO_C2.h" #include "GPIO_C3.h" #include "GPIO_D6.h" #include "GPIO_D7.h" #include "IRQA.h" #include "IRQB.h" /*Include shared modules, which are used for whole project*/ #include "PE_Types.h" #include "PE_Error.
Processor Expert Interface Processor Expert Tutorial ** ========================================================== ** Event : IRQA_OnInterrupt (module Events) ** ** From bean : IRQA [ExtInt] ** Description : ** This event is called when the active signal edge/level ** occurs.
Processor Expert Interface Processor Expert Tutorial Listing 5.2 File LEDcontrol.c /* ** ################################################################### ** 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.
Processor Expert Interface Processor Expert Tutorial #include "GPIO_C0.h" #include "GPIO_C1.h" #include "GPIO_C2.h" #include "GPIO_C3.h" #include "GPIO_D6.h" #include "GPIO_D7.h" #include "IRQA.h" #include "IRQB.h" /* Include shared modules, which are used for whole project */ #include "PE_Types.h" #include "PE_Error.h" #include "PE_Const.h" #include "IO_Map.h" /* * Application Description: * LED program for the 56836 EVM. * * Pattern: "Count" from 0 to 63, using LEDs to represent the bits of the number.
Processor Expert Interface Processor Expert Tutorial { num = 7-num; } if (!IRQB_On) { switch (num) { case case case case case case } } else { switch (num) { case case case case case case } } 1: 2: 3: 4: 5: 6: GPIO_C0_ClrVal(); GPIO_C1_ClrVal(); GPIO_C2_ClrVal(); GPIO_C3_ClrVal(); GPIO_D6_ClrVal(); GPIO_D7_ClrVal(); break; break: break; break; break; break; 1: 2: 3: 4: 5: 6: GPIO_C0_SetVal(); GPIO_C1_SetVal(); GPIO_C2_SetVal(); GPIO_C3_SetVal(); GPIO_D6_SetVal(); GPIO_D7_SetVal(); break; break; break;
Processor Expert Interface Processor Expert Tutorial case 5: case 6: GPIO_D6_ClrVal(); break; GPIO_D7_ClrVal(); break; } } else { switch (num) { case case case case case case } 1: 2: 3: 4: 5: 6: GPIO_C0_SetVal(); GPIO_C1_SetVal(); GPIO_C2_SetVal(); GPIO_C3_SetVal(); GPIO_D6_SetVal(); GPIO_D7_SetVal(); break; break; break; break; break; break; } } #define CLEARLEDS showNumberWithLEDs(0) /* method to set each LED status to reflect the given number/bitfield */ void shwNumberWithLEDs(long); void showNumb
Processor Expert Interface Processor Expert Tutorial } } void main(void) { /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization.
6 C for DSP56800E This chapter explains considerations for using C with the DSP56800E processor. Note that the DSP56800E processor does not support: • The C++ language • Standard C trigonometric and algebraic floating-point functions (such as sine, cosine, tangent, and square root) Furthermore, C pointers allow access only to X memory. NOTE The DSP56800E MSL implements a few trigonometric and algebraic functions, but these are mere examples that the DSP56800E does not support.
C for DSP56800E Number Formats Table 6.
C for DSP56800E Calling Conventions and Stack Frames Table 6.2 shows the sizes and ranges of the floating-point types. Table 6.2 M56800E Floating-Point Types Type Size (bits) Range float 32 1.17549e-38 to 3.40282e+38 short double 32 1.17549e-38 to 3.40282e+38 double 32 1.17549e-38 to 3.40282e+38 long double 32 1.17549e-38 to 3.40282e+38 Calling Conventions and Stack Frames The DSP56800E compiler stores data and call functions differently than does the DSP56800 compiler.
C for DSP56800E Calling Conventions and Stack Frames Returning Values From Functions The compiler returns function results in registers A, R0, R2, and Y0: • 16-bit integer values — Y0. • 32-bit integer or float values — A. • All pointer values — R2. • Structure results — R0 contains a pointer to a temporary space allocated by the caller. (The pointer is a hidden parameter value.) Additionally, the compiler: • Reserves R5 for the stack frame pointer when a function makes a dynamic allocation.
C for DSP56800E Calling Conventions and Stack Frames Table 6.
C for DSP56800E Calling Conventions and Stack Frames Table 6.
C for DSP56800E Calling Conventions and Stack Frames Stack Frame and Alignment Figure 6.1. depicts generation of the stack frame. The stack grows upward, so pushing data onto the stack increments the stack pointer’s address value. Figure 6.
C for DSP56800E User Stack Allocation 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.
C for DSP56800E User Stack Allocation 4. You must not overwrite the compiler’s stack allocation by decreasing the SP into the compiler allocated stack space. Point 1 above is required when you think about an if-then-else type statement. If one branch of a decision point modifies the SP one way and the other branch modifies SP another way, then the value of the SP is run-time dependent, and the compiler is unable to determine where stack-based variables are located at run-time.
C for DSP56800E User Stack Allocation In cases where the SP is modified by a run-time dependent amount, a warning is issued. Listing 6.1 Example 1 – Legal modification of SP Using Inline Assembly #define EnterCritical() { asm(adda #2,SP);\ asm(move.l SR,X:(SP)+); \ asm(bfset #0x0300,SR); \ asm(nop); \ asm(nop);} #define ExitCritical() { asm(deca.l SP);\ asm(move.
C for DSP56800E User Stack Allocation asm(nop);\ asm(nop);} #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. Warning : Inconsistent inline assembly modification of SP in this function.
C for DSP56800E User Stack Allocation asm(nop);} #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 will generate the following warning: Warning : Cannot determine SP modification value at compile time M56800E_main.c line 20 EnterCritical(); This example is not legal since the SP is modified by run-time dependent amount.
C for DSP56800E Data Alignment Requirements { 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 Alignment Requirements The data alignment rules for DSP56800E stack and global memory are: • Bytes — byte boundaries. Exception: bytes passed on the stack are always word-aligned, residing in the lower bytes.
C for DSP56800E Data Alignment Requirements • Structures — double-word boundaries if they contain 32-bit elements, or if an inner structure itself is double-word aligned. • Arrays — the size of one array element. Word and Byte Pointers The alignment requirements explained above determine how the compiler uses DSP56800E byte and word pointers to implement C pointer types.
C for DSP56800E Code and Data Storage • Reordering is mandatory if local variables are allocated on the stack. • The compiler does not reorder data for parameter values passed in memory (instead of being passed in registers). • The compiler does not reorder data when locating fields within a structure. Code and Data Storage The DSP56800E processor has a dual Harvard architecture with separate CODE (P: memory) and DATA (X: memory) memory spaces. Table 6.4.
C for DSP56800E Code and Data Storage checkbox.”. You can locate these sections in the lower half of the memory map, making sure that the data can be addressed.
C for DSP56800E Large Data Model Support Large Data Model Support The DSP56800E extends the DSP56800 data addressing range, by providing 24-bit address capability to some instructions. 24-bit address modes allow user accesses beyond the 64K-word boundary of 16-bit addressing. To control large data memory model support, use the M56800E Processor panel (Figure 6.2). See “M56800E Processor” for explanations of this panel’s elements. Figure 6.
C for DSP56800E Large Data Model Support 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: Extended Data Addressing Example Consider the code of Listing 6.5: Listing 6.5 Addressing Extended Data move.w x:0x123456,A1 ; move int using 24 bit absolute address tst.l x:(R0-0x123456) ; test a global long for zero using 24-bit ; pointer indexed addressing move.
C for DSP56800E Large Data Model Support Table 6.5 lists ways to access a global integer stored at address X:0x1234. int g1; Table 6.5 Accessing a Global Integer Large Data Model checkbox Globals live in lower memory checkbox Instruction Comments Clear Clear move.w X:0x1234,y0 Default values Checked Clear move.w X:0x001234,y0 Clear Checked Combination not allowed Checked Checked move.w X:0x1234,y0 Global accesses use 16bit addressing Table 6.
C for DSP56800E Optimizing Code External Library Compatibility If you enable the large data model when the compiler builds your main application, external libraries written in C also must be built with the large data model enabled. The linker enforces this requirement, catching global objects located out of range for particular instructions. A more serious compatibility problem involves pointer parameters.
C for DSP56800E Deadstripping and Link Order for (i=0; i<100; i++) { MyFunc(i); } for (j=0; j<100; j++) { MyFunc(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. For DSP56800E development, you can instruct the compiler to: 1. Store all local variables on the stack. — (That is, do not perform register coloring.
C for DSP56800E Deadstripping and Link Order Libraries built with the CodeWarrior C compiler contribute only the used objects to the linked program. If a library has assembly files or files built with other C compilers, the only files that contribute to the linked program are those that have at least one referenced object. If you enable deadstripping, the linker completely ignores files without any referenced objects.
7 Inline Assembly Language and Intrinsics The CodeWarrior™ compiler supports inline assembly language and intrinsic functions. This chapter explains the IDE implementation of Motorola assembly language, with regard to DSP56800E development. It also explains the relevant intrinsic functions. This chapter contains these sections: • Inline Assembly Language • Intrinsic Functions Inline Assembly Language This section explains how to use inline assembly language.
Inline Assembly Language and Intrinsics Inline Assembly Language Inline Assembly Overview To specify assembly-language interpretation for a block of code in your file, use the asm keyword and standard DSP56800E instruction mnemonics. 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 settings panel. Differences in calling conventions mean that you cannot re-use DSP56800 assembly code in the DSP56800E compiler. Listing 7.
Inline Assembly Language and Intrinsics Inline Assembly Language Listing 7.3 shows how to use the asm keyword with parentheses, to specify that a single statement is in assembly language. Note that a semicolon must follow the close parenthesis. Listing 7.3 Alternate Single-Statement Syntax asm (inline assembly statement); 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.
Inline Assembly Language and Intrinsics Inline Assembly Language 6. Assembly language directives, instructions, and registers are not case-sensitive. The following two statements are the same: add x0,y0 ADD X0,Y0 7. Comments must have the form of C or C++ comments; they must not begin with the ; or # characters. Listing 7.5 shows the valid syntax for comments. Listing 7.5 Valid Comment Syntax move.w add.w move.w adda x:(r3),y0 x0,y0 r2,x:(sp) r0,r1,n # ERROR // OK ; ERROR /* OK */ 8.
Inline Assembly Language and Intrinsics Inline Assembly Language add x0,y0 // int result returned in y0 rts } Listing 7.7 shows the C calling statement for this inline-assembly-language function. Listing 7.7 Sample Code - Calling an Inline Assembly Language Function int x = 4, y = 2; y = add_int( &x, &y ); /* Returns 6 */ Calling Pure Assembly Language Functions If you want C code to call assembly language files, you must specify a SECTION mapping for your code, for appropriate linking.
Inline Assembly Language and Intrinsics Inline Assembly Language rts ;pointed to by R0 in P: memory and ;post-increment R0 ;return to calling function ENDSEC END ;End of section ;End of source program Listing 7.9 shows the C calling statement for this assembly language function. Listing 7.9 Sample Code - Calling an Assembly Language Function from C void pmemwrite( short, short );/* Write a value into P: memory */ void main( void ) { // ...
Inline Assembly Language and Intrinsics Intrinsic Functions Intrinsic Functions This section explains CodeWarrior intrinsic functions. It consists of these sections: • Implementation • Fractional Arithmetic • Intrinsic Functions for Math Support • Modulo Addressing Intrinsic Functions Implementation The CodeWarrior IDE for DSP56800E has intrinsic functions to generate inlineassembly-language instructions. These intrinsic functions are a CodeWarrior extension to ANSI C.
Inline Assembly Language and Intrinsics Intrinsic Functions * * * * */ Allowed dst regs: (same) Assumptions: OMR's SA bit was set to 1 at least 3 cycles before this code. asm(abs svar1); return svar1; } 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.
Inline Assembly Language and Intrinsics Intrinsic Functions NOTE Intrinsic functions us these macros: Word16. — A macro for signed short. Word32. — A macro for signed long. Intrinsic Functions for Math Support Table 7.2 lists the math intrinsic functions. See section “Modulo Addressing Intrinsic Functions.” for explanations of the remaining intrinsic functions. For the latest information about intrinsic functions, refer to file intrinsics_56800E.h.
Inline Assembly Language and Intrinsics Intrinsic Functions Table 7.2 Intrinsic Functions for DSP56800E Category Function Category (cont.) Function (cont.
Inline Assembly Language and Intrinsics Intrinsic Functions Absolute/Negate The intrinsic functions of the absolute-value/negate group are: • abs_s • negate • L_abs • L_negate 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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 • sub • L_add • L_sub add Addition of two 16-bit integer or fractional values, returning a 16-bit result.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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 • wait • turn_off_conv_rndg • turn_off_sat • turn_on_conv_rndg • turn_on_sat stop Generates a STOP instruction which places the processor in the low power STOP mode.
Inline Assembly Language and Intrinsics Intrinsic Functions 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 If convergent rounding is disabled, the assembler performs 2’s complement rounding.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions Deposit/Extract The intrinsic functions of the deposit/extract group are: • extract_h • extract_l • L_deposit_h • L_deposit_l 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.
Inline Assembly Language and Intrinsics Intrinsic Functions Example long l = 0x87654321; short result; result = extract_l(l); // Expected value of result: 0x4321 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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 • div_s4q • div_ls • div_ls4q 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).
Inline Assembly Language and Intrinsics Intrinsic Functions 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. NOTE Does not check for division overflow or division by zero. Prototype Word16 div_s4q(Word16 s_numerator, Word16 s_denominator) Example short s1=0xE000;/* -0.25 */ short s2=0xC000;/* -0.
Inline Assembly Language and Intrinsics Intrinsic Functions NOTE Does not check for division overflow or division by zero. Prototype Word16 div_ls(Word32 l_numerator, Word16 s_denominator) Example long l =0x20000000;/* short s2=0x4000;/* 0.25 */ 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.
Inline Assembly Language and Intrinsics Intrinsic Functions Multiplication/MAC The intrinsic functions of the multiplication/MAC group are: • mac_r • msu_r • mult • mult_r • L_mac • L_msu • L_mult • L_mult_ls 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions Normalization The intrinsic functions of the normalization group are: • ffs_s • norm_s • ffs_l • norm_l 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 which handles the case where the input == 0x0000 differently.
Inline Assembly Language and Intrinsics Intrinsic Functions 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 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;/* .
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions Rounding The intrinsic function of the rounding group is: • round 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.
Inline Assembly Language and Intrinsics Intrinsic Functions Shifting The intrinsic functions of the shifting group are: • shl • shlftNs • shlfts • shr • shr_r • shrtNs • L_shl • L_shlftNs • L_shlfts • L_shr • L_shr_r • L_shrtNs 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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. NOTE This is not a bidirectional shift. Assumptions Assumed s_shftamount is positive.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions NOTE Ignores upper N-5 bits of s_shftamount except the sign bit (MSB). If s_shftamount is positive and the value in the lower 5 bits of s_shftamount is greater than 15, the result is 0 if sval2shft is positive, and 0xFFFF is sval2shft is negative. If s_shftamount is negative and the absolute value in the lower 5 bits of s_shftamount is greater than 15, the result is 0.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions L_shlfts Arithmetic left shift of 32-bit value by a specified shift amount. Saturation does occur during a left shift if required. NOTE This is not a bidirectional shift. 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions 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).
Inline Assembly Language and Intrinsics Intrinsic Functions Figure 7.1 Example of a Modulo Buffer Address 0x100 Data 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.
Inline Assembly Language and Intrinsics Intrinsic Functions • __mod_setint16 • __mod_error __mod_init Initialize a modulo buffer pointer with arbitrary data using the address specified by the . This function expects a byte address. 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.
Inline Assembly Language and Intrinsics Intrinsic Functions __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.
Inline Assembly Language and Intrinsics Intrinsic Functions __mod_access Retrieve the modulo pointer. The __mod_access function returns the modulo pointer value specified by 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 ); Example Assign a value to the modulo buffer at the current pointer.
Inline Assembly Language and Intrinsics Intrinsic Functions Prototype void __mod_stop( int integer units (*2 bytes). must be a compile time constant.
Inline Assembly Language and Intrinsics Intrinsic Functions __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.
Inline Assembly Language and Intrinsics Intrinsic Functions #pragma section DATA_INT_MODULO begin int int_buf[10]; #pragma section DATA_INT_MODULO end /* Convenient defines for modulo descriptors */ #define M0 0 #define M1 1 int main ( void ) { int i; /* Modulo buffer will be initialized. R0 will be the modulo pointer register. The buffer size is 10 units. The unit size is ‘sizeof(int)’.
Inline Assembly Language and Intrinsics Intrinsic Functions Listing 7.12 Modulo Buffer Example 2 /* Set up a static location to save error codes */ if ( ! __mod_error(&err_codes)) { printf (“__mod_error set up failed\n”); } /* Initialize a modulo buffer pointer, pointing to an array of 10 ints.
Inline Assembly Language and Intrinsics Intrinsic Functions 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.
Inline Assembly Language and Intrinsics Intrinsic Functions Table 7.3 Modulo Addressing Error Codes (continued) Code Meaning 22 Attempt to use word pointer functions with byte pointer initialization. __mod_getint16 and __mod_setint16 were called but __mod_init was used for initialization. __mod_initint16 is required for pointer initialization. 23 Modulo increment value exceeds modulo buffer size. 24 Attempted use of R1 as a modulo pointer without initializing R0 for modulo use. Table 7.
Inline Assembly Language and Intrinsics Intrinsic Functions 188 Targeting MC56F83xx/DSP5685x Controllers
8 Debugging for DSP56800E This chapter, which explains the generic features of the CodeWarrior™ debugger, consists of these sections: • Target Settings for Debugging • Command Converter Server • Load/Save Memory • Fill Memory • Save/Restore Registers • EOnCE Debugger Features • Using the DSP56800E Simulator • Launching and Operating the Debugger • Register Details Window • Loading a .
Debugging for DSP56800E Command Converter Server Table 8.1 Setting Panels that Affect Debugging This panel… Affects… Refer to… M56800E Linker symbolics, linker warnings “Deadstripping and Link Order” M56800E Processor optimizations “Optimizing Code” Debugger Settings Debugging options Remote Debugging Debugging communication protocol “Remote Debugging” Remote Debug Options Debugging options “Remote Debug Options” The M56800E Target panel is unique to DSP56800E debugging.
Debugging for DSP56800E Command Converter Server Essential Target Settings for Command Converter Server Before you can download programs to a target board for debugging, you must specify the target settings for the command converter server: • Local Settings If you specify that the CodeWarrior IDE start the command converter server locally, the command converter server uses the connection port (for example, LPT1) that you specified when you installed CodeWarrior Development Studio for Motorola 56800/E Hybri
Debugging for DSP56800E Command Converter Server 1. Click the command converter server icon. While the command converter server is running, locate the command converter server icon on the status bar. Right-click on the command converter server icon (Figure 8.1): Figure 8.1 Command Converter Server Icon A menu appears (Figure 8.2): Figure 8.2 Command Converter Server Menu 2. Select Show console from the menu. The Metrowerks Command Converter Server window appears (Figure 8.3).
Debugging for DSP56800E Command Converter Server Figure 8.3 Metrowerks Command Converter Server Window 3. On the console command line, type the following command: delete all 4. Press Enter. 5. Type the following command, substituting the number of the parallel port to use (for example, 1 for LPT1): config cc parallel:1 6. Press Enter. 7. Type the following command to save the configuration: config save 8. Press Enter.
Debugging for DSP56800E Command Converter Server Changing the Command Converter Server Protocol to PCI To change the command converter server to a PCI Connection: 1. While the command converter server is running, right-click on the command converter server icon shown in Figure 8.1 or double click on it. 2. From the menu shown in Figure 8.2, select Show Console. 3. At the console command line in the Metrowerks Command Converter Server window shown in Figure 8.3, type the following command: delete all 4.
Debugging for DSP56800E Command Converter Server Figure 8.4 Remote Connections Panel To Add a New Remote Connection To add a new remote connection: 1. Click the Add button. The New Connection window appears as shown in Figure 8.5.
Debugging for DSP56800E Command Converter Server Figure 8.5 New Connection Window 2. In the Name edit box, type in the connection name. 3. Check Use Remote CCS checkbox. Select this checkbox to specify that the CodeWarrior IDE is connected to a remote command converter server. Otherwise, the IDE starts the command converter server locally 4. Enter the Server IP address or host machine name.
Debugging for DSP56800E Load/Save Memory 6. Click the OK button. To Change an Existing Remote Connection To change an existing remote connection: Double click on the connection name that you want to change, or click once on the connection name and click the Change button (shown in Figure 8.4 in grey). To Remove an Existing Remote Connection To remove an existing remote connection: Click once on the connection name and click the Remove button (shown in Figure 8.4 in grey).
Debugging for DSP56800E Load/Save Memory Figure 8.6 Load/Save Memory Dialog Box 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. History Combo Box The History combo box displays a list of recent loads and saves.
Debugging for DSP56800E Load/Save Memory Radio Buttons The Load/Save Memory dialog box has two radio buttons: • Load Memory • Save Memory The default is Load Memory. Memory Type Combo Box The memory types that appear in the Memory Type Combo box are: • P: Memory (Program Memory) • X: Memory (Data Memory) Address Text Field Specify the address where you want to write the memory. If you want your entry to be interpreted as hex, prefix it with 0x; otherwise, it is interpreted as decimal.
Debugging for DSP56800E Fill Memory 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 Metrowerks CodeWarrior window, select Debug > Fill memory to display the Fill Memory dialog box (Figure 8.7). Figure 8.7 Fill Memory Dialog Box Use this dialog box to fill memory at a specified location and size with user- specified raw memory data.
Debugging for DSP56800E Fill Memory NOTE By default, the History combo box displays the most recent settings on subsequent viewings. Memory Type Combo Box The memory types that can appear in the Memory Type Combo box are: • P:Memory (Program Memory) • X:Memory (Data Memory) Address Text Field Specify the address where you want to write the memory. If you want it to be interpreted as hex, prefix it with 0x; otherwise, it is interpreted as decimal.
Debugging for DSP56800E Save/Restore Registers Dialog Box Controls OK, Cancel, and Esc Clicking OK writes the memory piece by piece until the target memory is filled in. The Status field is updated with the current progress of the operation. When this is in progress, the entire dialog box grays out except the Cancel button, so the user cannot change any information. Clicking the Cancel button halts the fill operation, and reenables the controls on the dialog box.
Debugging for DSP56800E Save/Restore Registers History Combo Box The History combo box displays a list of recent saves and restores. If this is the first time you have saved or restored, the History combo box is empty. If you saved or restored before, the combo box remembers your last ten sessions. The most recent session will appear at the top of the list. Radio Buttons The Save/Restore Registers dialog box has two radio buttons: • Save Registers • Restore Registers The default is Save Registers.
Debugging for DSP56800E EOnCE Debugger Features Browse Button Clicking the Browse button displays OPENFILENAME or SAVEFILENAME, depending on whether you selected the Restore Registers or Save Registers radio button. EOnCE Debugger Features The following EOnCE Debugger features are discussed in this section: • Set Hardware Breakpoint Panel • Special Counters • Trace Buffer • Set Trigger Panel NOTE These features are only available when debugging with a hardware target.
Debugging for DSP56800E EOnCE Debugger Features Figure 8.9 Set Hardware Breakpoint Panel The Set Hardware BreakPoint panel options are: • Set trigger Select this button to open the Set Trigger panel (Figure 8.13). For more information on using this panel, see “Set Trigger Panel.” • Action This pull down list lets you select the resulting action caused by the trigger. – Halt core Stops the processor. – Interrupt Causes an interrupt and uses the vector for the EOnCE hardware breakpoint (unit 0).
Debugging for DSP56800E EOnCE Debugger Features Figure 8.10 EOnCE Special Counter Panel The EOnCE Special Counter panel options are: • Counter size This pull down list gives you the option to use a 16 or 40-bit counter. 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.
Debugging for DSP56800E EOnCE Debugger Features 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.
Debugging for DSP56800E EOnCE Debugger Features 1. From the IDE menu bar, select DSP56800E > Dump Trace Buffer. Figure 8.12 Contents of Trace Buffer To clear triggers set with the Trace Buffer Setup panel (Figure 8.11): 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.
Debugging for DSP56800E EOnCE Debugger Features 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.
Debugging for DSP56800E EOnCE Debugger Features Figure 8.13 Set Trigger Panel The Set Trigger panel options are: • Primary trigger type This pull down list contains the general categories of triggers that can be set. • Primary trigger This pull down list contains the specific forms of the triggers that can be set. This list changes depending on the selection made in the Primary trigger type option.
Debugging for DSP56800E Using the DSP56800E Simulator • Data compare length When the data trigger (address and data) compare trigger is selected, this set of radio buttons becomes available. These options allow you to specify the length of data being compared at that address. • 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.
Debugging for DSP56800E Using the DSP56800E Simulator code on a simulated DSP56800E architecture without installing any additional hardware. The simulator simulates the DSP56800E processor, not the peripherals. In order to use the simulator, you must select a connection that uses the simulator as your debugging protocol from the Remote Debugging panel. NOTE The simulator also enables the DSP56800E menu for retrieving the machine cycle count and machine instruction count when debugging.
Debugging for DSP56800E Launching and Operating the Debugger Memory Map Figure 8.15 Simulator Memory Map $FFFF $FFFF Reserved $FFCO X Data Memory Space Program Memory Space $2000 Reserved $1300 $7F Interrupt Vectors $0 $0 X: P: NOTE Figure 8.15 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.
Debugging for DSP56800E Launching and Operating the Debugger 1. Set debugger preferences. Select Edit >sdm Settings from the menu bar of the Metrowerks CodeWarrior window. The IDE displays the Remote Debugging window. Figure 8.16 Remote Debugging Panel 2. Select the Connection. For example, select 56800E Local Hardware Connection (CCS). 3. Click OK button. 4. Debug the project. Use either of the following options: • From the Metrowerks CodeWarrior window, select Project > Debug.
Debugging for DSP56800E Launching and Operating the Debugger This command resets the board (if Always reset on download is checked in the Debugger’s M56800E Target panel shown in Figure 4.13) and the download process begins. When the download to the board is complete, the IDE displays the Program window (sdm.elf in sample) shown in Figure 8.17.
Debugging for DSP56800E Launching and Operating the Debugger Figure 8.17 Program Window Step Out Step Into Step Over Kill Break Run Breakpoint Watchpoint Expressions Symbolics 5. Navigate through your code. The Program window has three panes: • Stack pane The Stack pane shows the function calling stack. • Variables pane The Variables pane displays local variables. • Source pane The Source pane displays source or assembly code.
Debugging for DSP56800E Launching and Operating the Debugger The toolbar at the top of the window has buttons that allows you access to the execution commands in the Debug menu. Setting Breakpoints 1. Locate the code line. Scroll through the code in the Source pane of the Program window until you come across the main() function. 2. Select the code line. Click the gray dash in the far left-hand column of the window, next to the first line of code in the main() function. A red dot appears (Figure 8.
Debugging for DSP56800E Launching and Operating the Debugger NOTE To remove the breakpoint, click the red dot. The red dot disappears. Setting Watchpoints For details on how to set 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. Viewing and Editing Register Values Registers are platform-specific. Different chip architectures have different registers. 1. Access the Registers window.
Debugging for DSP56800E Launching and Operating the Debugger Figure 8.
Debugging for DSP56800E Register Details Window Figure 8.20 General Purpose Registers Window 2. Edit register values. To edit values in the register window, double-click a register value. Change the value as you wish. 3. Exit the window. The modified register values are saved. Register Details Window From the menu bar of the Metrowerks CodeWarrior window, select View > Register Details or in the Registers window (Figure 8.19) double-click on the register. The Register Details window appears (Figure 8.
Debugging for DSP56800E Register Details Window Figure 8.21 Register Details Window 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 \dsp568e\Generic Register description files must end with the .xml extension.
Debugging for DSP56800E Register Details Window 1. Locate a particular address in program memory. From the menu bar of the Metrowerks CodeWarrior window, select Data > View 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. The Memory window appears (Figure 8.22). Figure 8.22 View X:Memory Window 2. Select type of memory. Locate the Page list box at the bottom of the View Memory window. Select X for X Memory. 3.
Debugging for DSP56800E Register Details 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. 1. Locate a particular address in program memory.
Debugging for DSP56800E Register Details Window Figure 8.23 View P:Memory (Raw Data) Window • Disassembly (Figure 8.24). Figure 8.24 View P:Memory (Disassembly) Window • Source (Figure 8.25).
Debugging for DSP56800E Register Details Window Figure 8.25 View P:Memory (Source) Window • Mixed (Figure 8.26). Figure 8.
Debugging for DSP56800E Loading a .elf File without a Project Loading a .elf File without a Project You can load and debug a .elf file without an associated project. To load a .elf file for debugging without an associated project: 1. Launch the CodeWarrior IDE. 2. Choose File > Open and specify the file to load in the standard dialog box that appears. Alternatively, you can drag and drop a .elf file onto the IDE. 3.
Debugging for DSP56800E Command-Line Debugging Command-Line Debugging In addition to using the regular CodeWarrior IDE debugger windows, you also can debug on the command-line. When you debug on the command-line, you can use: • Commands included in the Tcl script language • Additional debugging commands that are specific to the debugger Tcl Support This section describes how the command-line debugger handles Tcl support.
Debugging for DSP56800E Command-Line Debugging Listing 8.1 Example Tcl Script set x 0; while {$x < 5} { puts "x is $x"; set x [expr $x + 1] } NOTE The run debugging command synchronizes the debug events between blocks in a script file. For example, after a go, next, or step debugging command, run polls the debugging thread state and refrains from executing the next line or block until the debugging thread stops. However, the Tcl source command does not consider the state of the debugging thread.
Debugging for DSP56800E Command-Line Debugging NOTE There is no synchronization of debug events in the startup script. Consequently, add the run debugging command to the startup script and place the following debugging commands in another script to execute them: debug, go, stop, kill, next, and step. Command-Line Debugging Tasks This section describes some tasks for command-line debugging. Open a Command-Line Debugging Window To open a command-line debugging window, choose Debug > Command Line Debugger.
Debugging for DSP56800E Command-Line Debugging View Debugging Command Hints You can view debugging command hints as follows: • To view the hint for a particular debugger-specific command, type the command followed by a space. • The hint shows the syntax for the remainder of the command. • To scroll through all of the debugger-specific commands that you can use on the command line, press the space bar when the cursor is at the start of the command line in the debugging window.
Debugging for DSP56800E Command-Line Debugging Stop an Executing Script To stop a script that is executing, press the Escape key. Switch between Insert and Overwrite Mode To switch between insert and overwrite mode when entering commands on the command line, press the Insert key. Scroll Text in the Command-Line Debugging Window The scrolling line number can be set by the config debugging command.
Debugging for DSP56800E Command-Line Debugging 2. Press Enter or choose Edit > Copy. Paste Text into the Command-Line Debugging Window To paste text from the clipboard into the window: 1. Place the mouse cursor on the command line. 2. Click the right mouse button or choose Edit > Paste. Command-Line Debugging Commands This section describes the command-line debugging commands. NOTE The default number base for entering commands and displaying registers and memory is hexadecimal.
Debugging for DSP56800E Command-Line Debugging Examples Table 8.3 shows examples of the alias command. Table 8.3 Debugging Command Examples: alias Example Description alias .. cd .. This example creates a command named .. to go to the parent directory. alias This example lists all the currently set aliases. alias .. This example removes a previously specified alias (named ..).
Debugging for DSP56800E Command-Line Debugging Table 8.4 Debugging Command Examples: break (continued) Example Description break p:$1048a This example sets a breakpoint on the machine address 1048a. break This example displays all the breakpoints. break #4 off This example removes breakpoint number 4. (To determine the number assigned to a particular breakpoint, execute the break command.) break main.c `15 This example sets a breakpoint on line 15 in main.
Debugging for DSP56800E Command-Line Debugging cd Use the cd debugging command to change to a different directory or display the current directory. When typing a directory name, you can press the Tab key to complete the name automatically. You can use an asterisk as a wild card when entering directory names. Prototype cd [path] Examples Table 8.6 shows examples of the cd command. Table 8.6 Debugging Command Examples: cd Example Description cd This example displays the current directory.
Debugging for DSP56800E Command-Line Debugging • A single register • A block of registers • A single memory address • A block of memory addresses Prototype c[hange] [ register | reg_block | address | addr_block ] [ value ] [ 8bit |16bit | 32bit | 64bit ] reg_block ::= register_first..register_last addr_block ::= address_first..address_last | address#count count ::= a value indicating the number of memory locations whose contents to change Examples Table 8.7 shows examples of the change command. Table 8.
Debugging for DSP56800E Command-Line Debugging • If value is a hexadecimal value, the debugger determines the mode as shown in Table 8.8: Table 8.8 Memory Access Mode for Hexadecimal Values Memory Access Mode When value Length Is...
Debugging for DSP56800E Command-Line Debugging close Use the close debugging command to close the opened default project. Prototype clo[se] config Use the config debugging command to configure the command-line debugging window.
Debugging for DSP56800E Command-Line Debugging p[rocessor] processor_name [subprocessor_name] ] text_color ::= [R_value G_value B_value] background_color ::= [R_value G_value B_value] R_value ::= the R value of an RGB color G_value ::= the G value of an RGB color B_value ::= the B value of an RGB color NOTE The valid values to specify an RGB color are from 0 through 255. number_of_lines ::= the number of lines to scroll Examples Table 8.10 shows examples of the config command. Table 8.
Debugging for DSP56800E Command-Line Debugging Table 8.10 Debugging Command Examples: config (continued) Example Description config project Get the default project name. config target sdm Change the default build target to sdm. copy Use the copy debugging command to copy the contents of a memory address or block of addresses to another memory location. Prototype co[py] addr_group addr addr_group ::= address | addr_block addr_block ::= address_first..
Debugging for DSP56800E Command-Line Debugging debug Use the debug command to start a command-line debugging session for a project. Prototype de[bug] [project_file_name] Examples Table 8.12 shows examples of the debug command. Table 8.12 Debugging Command Examples: debug Example Description debug This example starts a debugging session for the open default project. debug des.mcp This example starts a debugging session for the project named des.mcp.
Debugging for DSP56800E Command-Line Debugging Table 8.13 Debugging Command Examples: dir Example Description dir This example lists all files in the current directory. dir *.txt This example lists all files in the current directory that have a file extension of .txt. dir c:/tmp This example lists all files in the tmp directory of the C: drive. dir /ad This example lists only the subdirectories in the current directory. ls /usr This example lists the contents of the subdirectory called usr.
Debugging for DSP56800E Command-Line Debugging Table 8.14 Debugging Command Examples: disassemble (continued) Example Description disassemble p:0..20 Disassembles program memory address block 0 to 20. disassemble p:$50#10 Disassembles 10 memory locations starting at memory map hexadecimal 50.
Debugging for DSP56800E Command-Line Debugging 64bit]] reg_group ::= a list of register sets separated by spaces reg_block ::= register_first..register_last addr_group ::= address | addr_block addr_block ::= address_first..address_last | address#count count ::= a value indicating the number of memory locations Examples Table 8.15 shows examples of the display command. Table 8.
Debugging for DSP56800E Command-Line Debugging Table 8.15 Debugging Command Examples: display (continued) Example Description display p:00..$100 Displays the p memory contents from address 0 to hexadecimal 100. display p:00#$200 8bit Display hexadecimal 200 memory units’ contents from address 0. Access memory in 8bit mode. evaluate Use the evaluate debugging command to display a C variable type or value.
Debugging for DSP56800E Command-Line Debugging exit Use the exit debugging command to close the command-line debugging window. Prototype [ex]it go Use the go debugging command to start the program that you are debugging from the current instruction. Prototype g[o] [ all | time_period ] If you execute the go command interactively, the command returns immediately. The target program starts to run.
Debugging for DSP56800E Command-Line Debugging Table 8.17 Debugging Command Examples: go (continued) Example Description go 1 This command stops polling the target when no breakpoint is reached within 1 second. It also sets a Tcl variable called $still_running to 1. go all This command starts all the target programs when debugging multiple cores. help Use the help debugging command to display help for the debugging commands in the command-line debugger window.
Debugging for DSP56800E Command-Line Debugging hsst_attach_listener Use the hsst_attach_listener command to set up a Tcl procedure that the debugger notifies whenever there is data in a communication channel. Prototype hsst_a[ttach_listener] channel_id tcl_proc_name Example Execute the procedure call_back automatically when a communication channel has data available from the target.
Debugging for DSP56800E Command-Line Debugging hsst_block_mode $cid hsst_close Use the hsst_close debugging command to close a communication channel with the host machine. Prototype hsst_c[lose] channel_id Example Close a channel and set the result to the variable $cid: hsst_close $cid hsst_detach_listener Use the hsst_detach_listener command to detach a listener that had been previously attached for automatic data notification.
Debugging for DSP56800E Command-Line Debugging Prototype hsst_l[og] cid [ directory_name ] Examples Table 8.19 shows examples of the hsst_log command: Table 8.19 Debugging Command Examples: hsst_log Example Description hsst_log cid c:\logdata The debugger logs the data to the specified directory. hsst_log cid 0 The debugger turns off the log. hsst_noblock_mode Use the hsst_noblock_mode command to configure a communication channel in non-blocking mode.
Debugging for DSP56800E Command-Line Debugging Prototype hsst_o[pen] channel_name Example Open a channel and set the returned ID to the variable $cid: set cid [hsst_open ochannel1] hsst_read Use the hsst_read debugging command to read data from an opened communication channel. Prototype hsst_r[ead] size nmemb cid Example Read 15 data items (each 1 byte in length) from the channel identified by the variable $cid: puts [hsst_read 1 15 $cid] The debugger returns and displays the data.
Debugging for DSP56800E Command-Line Debugging hsst_write 2 0x1234 $cid input Use the input debugging command to map a target memory block to a host file. When a target application reads the memory block, the application reads the contents of the specified host file instead. Prototype i[nput] [ id_num | address filename [ -rd | -rf | -rh | -ru ]] | [ off ] Specify address when using the simulator to debug. Specify id_num when using target hardware to debug.
Debugging for DSP56800E Command-Line Debugging kill Use the kill debugging command to close one or all current debugging sessions. Prototype k[ill] [all] Examples Table 8.21 shows examples of the kill command. Table 8.21 Debugging Command Examples: kill Example Description kill Kills the current debugging session. kill all Kills all the debug sessions when debugging multiple cores. load Use the load debugging command to open a project or load records into memory.
Debugging for DSP56800E Command-Line Debugging Table 8.22 Debugging Command Examples: load Example Description load des.mcp Loads a project named des.mcp. load des.eld Creates a default project from the des.eld object file and loads the project. load -h dat.lod Loads the contents of the hexadecimal file dat.lod into memory. load -b dat.lod p:$20 Loads the contents of the binary file dat.lod into program memory beginning at $20.
Debugging for DSP56800E Command-Line Debugging next Use the next debugging command to step over subroutine calls. If you execute the next command interactively, the command returns immediately. The target program starts to run. Then you can either wait for the target program to stop executing (for example, on a breakpoint) or type the stop debugging command to stop the execution of the target program.
Debugging for DSP56800E Command-Line Debugging • Use -ru to indicate that the output file is an unsigned decimal file. Choose from the following options to indicate how to write to the output file: • Use -a to cause the debugger to append to the output file if it already exists. • Use -o to cause the debugger to overwrite the output file if it already exists. Examples Table 8.24 shows examples of the output command. Table 8.24 Debugging Command Examples: Output Example Description output p:$0 out.
Debugging for DSP56800E Command-Line Debugging The default input and display radix is 16: hexadecimal input and display values. NOTE You can override the default input radix when entering an individual value. To specify a hexadecimal constant, precede the constant with a dollar sign ($). To specify a decimal constant, precede the constant with a grave accent (`). To specify a binary value, precede the constant with a percent sign (%). To specify a fraction value, precede the constant with a caret (^).
Debugging for DSP56800E Command-Line Debugging Table 8.25 Debugging Command Examples: radix Example Description radix Displays the currently enabled radix. radix D Changes the input radix to decimal. radix H Changes the input radix to hexadecimal. radix f r0..r7 Changes the display radix for the specified registers to fraction. radix d x:0#10 r1 Changes the display radix for the specified register and memory blocks to decimal.
Debugging for DSP56800E Command-Line Debugging run test.tcl NOTE You can use the run command to run a script that includes these commands: load, close, debug, kill, and run. However, the preceding commands cannot reside in a block (such as a loop). For example, this script is invalid: set x 0 while {$x < 5} { load a.mcp debug kill } save Use the save debugging command to save the contents of specified memory locations to a binary file or a text file in hexadecimal format.
Debugging for DSP56800E Command-Line Debugging • -a = append to an existing file • -c = write if the file does not yet exist • If the file to which you are trying to save already exists, the save command does not overwrite the file. Instead, the save command cancels and returns without changing the file. • -o = overwrite an existing file You can use the Tcl set command to assign a name to a particular block of memory.
Debugging for DSP56800E Command-Line Debugging Examples Table 8.27 shows examples of the step command. \ Table 8.27 Debugging Command Examples: step Example Description step li This example steps one line. step in This example steps one instruction. step into This example steps into a function. step out This example steps out of a function. stop Use the stop debugging command to stop a running program after invoking a go, step, or next debugging command. Prototype s[top] [all] Examples Table 8.
Debugging for DSP56800E Command-Line Debugging Prototype sw[itchtarget] [index] Examples Table 8.29 shows examples of the switchtarget command. Table 8.29 Debugging Command Examples: switchtarget Example Description switchtarget This example lists the currently available debugging sessions. switchtarget 0 Choose the debugging session whose session ID is 0 to send subsequent debugging commands to. system Use the system debugging command to execute a system command.
Debugging for DSP56800E Command-Line Debugging system del *.tmp view Use the view debugging command to change the view mode. You can toggle the view mode between assembly mode and register mode. Prototype v[iew] [a | r] Examples Table 8.30 shows examples of the view command. Table 8.30 Debugging Command Examples: view Example Description view Toggle the view mode. view a Set the view mode to assembly mode. view r Set the view mode to register mode.
Debugging for DSP56800E System-Level Connect Table 8.31 Debugging Command Examples: wait Example Description wait The debugger waits until you press the space bar on the keyboard. wait 2 The debugger waits for two milliseconds. watchpoint Use the watchpoint debugging command to add, remove, or display a watchpoint. NOTE Due to hardware resource limitations, you can set only one watchpoint at a time. Prototype wat[chpoint] [variable_name | watchpoint_id off] Examples Table 8.
Debugging for DSP56800E Debugging in the Flash Memory 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. To perform a system-level connect: 1. Select the Project window for the program you downloaded. 2. From the menu bar, select Debug > Connect. The debugger connects to the board.
Debugging for DSP56800E Debugging in the Flash Memory 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.
Debugging for DSP56800E Notes for Debugging on Hardware Size> This command adds a flash unit to the list and sets its parameters. NOTE The set_hfm_base and add_hfm_unit commands should not be changed for a particular processor. Their values will always be the same. set_hfm_erase_mode units | pages | all This command sets the erase mode as units, pages or all. If you set this to units, the units that are programmed are mass erased.
Debugging for DSP56800E Notes for Debugging on Hardware • Ensure your Flash data size fits into Flash memory. The linker command file specifies where data is written to. There is no bounds checking for Flash programming. • The standard library I/O function such as printf uses large amount of memory and may not fit into flash targets. • Use the Flash stationery when creating a new project intended for ROM.
9 High-Speed Simultaneous Transfer High-Speed Simultaneous Transfer (HSST) facilitates data transfer between low-level targets (hardware or simulator) and host-side client applications. The data transfer occurs without stopping the core. The host-side client must be an IDE plug-in or a script run through the command-line debugger. When the customer links their application to the target side hsst lib, the debugger detects that the customer wants to use hsst and automatically enables hsst communications.
High-Speed Simultaneous Transfer Host-Side Client Interface 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.
High-Speed Simultaneous Transfer Host-Side Client Interface 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.
High-Speed Simultaneous Transfer Host-Side Client Interface 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.
High-Speed Simultaneous Transfer Host-Side Client Interface 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.
High-Speed Simultaneous Transfer Host-Side Client Interface 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.
High-Speed Simultaneous Transfer Host-Side Client Interface 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.
High-Speed Simultaneous Transfer Host-Side Client Interface 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.
High-Speed Simultaneous Transfer Host-Side Client Interface NOTE Before launching the program, the IDE plugin needs to be created and placed in the folder: CodeWarrior\bin\Plugins\Com. Listing 9.1 Sample HSST Host Program #include #include #include #include "CodeWarriorCommands.h" "HSSTInterface.
High-Speed Simultaneous Transfer Target Library Interface return 0; } Target Library Interface This section describes the API calls for using High-Speed Simultaneous Transfer (HSST) from your target application. At the end of this section, an example of a HSST target program is given (Listing 9.2). 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.
High-Speed Simultaneous Transfer Target Library Interface 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 NOTE This can greatly improve performance.
High-Speed Simultaneous Transfer Target Library Interface 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.
High-Speed Simultaneous Transfer Target Library Interface 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.
High-Speed Simultaneous Transfer Target Library Interface 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.
High-Speed Simultaneous Transfer Target Library Interface 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.
High-Speed Simultaneous Transfer Target Library Interface 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).
High-Speed Simultaneous Transfer Target Library Interface 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. HSST Target Program Example In Listing 9.2 the HSST target program runs in parallel with the host plugin. The target communicates with the host-side (your computer).
High-Speed Simultaneous Transfer Target Library Interface /* Opening channel 1 and 2 from TARGET side */ channel_1 = HSST_open ( "channel_1" ); channel_2 = HSST_open ( "channel_2" ); /* TARGET writing data to channel 1 */ written_items = HSST_write(test_buffer, sizeof(long), buf_size, channel_1); /* TARGET reading data from channel 2 */ read_items = HSST_read(test_buffer, sizeof(long), buf_size, channel_2); return 0; } Figure 9.
10 ELF Linker and Command Language The CodeWarrior™ Executable and Linking Format (ELF) Linker makes a program file out of the object files of your project. The linker also allows you to manipulate code in different ways. You can define variables during linking, control the link order to the granularity of a single function, change the alignment, and even compress code and data segments so that they occupy less space in the output file.
ELF Linker and Command Language Structure of Linker Command Files Memory Segment In the memory segment, available memory is divided into segments. The memory segment format looks like Listing 10.1. Listing 10.1 Sample MEMORY Segment MEMORY { segment_1 (RWX): ORIGIN = 0x8000, LENGTH = 0x1000 segment_2 (RWX): ORIGIN = AFTER(segment_1), LENGTH = 0 data (RW) : ORIGIN = 0x2000, LENGTH = 0x0000 #segment_name (RW) : ORIGIN = memory address, LENGTH = segment length #and so on...
ELF Linker and Command Language Structure of Linker Command Files NOTE The closure blocks need to be in place before the SECTIONS definition in the linker command file. The two types of closure blocks available are: • Symbol-level Use FORCE_ACTIVE to include a symbol into the link that would not be otherwise included. An example is shown in Listing 10.2. Listing 10.
ELF Linker and Command Language Linker Command File Syntax Listing 10.5 Sample SECTIONS Segment 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.
ELF Linker and Command Language Linker Command File Syntax Listing 10.7 Sample ALIGNALL Command Usage file.c (.text) ALIGNALL (0x10); file.c (.data) #everything past this point aligned on 16 bytes Arithmetic Operations Standard C arithmetic and logical operations may be used to define and use symbols in the linker command file. Table 10.1 shows the order of precedence for each operator. All operators are left-associative. Table 10.
ELF Linker and Command Language Linker Command File Syntax 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, KEEP_SECTION, and REF_INCLUDE directives to preserve them in the output file. Variables, Expressions, and Integral Types This section explains variables, expressions, and integral types.
ELF Linker and Command Language Linker Command File Syntax Listing 10.11 Accessing a Global Symbol From C Program Sources extern unsigned long _foot; void main( void ) { unsigned long i; // ... i = _foot; // _foot value determined in LCF // ... } Expressions and Assignments You can create symbols and assign addresses to those symbols by using the standard assignment operator. An assignment may only be used at the start of an expression, and a semicolon is required at the end of an assignment statement.
ELF Linker and Command Language Linker Command File Syntax 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 10.14 shows examples of valid decimal integers that you can write into your linker command file. Listing 10.
ELF Linker and Command Language Linker Command File Syntax Listing 10.16 Sample Function Selection Using OBJECT Keyword 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. ROM to RAM Copying In embedded programming, it is common to copy a portion of a program resident in ROM into RAM at runtime.
ELF Linker and Command Language Linker Command File Syntax .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 = .; *(.data) *(fp_state.data); *(rtlib.data); F__End_Data = .; # Start location for RAM (0x3000) # Write data to the section (ROM) # Get end location for RAM # .bss sections * (rtlib.bss.lo) * (.
ELF Linker and Command Language Linker Command File Syntax unsigned short a = 0, b = 0, c = 0; unsigned long dataLen = 0x0; unsigned short __myArray[] = { 0xdead, 0xbeef, 0xcafe }; // Calculate the data length of the X: memory written to Flash dataLen = (unsigned long)&__End_Data unsigned long)&__Begin_Data; // Block move from ROM to RAM memcpy( (unsigned long *)&__Begin_Data, (const unsigned long *)&__ROMAddress,dataLen ); a = GlobalFlash; return; } Stack and Heap To reserve space for the stack and heap,
ELF Linker and Command Language Linker Command File Keyword Listing WRITEB 0x21; // '!' } Linker Command File Keyword Listing This section explains the keywords available for use when creating CodeWarrior Development Studio for Motorola 56800/E Hybrid Controllers application objects with the linker command file. Valid linker command file functions, keywords, directives, and commands are: . (location counter) The period character (.) always maintains the current position of the output location.
ELF Linker and Command Language Linker Command File Keyword Listing 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); *(.
ELF Linker and Command Language Linker Command File Keyword Listing 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.
ELF Linker and Command Language Linker Command File Keyword Listing Example .code : { ALIGNALL(16); * (.init) * (.text) ALIGNALL(16); * // Align code on 16 byte boundary //align data on 16 byte boundary (.rodata) } > .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 keyword.
ELF Linker and Command Language Linker Command File Keyword Listing 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 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.
ELF Linker and Command Language Linker Command File Keyword Listing a memory address Specify a hex address, such as 0x8000. 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.
ELF Linker and Command Language Linker Command File Keyword Listing 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.
ELF Linker and Command Language Linker Command File Keyword Listing sectionName is the section name for the output section. It must start with a period character. For example, ".mysection". AT (loadAddress) is an optional parameter that specifies the address of the section. The default (if not specified) is to make the load address the same as the relocation address. contents are made up of statements. These statements can: • Assign a value to a symbol.
ELF Linker and Command Language Linker Command File Keyword Listing 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.
ELF Linker and Command Language Linker Command File Keyword Listing 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) 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.
ELF Linker and Command Language DSP56800E Command-Line Tools 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. DSP56800E Command-Line Tools This section contains the following topics: • Usage • Response File • Sample Build Script • Arguments Usage To call the command-line tools, use the following format: Table 10.
ELF Linker and Command Language DSP56800E Command-Line Tools 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 10.3. Table 10.
ELF Linker and Command Language DSP56800E Command-Line Tools Sample Build Script This following is a sample of a DOS batch (BAT) file. The sample demonstrates: • Setting of the environmental variables. • Using the compiler to compile and link a set of files. REM *** set GUI compiler path *** set COMPILER={path to compiler} REM set set set *** set includes path *** MWCIncludes=+%COMPILER%\M56800E Support MWLibraries=+%COMPILER%\M56800E Support MWLibraryFiles=Runtime 56800E.Lib;MSL C 56800E.
ELF Linker and Command Language DSP56800E Command-Line Tools # # # # # # # # # # usage [no]spaces all [no]normal [no]obsolete [no]ignored [no]deprecated [no]meaningless target [no]compatible opt[ion]=name search=keyword group=keyword tool=keyword[,...
ELF Linker and Command Language DSP56800E Command-Line Tools -msgstyle keyword mpw std gcc IDE parseable -[no]stderr # zero means no maximum; default is 0 # global; set error/warning message style # use MPW message style # use standard message style; default # use GCC-like message style # use CW IDE-like message style # use context-free machine-parseable message # style # # global; use separate stderr and stdout streams; # if using -nostderr, stderr goes to stdout Compiler ------------------------------
ELF Linker and Command Language DSP56800E Command-Line Tools -dis[assemble] -E -EP #line # global; passed to all tools; # disassemble files to stdout # global; cased; preprocess source files # global; cased; preprocess and strip out # directives # global; specify extension for generated object # files; with a leading period ('.
ELF Linker and Command Language DSP56800E Command-Line Tools # filename extension -nosyspath # global; treat #include <...> like #include # "...
ELF Linker and Command Language DSP56800E Command-Line Tools -char keyword signed unsigned # set sign of 'char' # chars are signed; default # chars are unsigned # -Cpp_exceptions on|off # passed to linker; # enable or disable C++ exceptions; default is # on -dialect | -lang keyword # passed to linker; # specify source language c # treat source as C always c++ # treat source as C++ always ec++ # generate warnings for use of C++ features # outside Embedded C++ subset (implies # 'dialect cplus') # ‘dialect c
ELF Linker and Command Language DSP56800E Command-Line Tools # # 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
ELF Linker and Command Language DSP56800E Command-Line Tools -O -O+keyword[,...] # same as '-O2' # cased; control optimization; you may combine # options as in '-O4,p' 0 # same as '-opt off' 1 # same as '-opt level=1' 2 # same as '-opt level=2' 3 # same as '-opt level=3' 4 # same as '-opt level=4' p # same as '-opt speed' s # same as '-opt space' # -opt keyword[,...
ELF Linker and Command Language DSP56800E Command-Line Tools display|dump # # # display complete list of active optimizations ---------------------------------------------------------------------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 pipelin
ELF Linker and Command Language DSP56800E Command-Line Tools [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 | # p
ELF Linker and Command Language DSP56800E Command-Line Tools -lr path -l+file -[no]defaults -nofail -[no]stdlib # search paths have global scope over the # command line and are searched in the order # given # global; like '-l', but add recursive library # search path # cased; add a library by searching access paths # for file named lib.
ELF Linker and Command Language DSP56800E Command-Line Tools unix -sreclength length -usebyteaddr -o file # Unix ('\n') # # specify length of S-records (should be a # multiple of 4); implies '-srec'; for # 'length', range 8 - 252; default is 64 # use byte address in S-record file; implies # '-srec' # specify output filename ---------------------------------------------------------------------DSP M56800E Project Options ----------------------------------------------------------------------application # g
ELF Linker and Command Language DSP56800E Command-Line Tools ---------------------------------------------------------------------Warning Options ----------------------------------------------------------------------w[arn[ings]] # global; warning options keyword[,...
ELF Linker and Command Language DSP56800E Command-Line Tools # # 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
ELF Linker and Command Language DSP56800E Command-Line Tools 324 Targeting MC56F83xx/DSP5685x Controllers
11 Libraries and Runtime Code You can use a variety of libraries with the CodeWarrior™ IDE. The libraries include ANSI-standard libraries for C, runtime libraries, and other codes. This chapter explains how to use these libraries for DSP56800E development. With respect to the Metrowerks Standard Library (MSL) for C, this chapter is an extension of the MSL C Reference. Consult that manual for general details on the standard libraries and their functions.
Libraries and Runtime Code MSL for DSP56800E 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.
Libraries and Runtime Code MSL for DSP56800E NOTE DSP56800E stationery creates new projects with LDM and SDM targets and the appropriate libraries. Below is a list of the DSP56800E libraries: • Metrowerks Standard Libraries (MSL) – MSL C 56800E.lib Standard C library support for Small Data Model. – MSL C 56800E lmm.lib Standard C library support for Large Data Model. • Runtime Libraries – runtime 56800E.lib Low-level functions for MSL support for Small Data Model with Host I/O via JTAG port.
Libraries and Runtime Code MSL for DSP56800E Table 11.1 Host File Creation Location fopen Filename Parameter Host Creation Location filename with no path target project file folder full path location of full path Allocating Stacks and Heaps for the DSP56800E Stationery linker command files (LCF) define heap, stack, and bss locations. LCFs are specific to each target board. When you use M56800E stationery to create a new project, CodeWarrior automatically adds the LCF to the new project.
Libraries and Runtime Code Runtime Initialization 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.
Libraries and Runtime Code Runtime Initialization The starting point for a program is set in the Entry Point field in the M56800E Linker settings panel. The project for the DSP56800E runtime is: CodeWarrior\M56800E Support\runtime_56800E\projects\Runtime 56800E.mcp Table 11.3 Library Names and Locations Library Name Location Large Memory Model Runtime 56800E lmm.lib CodeWarrior\M56800E Support\runtime_56800E\lib Small Memory Model Runtime 56800E.
Libraries and Runtime Code Runtime Initialization section rtlib XREF F_stack_addr org p: GLOBAL Finit_M56852_ SUBROUTINE "Finit_M56852_",Finit_M56852_,Finit_M56852ENDFinit_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) ; Setup the m01 re
Libraries and Runtime Code EOnCE Library noinc: tfra move.w nop move.w adda r0,sp #0,r1 ; set stack pointer too r1,x:(sp) #1,sp jsr F__init_sections ; Call main() move.w move.w move.w #0,y0 #0,R2 #0,R3 ; Pass parameters to main() jsr Fmain ; Call the Users program ; ; The fflush calls where removed because they added code ; growth in cases where the user is not using any debugger IO. ; Users should now make these calls at the end of main if they use debugger IO ; ; move.
Libraries and Runtime Code EOnCE Library 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.
Libraries and Runtime Code EOnCE Library • Trace Buffer Capture Options • Trace Buffer Full Options • Miscellaneous Trace Buffer Option _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.
Libraries and Runtime Code EOnCE Library _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.
Libraries and Runtime Code EOnCE Library 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.
Libraries and Runtime Code EOnCE Library 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.
Libraries and Runtime Code EOnCE Library _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.
Libraries and Runtime Code EOnCE Library *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.
Libraries and Runtime Code EOnCE Library _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.
Libraries and Runtime Code EOnCE Library 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.
Libraries and Runtime Code EOnCE Library 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.
Libraries and Runtime Code EOnCE Library 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.
Libraries and Runtime Code EOnCE Library Return Codes Every function except _eonce_Initialize returns one of the error codes in Table 11.4. Table 11.4 Error Codes Error Code Description EONCE_ERR_NONE No error. EONCE_ERR_NOT_INITIALIZED The _eonce_Initialize function has not been called before the current function. EONCE_ERR_UNIT_OUT_OF_RANGE The unit parameter is greater than or equal to the number of units specified in _eonce_Initialize.
Libraries and Runtime Code EOnCE Library 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 Table 11.
Libraries and Runtime Code EOnCE Library Table 11.
Libraries and Runtime Code EOnCE Library B1PA_SC_B2PF_HC B2PF_SC_B1PA_HC Table 11.6 Defined Identifier Key: Counter Trigger Modes Identifier Fragments Description B1 breakpoint 1; value set in value1 B2 breakpoint 2; value set in value2 P p-memory address; this is followed by a type of access X x-memory address; this is followed by a type of access.
Libraries and Runtime Code EOnCE Library Table 11.7 Data Selection Modes Defined Identifiers Description B2D_WORD makes a comparison when the data being moved is of word-length B2D_LONG makes a comparison when the data being moved is of long-length Counter Function Modes One of the defined identifiers in Table 11.8 must be OR’ed into the options parameter of the _eonce_SetCounterTrigger function. Table 11.
Libraries and Runtime Code EOnCE Library Counter Unit Action Options This list of options describes the action taken when a counter trigger is generated. One of the defined identifiers in Table 11.10 must be OR’ed into the options parameter of the _eonce_SetCounterTrigger function. Identifiers that include ZERO_BEFORE_TRIGGER only perform the action when the counter counts down to zero before the Counter Stop Trigger occurs.
Libraries and Runtime Code EOnCE Library Table 11.
Libraries and Runtime Code EOnCE Library Table 11.
Libraries and Runtime Code EOnCE Library Table 11.
A Porting Issues This appendix explains issues relating to successfully porting code to the most current version of the CodeWarrior Development Studio for Motorola 56800/E Hybrid Controllers. This appendix contains the following sections: • Converting the DSP56800E 1.x or 2.x, to 6.x Projects • Removing "illegal object_c on pragma directive" Warning Converting the DSP56800E 1.x or 2.x, to 6.
Porting Issues Removing "illegal object_c on pragma directive" Warning Removing "illegal object_c on pragma directive" Warning If after porting a project to DSP56800E 6.x, you get a warning that says illegal object_c on pragma directive, you need to remove it. To remove this warning: 1. Open the project preference and go to the C/C++ Preprocessor. 2. Remove the line #pragma objective_con from the prefix text field.
B DSP56800x New Project Stationery Wizard This appendix explains the high-level design of the new project stationery wizard. High-Level Design The DSP56800x New Project Stationery Wizard supports the DSP56800x processors listed in Table B.1. Table B.
DSP56800x New Project Stationery Wizard High-Level Design • Resulting Target Rules • Rule Notes Click on the following link for details about the DSP56800x New Project Stationery Wizard Graphical User Interface: • DSP56800x New Project Stationery Wizard Graphical User Interface 356 Targeting MC56F83xx/DSP5685x Controllers
DSP56800x New Project Stationery Wizard High-Level Design Page Rules The page rules governing the wizard page flow for the simulator and the different processors are shown in the Table B.2, Table B.3, Table B.4, and Table B.5. Table B.
DSP56800x New Project Stationery Wizard High-Level Design Table B.4 Page Rules for the DSP56852, DSP56853, DSP56854, DSP56855, DSP56857, and DSP56858 Target Selection Page Next Page Next Page DSP56852 Program Choice with Processor Expert Option Page Finish Page DSP56853 DSP56854 DSP56855 DSP56857 DSP56858 Table B.
DSP56800x New Project Stationery Wizard High-Level Design Resulting Target Rules The rules governing possible final project configurations are shown in Table B.6. Table B.
DSP56800x New Project Stationery Wizard DSP56800x New Project Stationery Wizard Graphical User Interface Rule Notes Additional notes for the DSP56800x New Project Stationery Wizard rules are: • The DSP56800x New Project Stationery 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.
DSP56800x New Project Stationery Wizard DSP56800x New Project Stationery Wizard Graphical User Interface Invoking the New Project Stationery Wizard To invoke the New Project dialog box, from the Metrowerks CodeWarrior menu bar, select File>New (Figure B.1). Figure B.
DSP56800x New Project Stationery Wizard DSP56800x New Project Stationery Wizard Graphical User Interface New Project Dialog Box After selecting File>New from the Metrowerks CodeWarrior menu bar, the New project Dialog Box (Figure B.2) appears. In the list of stationeries, you can select either the “DSP56800x New Project Wizard” or any of the other regular stationery. Figure B.
DSP56800x New Project Stationery Wizard DSP56800x New Project Stationery Wizard Graphical User Interface Target Pages When invoked, the New Project Stationery 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, Figure B.4, Figure B.5, and Figure B.6). Figure B.
DSP56800x New Project Stationery Wizard DSP56800x New Project Stationery Wizard Graphical User Interface Figure B.
DSP56800x New Project Stationery Wizard DSP56800x New Project Stationery Wizard Graphical User Interface Figure B.
DSP56800x New Project Stationery Wizard DSP56800x New Project Stationery Wizard Graphical User Interface Figure B.6 DSP56800x New Project Wizard Target Dialog Box (MC56F83x) 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.
DSP56800x New Project Stationery Wizard DSP56800x New Project Stationery Wizard Graphical User Interface NOTE The Processor Expert option is not available here, since Processor Expert is not applicable to the Simulator. Figure B.7 DSP56800x New Project Wizard - Program Choice without Processor Expert Page When you click Next, the Wizard jumps to the appropriate page determined by the “Page Rules.” Program Choice Page with Processor Expert Option Page If you chose one of the processors, then Figure B.
DSP56800x New Project Stationery Wizard DSP56800x New Project Stationery Wizard Graphical User Interface Figure B.8 DSP56800x New Project Wizard - Program Choice with Processor Expert Page When you click Next, the Wizard jumps to the appropriate page determined by the “Page Rules.
DSP56800x New Project Stationery Wizard DSP56800x New Project Stationery Wizard Graphical User Interface Data Memory Model Page If you select a DSP56800E processor (56F83xx or 5685x family), then the Data Memory Model page appears (Figure B.9) and you must select either the Small Data Model (SDM) or Large Data Model (LDM). Figure B.9 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.
DSP56800x New Project Stationery Wizard DSP56800x New Project Stationery Wizard Graphical User Interface External/Internal Memory Page Depending on the processor that you select, the External/Internal Memory page may appear (Figure B.10) and you must select either external or internal memory. NOTE Multiple memory targets can be checked. Figure B.10 DSP56800x New Project Wizard - External/Internal Memory Page When you click Next, the Wizard jumps to the appropriate page determined by the “Page Rules.
DSP56800x New Project Stationery Wizard DSP56800x New Project Stationery Wizard Graphical User Interface Finish Page When you click the Finish button on the Finish Page (Figure B.11), the project creation process start. NOTE All target choices end on this page. Figure B.
DSP56800x New Project Stationery Wizard DSP56800x New Project Stationery Wizard Graphical User Interface 372 Targeting MC56F83xx/DSP5685x Controllers
C Pragmas for the DSP56800 and DSP56800E You can configure the compiler globally for a project by changing the settings in the C/C++ Language panel. You can also control compiler behavior in your code in a localized manner by including the appropriate pragmas. Many of the pragmas correspond to settings in the C/C++ Language panel and the settings panels for processors and operating systems.
Pragmas for the DSP56800 and DSP56800E Pragma Scope #include #pragma profile reset // If the Generate Profiler Calls setting was originally on, // turns it back on. Otherwise, the setting remains off Suppose that you use #pragma profile on instead of #pragma profile reset. If you later disable Generate Profiler Calls from the Preference dialog box, that pragma turns it on. Using reset ensures that you do not inadvertently change the settings in the Project Settings dialog box.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Pragma Reference Click any of the links in Table C.1 to jump to the corresponding pragma. Table C.
Pragmas for the DSP56800 and DSP56800E Pragma Reference always_inline Controls the use of inlined functions. Prototype #pragma always_inline on | off | reset Remarks This pragma is strongly deprecated. Use the inline_depth() pragma instead. If you enable this pragma, the compiler ignores all inlining limits and attempts to inline all functions where it is legal to do so. This pragma does not correspond to any panel setting.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Listing C.2 Unnamed Arguments void f(int ) {} /* OK, if ANSI Strict is disabled */ void f(int i) {} /* ALWAYS OK */ • A # token that does not appear before an argument in a macro definition. Listing C.3 shows an example. Listing C.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Remarks For each file that has assembly output activated, the compiler generates an .asm file that is equivalent to the original .c file. It stores the new .asm file in the same directory as the original .c file, replacing the .c filename extension with .asm. This pragma works for an individual file. However, an option of the M56800/E Processor panel specifies global creation of assembly output. auto_inline Controls which functions to inline.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Remarks Use this pragma for extra validation of generated C code. The compiler already checks for pipeline conflicts; this pragma tells the compiler to add another check for pipeline conflicts. Should this pragma detect a pipeline conflict, it issues an error message. NOTE The pipeline conflicts that this pragma finds are rare. Should this pragma report such a conflict with your code, you should report the matter to Metrowerks.
Pragmas for the DSP56800 and DSP56800E Pragma Reference const_strings Controls the const-ness of string literals. Prototype #pragma const_strings [ on | off | reset ] Remarks If you enable this pragma, the compiler will generate a warning when string literals are not declared as const. Listing C.5 shows an example. Listing C.
Pragmas for the DSP56800 and DSP56800E Pragma Reference extern void f(); extern void g(); main() { f(); // will be inlined g(); // will be inlined } inline void f() {} void g() {} NOTE The compiler requires more memory at compile time if you enable this pragma. This pragma corresponds to the Deferred Inlining setting in the C/C++ Language panel. To check this setting, use the __option (defer_codegen), described in Checking Settings. By default, this pragma is disabled.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Section name string for initialized data assigned to . For example: ".data" Optional Arguments: Section name string for uninitialized data assigned to . If ustring is not specified then istring is used. One of the following indicating the attributes of the section: R readable RW readable and writable RX readable and executable RWX readable, writable, and executable Note The default is RW.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Prototype #pragma dollar_identifiers on | off | reset Remarks If you enable this pragma, the compiler accepts dollar signs ($) in identifiers. Otherwise, the compiler issues an error if it encounters anything but underscores, alphabetic, and numeric characters in an identifier. This pragma does not correspond to any panel setting. To check this setting, use the __option (dollar_identifiers), described in Checking Settings.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Prototype #pragma dont_reuse_strings on | off | reset Remarks If you enable this pragma, the compiler stores each string literal separately. Otherwise, the compiler stores only one copy of identical string literals. This pragma helps you save memory if your program contains a lot of identical string literals that you do not modify.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Listing C.7 Example of Enumerations the Same as Size as int enum SmallNumber { One = 1, Two = 2 }; /* If you enable enumsalwaysint, this type is the same size as an int. Otherwise, this type is short int. */ enum BigNumber { ThreeThousandMillion = 3000000000 }; /* If you enable enumsalwaysint, the compiler might generate an error. Otherwise, this type is the same size as a long int.
Pragmas for the DSP56800 and DSP56800E Pragma Reference NOTE The pragmas explicit_zero_data and initializedzerodata are the same, however, the preferred syntax is explicit_zero_data. extended_errorcheck Controls the issuing of warnings for possible unintended logical errors. Prototype #pragma extended_errorcheck on | off | reset Remarks If you enable this pragma, the C compiler generates a warning (not an error) if it encounters some common programming errors.
Pragmas for the DSP56800 and DSP56800E Pragma Reference gcc_extensions Controls the acceptance of GNU C language extensions. Prototype #pragma gcc_extensions on | off | reset Remarks If you enable this pragma, the compiler accepts GNU C extensions in C source code. This includes the following non-ANSI C extensions: • Initialization of automatic struct or array variables with non-const values. Listing C.8 provides an example. Listing C.
Pragmas for the DSP56800 and DSP56800E Pragma Reference This pragma does not correspond to any setting in the C/C++ Language panel. To check the global optimizer, use __option (gcc_extensions), described in Checking Settings. By default, this pragma is disabled. initializedzerodata Controls the section where zero-initialized global variables are emitted. Prototype #pragma initializedzerodata on | off | reset Remarks If you enable this pragma, zero-initilaized global variables are emitted to the .
Pragmas for the DSP56800 and DSP56800E Pragma Reference Remarks Bottom-up function inlining tries to expand up to eight levels of inline leaf functions. The maximum size of an expanded inline function and the caller of an inline function can be controlled by the pragmas shown in Listing C.10 and Listing C.11. Listing C.10 Maximum Complexity of an Inlined Function // maximum complexity of an inlined function #pragma inline_max_size( max ) // default max == 256 Listing C.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Prototype #pragma inline_depth(n) #pragma inline_depth(smart) Remarks Sets the number of passes used to expand inline function calls. The number n is an integer from 0 to 1024 or the smart specifier. It also represents the distance allowed in the call chain from the last function up.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Prototype #pragma interrupt [called|warn|saveall[warn]] Remarks The compiler generates a special prologue and epilogue for functions so that they may be used to handle interrupts. The contents of the epilogue and prologue vary depending on the mode selected. The compiler also emits an RTI or RTS for the return statement depending upon the mode selected. The SA, R, and CC bits of the OMR register are set to system default.
Pragmas for the DSP56800 and DSP56800E Pragma Reference – You can use this argument on the function prototype or within the function body as described below. On the function prototype: #pragma interrupt called void function_called_from_interrupt (void); Within the function body: void function_called_from_interrupt (void) { #pragma interrupt called asm (nop); } – You should use this pragma for all functions called from #pragma interrupt enabled ISRs.
Pragmas for the DSP56800 and DSP56800E Pragma Reference In Table C.2, the advantages and disadvantages of the interrupt and interrupt saveall pragmas are listed. Table C.
Pragmas for the DSP56800 and DSP56800E Pragma Reference • Emit an RTI for the return statement depending upon the mode selected. If the interrupt routine has a return value, the return register is not saved. There are several ways to use this pragma, with an on|off|reset arguments, or with no arguments. Arguments on|off|reset alignsp Aligns the stack pointer register correctly to allow long values to be pushed on to the stack.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Listing C.12 Sample Code - #pragma interrupt on | off | reset #pragma interrupt off value // Non ISR code #pragma interrupt on void ISR_1(void) { // ISR_1 code goes here. } // To be used as default void ISR_2(void) { // ISR_2 code goes here. } #pragma interrupt reset If the pragma is inside a function block, compile the current routine as an interrupt routine.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Data1+=Data2; return; } void ISR1(void) { /* This is an interrupt service routine. */ #pragma interrupt Data2 = Datain+2; ISR_inc_Data1_by_Data2(); } Avoiding Possible Hitches with enabled Pragma Interrupt Pragma interrupt with the called or default mode for a C routine saves only the volatile registers for that C routine. Register values are not preserved if the ISR makes one or more function calls.
Pragmas for the DSP56800 and DSP56800E Pragma Reference line_prepdump Shows #line directives in preprocessor output. Prototype #pragma line_prepdump on | off | reset Remarks If you enable this pragma, #line directives appear in preprocessor output, and line spacing is preserved through the insertion of empty lines. Use this pragma with the command-line compiler’s -E option to make sure that #line directives are inserted in the compiler’s output. This pragma does not correspond to any panel setting.
Pragmas for the DSP56800 and DSP56800E Pragma Reference message Issues a text message to the user. Prototype #pragma message("text") Remarks This pragma tells the compiler to issue a message, text, to the user. When running under the CodeWarrior IDE, the message appears in the Errors & Warnings window. This pragma does not correspond to any setting in the C/C++ Language panel. By default, this pragma is disabled. mpwc_newline Controls the use of newline character convention used by the Apple MPW C.
Pragmas for the DSP56800 and DSP56800E Pragma Reference This pragma corresponds to the Map newlines to CR setting in the C/C++ Language panel. To check this setting, use __option (mpwc_newline), described in Checking Settings. By default, this pragma is disabled. Enabling this setting is not useful for the DSP56800 target. mpwc_relax Controls the compatibility of the char* and unsigned char* types.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Prototype #pragma notonce Remarks If you enable this pragma, include statements can be repeatedly included, even if you have enabled #pragma once on. For more information, see “once.” This pragma does not correspond to any setting in the C/C++ Language panel. By default, this pragma is disabled. once Controls whether or not a header file can be included more than once in the same source file.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Prototype #pragma only_std_keywords on | off | reset Remarks The C/C++ compiler recognizes additional reserved keywords. If you are writing code that must follow the ANSI standard strictly, enable the pragma only_std_keywords. This pragma corresponds to the ANSI Keywords Only setting in the C/C++ Language panel. To check this setting, use __option (only_std_keywords), described in Checking Settings. By default, this pragma is disabled.
Pragmas for the DSP56800 and DSP56800E Pragma Reference opt_dead_assignments Controls the use of dead store optimization. Prototype #pragma opt_dead_assignments on | off | reset Remarks If you enable this pragma, the compiler removes assignments to unused variables before reassigning them. This pragma does not correspond to any panel setting in the C/C++ Language panel. To check this setting, use __option (opt_dead_assignments), described in Checking Settings. By default, this pragma is disabled.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Prototype #pragma opt_lifetimes on | off | reset Remarks If you enable this pragma, the compiler uses the same processor register for different variables that exist in the same routine but not in the same statement. This pragma does not correspond to any panel setting in the C/C++ Language panel. To check this setting, use __option (opt_lifetimes), described in Checking Settings. By default, this pragma is disabled.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Remarks If you enable this pragma, the compiler replaces multiple occurrences of one variable with a single occurrence. This pragma does not correspond to any panel setting in the C/C++ Language panel. To check this setting, use __option (opt_propagation), described in Checking Settings. By default, this pragma is disabled. opt_strength_reduction Controls the use of strength reduction optimization.
Pragmas for the DSP56800 and DSP56800E Pragma Reference that the optimization is only applied when the array element arithmetic is not of an unsigned type that is smaller than a pointer type. This pragma does not correspond to any panel setting in the C/C++ Language panel. To check this setting, use __option (opt_strength_reduction_strict), described in Checking Settings. By default, this pragma is disabled. opt_unroll_loops Controls the use of loop unrolling optimization.
Pragmas for the DSP56800 and DSP56800E Pragma Reference For more information on the optimization the compiler performs for each optimization level, refer to the Code Warrior IDE User’s Guide. These pragmas correspond to the settings in the Global Optimizations panel. By default, this pragma is disabled. optimize_for_size Controls optimization to reduce the size of object code.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Remarks If you enable this pragma, integer longs within structures are aligned on four byte boundaries. When this pragma is disabled there is no alignment within structures. This pragma does not correspond to any setting in the C/C++ Language panel. To check this setting, use __option(packstruct), described in Checking Settings. By default, this pragma is enabled. peephole Controls the use peephole optimization.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Remarks If you enable this setting, the compiler collects all string constants into a single data object so that your program needs only one TOC entry for all of them. While this decreases the number of TOC entries in your program, it also increases your program size because it uses a less efficient method to store the address of the string. If you disable this setting, the compiler creates a unique data object and TOC entry for each string constant.
Pragmas for the DSP56800 and DSP56800E Pragma Reference If you are writing new code and need to set a pragma setting to its original value, use the reset argument, described in “Pragma Syntax.” This pragma does not correspond to any panel setting in the C/C++ Language panel. readonly_strings Controls the output of C strings to the read only data section.
Pragmas for the DSP56800 and DSP56800E Pragma Reference If you enable this pragma, the compiler generates an error if you use a function that does not have a prototype. This pragma helps you prevent errors that happen when you use a function before you define it or refer to it. This pragma corresponds to the Require Function Prototypes setting in the C/C++ Language panel. To check this setting, use __option (require_prototypes), described in Checking Settings. By default, this pragma is disabled.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Identifier by which this user-defined section is referenced in the source. Listing C.16 Sample Code - pragma define_section and pragma section /* 1. Define the section */ #pragma define_section mysection ".mysection.data" RW /* 2. Specify the data to be put into the section.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Remarks By default, the preprocessor adds comments about the current include file being processed in its output. Enabling this pragma disables these comments. This pragma does not correspond to any panel setting in the C/C++ Language panel. To check this setting, use __option (simple_prepdump), described in Checking Settings. By default, this pragma is disabled. suppress_init_code Controls the suppression of static initialization object code.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Remarks If you enable this pragma, the compiler does not generate warnings, including those that are enabled. This pragma does not correspond to any panel setting in the C/C++ Language panel. To check this setting, use __option (suppress_warnings), described in Checking Settings. By default, this pragma is disabled. syspath_once Controls how include files are treated.
Pragmas for the DSP56800 and DSP56800E Pragma Reference NOTE If you enable this pragma, your code might not be compatible with libraries that were compiled when the pragma was disabled. In particular, your code might not work with the ANSI libraries included with CodeWarrior. This pragma corresponds to the Use Unsigned Chars setting in the C/C++ Language panel. To check this setting, use __option (unsigned_char), described in Checking Settings. By default, this setting is disabled.
Pragmas for the DSP56800 and DSP56800E Pragma Reference use_rodata Controls the section where constant data is emitted. Compatibility This pragma is compatible with the DSP56800, but it is not compatible with the DSP56800E. Prototype #pragma use_rodata [ on | off | reset ] Remarks By default, the compiler emits const defined data to the .data section. There are two ways to cause the compiler to emit const defined data to the .rodata section: 1. Setting the “write const data to .
Pragmas for the DSP56800 and DSP56800E Pragma Reference #pragma use_rodata on const Int16 d[]={0xdddd}; const Int16 e[]={0xeeee}; const Int16 f[]={0xffff}; #pragma use_rodata off main() { // ... code } You must then appropriately locate the .rodata section created by the compiler using the linker command file. For example, see Listing C.19. Listing C.19 Sample Linker Command FIle - Pragma use_rodata MEMORY { .text_segment (RWX) : ORIGIN = 0x2000, LENGTH = 0x00000000 .
Pragmas for the DSP56800 and DSP56800E Pragma Reference warn_any_ptr_int_conv Controls if the compiler generates a warning when an integral type is explicitly converted to a pointer type or vice versa. Prototype #pragma warn_any_ptr_int_conv on | off | reset Remarks This pragma is useful to identify potential pointer portability issues. An example is shown in Listing C.20. Listing C.
Pragmas for the DSP56800 and DSP56800E Pragma Reference warn_emptydecl Controls the recognition of declarations without variables. Prototype #pragma warn_emptydecl on | off | reset Remarks If you enable this pragma, the compiler displays a warning when it encounters a declaration with no variables. Listing C.21 Example of Pragma warn_emptydecl int ; int i; // WARNING // OK This pragma corresponds to the Empty Declarations setting in the C/C++ Preprocessor panel.
Pragmas for the DSP56800 and DSP56800E Pragma Reference This pragma corresponds to the Extra Commas setting in the C/C++ Preprocessor panel. To check this setting, use __option (warn_extracomma), described in Checking Settings. By default, this pragma is disabled. warn_filenamecaps Controls the recognition of conflicts involving case-sensitive filenames within user includes.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Prototype #pragma warn_filenamecaps_system on | off | reset Remarks If you enable this pragma, the compiler issues a warning when an include directive capitalizes a filename within a system include differently from the way the filename appears on a disk. It also recognizes 8.3 DOS filenames in Windows when a long filename is available. This pragma helps avoid porting problems to operating systems with case-sensitive filenames.
Pragmas for the DSP56800 and DSP56800E Pragma Reference warn_impl_f2i_conv Controls the issuing of warnings for implicit float-to-int conversions. Prototype #pragma warn_impl_f2i_conv on | off | reset Remarks If you enable this pragma, the compiler issues a warning for implicitly converting floating-point values to integral values. Listing C.23 provides an example. Listing C.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Prototype #pragma warn_impl_i2f_conv on | off | reset Remarks If you enable this pragma, the compiler issues a warning for implicitly converting integral values to floating-point values. Listing C.24 provides an example. Listing C.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Remarks If you enable this pragma, the compiler issues a warning for implicitly converting either from signed int to unsigned int or vice versa. Listing C.25 provides an example. Listing C.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Remarks If you enable this pragma, the compiler issues a warning for all implicit arithmetic conversions when the destination type might not represent the source value. Listing C.26 provides an example. Listing C.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Remarks If you enable this pragma, the compiler issues a warning if you attempt to pass a noninteger numeric value, such as a float or long long, to an unprototyped function when the require_prototypes pragma is disabled. This pragma does not correspond to any panel setting in the C/C++ Preprocessor panel. To check this setting, use __option (warn_largeargs), described in Checking Settings. By default, this pragma is disabled.
Pragmas for the DSP56800 and DSP56800E Pragma Reference warn_no_side_effect Controls the issuing of warnings for redundant statements. Prototype #pragma warn_no_side_effect on | off | reset Remarks If you enable this pragma, the compiler issues a warning when it encounters a statement that produces no side effect. To suppress this warning, cast the statement with (void). Listing C.28 provides an example. Listing C.
Pragmas for the DSP56800 and DSP56800E Pragma Reference This pragma corresponds to the Non-Inlined Functions setting in the C/C++ Preprocessor panel. To check this setting, use __option (warn_notinlined), described in Checking Settings. By default, this pragma is disabled. warn_on_unknown_sp_modification Generates a warning if the user specifies an inline assembly instruction which modifies the SP by a run-time dependent amount.
Pragmas for the DSP56800 and DSP56800E Pragma Reference This pragma corresponds to the Pad Bytes Added setting in the C/C++ Warnings panel. To check this setting, use __option (warn_padding), described in Checking Settings By default, this setting is disabled. warn_possunwant Controls the recognition of possible unintentional logical errors.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Listing C.29 Example for #pragma warn_ptr_int_conv #pragma warn_ptr_int_conv on char *my_ptr; char too_small = (char)my_ptr; // WARNING: char is too small See also “warn_any_ptr_int_conv,”. This pragma corresponds to the Pointer / Integral Conversions setting in the C/C++ Warnings panel. To check this setting, use __option (warn_ptr_int_conv), described in Checking Settings. By default, this setting is disabled.
Pragmas for the DSP56800 and DSP56800E Pragma Reference warn_undefmacro Controls the detection of undefined macros in #if / #elif conditionals. Prototype #pragma warn_undefmacro on | off | reset Remarks Listing C.31 provides an example. Listing C.31 Example of Undefined Macro #if UNDEFINEDMACRO == 4 // WARNING: undefined macro // ’UNDEFINEDMACRO’ used in // #if/#elif conditional Use this pragma to detect the use of undefined macros (especially expressions) where the default value 0 is used.
Pragmas for the DSP56800 and DSP56800E Pragma Reference Remarks If you enable this pragma, the compiler issues a warning when it encounters an argument you declare but do not use. To suppress this warning in C++ source code, leave an argument identifier out of the function parameter list. This pragma corresponds to the Unused Arguments setting in the C/C++ Preprocessor panel. To check this setting, use __option (warn_unusedarg), described in Checking Settings. By default, this pragma is disabled.
Pragmas for the DSP56800 and DSP56800E Illegal Pragmas This pragma corresponds to the Treat All Warnings as Errors setting in the C/C++ Preprocessor panel. To check this setting, use __option (warning_errors), described in Checking Settings. By default, this pragma is disabled. Illegal Pragmas If you enable the Illegal Pragmas setting, the compiler issues a warning when it encounters a pragma it does not recognize. For example, the pragma statements in Listing C.
Pragmas for the DSP56800 and DSP56800E Checking Settings #endif lists all the setting names you can use in the preprocessor function __option(). Table C.3 Preprocessor Setting Names for __option() This argument... Corresponds to the… always_inline Pragma always_inline. ANSI_strict ANSI Strict setting in the C/C++ and pragma ANSI_strict. auto_inline Auto-Inline setting of the Inlining menu in the C/ C++ Language panel and pragma auto_inline. const_strings Pragma const_strings.
Pragmas for the DSP56800 and DSP56800E Checking Settings Table C.3 Preprocessor Setting Names for __option() (continued) This argument... Corresponds to the… only_std_keywords ANSI Keywords Only setting in the C/C++ Language panel and pragma only_std_keywords. opt_common_subs Pragma opt_common_subs. opt_dead_assignments Pragma opt_dead_assignments. opt_dead_code Pragma opt_dead_code. opt_lifetimes Pragma opt_lifetimes. opt_loop_invariants Pragma opt_loop_invariants.
Pragmas for the DSP56800 and DSP56800E Checking Settings Table C.3 Preprocessor Setting Names for __option() (continued) This argument... Corresponds to the… trigraphs Expand Trigraphs setting in the C/C++ panel and pragma trigraphs. unsigned_char Use Unsigned Chars setting in the C/C++ Language panel and pragma unsigned_char. warn_any_ptr_int_conv Pragma warn_any_ptr_int_conv. warn_emptydecl Empty Declarations setting in the C/C++ Language panel and pragma warn_emptydecl.
Pragmas for the DSP56800 and DSP56800E Checking Settings Table C.3 Preprocessor Setting Names for __option() (continued) This argument... Corresponds to the… warn_ptr_int_conv Pragma warn_ptr_int_conv warn_resultnotused Pragma warn_resultnotused. warn_undefmacro Pragma warn_undefmacro. warn_unusedarg Unused Arguments setting in the C/C++ Preprocessor panel and pragma warn_unusedarg. warn_unusedvar Unused Variables setting in the C/C++ Preprocessor panel and pragma warn_unusedvar.
Index Symbols #include directive getting path 386 #line directive 397 #pragma statement illegal 432 syntax 373 . (location counter) linker keyword 298, 299 .
config 238–240 copy 240 debug 241 dir 241, 242 disassemble 242, 243 display 243–245 evaluate 245 exit 246 go 246, 247 help 247 history 247 hsst_attach_listener 248 hsst_block_mode 248, 249 hsst_close 249 hsst_detach_listener 249 hsst_log 249, 250 hsst_noblock_mode 250 hsst_open 250, 251 hsst_write 251, 252 input 252 kill 253 load 253, 254 log 254 ls 241, 242 next 255 output 255, 256 pwd 256 radix 256–258 restart 258 run 258, 259 save 259, 260 step 260, 261 stop 261 switchtarget 261, 262 system 262, 263 view
Don’t Inline option 433 dont_inline pragma 383 dont_reuse_strings pragma 384 DSP56800E command line tools 308–323 DSP56800E simulator 211 E -E option 397 ELF disassembler panel 59–61 ELF linker and command language 287–323 enumerated types 384 enumsalwaysint pragma 384 EOnCE debugger features 204–211 EOnCE library definitions 343–352 EOnCE library functions 332–343 _eonce_ClearTraceBuffer 340, 341 _eonce_ClearTrigger 337 _eonce_EnableDEBUGEV 342 _eonce_EnableLimitTrigger 342, 343 _eonce_GetCounters 338 _eo
hsst_block_mode 273, 274 HSST_close 278, 279 hsst_close 270 hsst_detach_listener 275 HSST_flush 282 hsst_noblock_mode 274 HSST_open 278 hsst_open 269 HSST_raw_read 283 HSST_raw_write 283, 284 HSST_read 281 hsst_read 271 HSST_set_log_dir 284, 285 hsst_set_log_dir 276 HSST_setvbuf 279, 280 HSST_size 282 hsst_size 273 HSST_write 280, 281 hsst_write 272 HSST host program example 276–278 HSST target program example 285, 286 hsst_attach_listener debugging command 248 hsst_attach_listener function 274, 275 hsst_bl
div_s4q 156 extract_h 153 extract_l 153, 154 ffs_l 165, 166 ffs_s 164 fractional arithmetic 142, 143 implementation 141, 142 L_abs 146 L_add 149 L_deposit_h 154 L_deposit_l 154, 155 L_mac 161 L_msu 162 L_mult 162, 163 L_mult_ls 163 L_negate 147 L_shl 173, 174 L_shlftNs 174 L_shlfts 175 L_shr 175, 176 L_shr_r 176, 177 L_shrtNs 177 L_sub 149, 150 mac_r 158, 159 msu_r 159 mult 160 mult_r 160, 161 negate 145, 146 norm_l 166 norm_s 164, 165 round 167 shl 168, 169 shlftNs 169, 170 shlfts 170, 171 shr 171 shr_r 17
log debugging command 254 ls debugging command 241, 242 M M5600E target panel 44, 45 M56800E assembler panel 54, 56 M56800E linker panel 61–65 M56800E processor panel 56 M56800E target (debugging) panel 67–71 mac_r intrinsic function 158, 159 math support intrinsic functions 143–177 MEMORY linker keyword 302, 303 memory map window 91, 92 memory, viewing 221–225 message pragma 398 Metrowerks Standard Library (MSL) 325–329 modulo addressing error codes 186, 187 intrinsic functions 177–187 points to remember
section 410 syntax 373 #pragma statement syntax 373 pragmas asmoutput 377 check_inline_asm_pipeline 378, 379 interrupt 396 preprocessor #line directive 397 header files 386 Processor Expert beans 78–79 code generation 76–77 menu 79–82 overview 75–82 page 77 tutorial 96–112 Processor Expert interface 75–112 Processor Expert windows 83–95 bean inspector 84, 85 bean selector 83–84 CPU types overview 92 installed beans overview 94 memory map 91, 92 peripherals usage inspector 95 resource meter 93 target CPU 86–
shlftNs intrinsic function 169, 170 shlfts intrinsic function 170, 171 shr intrinsic function 171 shr_r intrinsic function 172 shrtNs intrinsic function 172, 173 side effects warning 426 simple_prepdump pragma 411 simulator 211 simultaneous transfer, high speed 269–286 SIZEOF linker keyword 306 SIZEOFW linker keyword 307 Source Trees settings panel 42 special counters EOnCE panel 205–207 stack frames 119, 120 statements #pragma 432, 373 stationery saving new target settings 41 step debugging command 260, 26
warn_unusedarg pragma 430 warn_unusedvar pragma 431 warning_errors pragma 431 warnings illegal pragmas 432 watchpoint debugging command 264 watchpoints 218 windows bean inspector 79, 84, 85 bean selector 78, 83–84 CPU types overview 92 installed beans overview 94 memory map 91, 92 peripherals usage inspector 95 Processor Expert 83–95 register details 220–225 resource meter 93 target CPU 86–90 WRITEB linker keyword 307 WRITEH linker keyword 307 WRITEW linker keyword 308 X X memory, viewing 221–223 XML files
TMP–446 Targeting MC56F83xx/DSP5685x Controllers