Targeting 56800
Targeting 56800
Targeting 56800
Freescale, the Freescale logo, and CodeWarrior are trademarks or registered trademarks of Freescale Corporation in the United States and/or other countries. All other trade names and trademarks are the property of their respective owners. Copyright 2006 by Freescale Semiconductor company. All rights reserved. No portion of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, without prior written permission from Freescale. Use of this document and related materials is governed by the license agreement that accompanied the product to which this manual pertains. This document may be printed for non-commercial personal use only in accordance with the aforementioned license agreement. If you do not have a copy of the license agreement, contact your Freescale representative or call 1-800-377-5416 (if outside the U.S., call +1-512-996-5300). Freescale reserves the right to make changes to any product described or referred to in this document without further notice. Freescale makes no warranty, representation or guarantee regarding the merchantability or fitness of its products for any particular purpose, nor does Freescale assume any liability arising out of the application or use of any product described herein and specifically disclaims any and all liability. Freescale software is not authorized for and has not been designed, tested, manufactured, or intended for use in developing applications where the failure, malfunction, or any inaccuracy of the application carries a risk of death, serious bodily injury, or damage to tangible property, including, but not limited to, use in factory control systems, medical devices or facilities, nuclear facilities, aircraft navigation or communication, emergency systems, or other applications with a similar degree of potential hazard.
Table of Contents
1 Introduction 13
CodeWarrior IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Freescale 56800/E Digital Signal Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . 14 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Getting Started
19
System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 DSP56800 Hardware Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Installing and Registering the CodeWarrior IDE . . . . . . . . . . . . . . . . . . . . . . . . 20 Installing DSP56800 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Using Parallel Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Installing the PCI Command Converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
31
CodeWarrior IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 CodeWarrior Compiler for DSP56800 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 CodeWarrior Assembler for DSP56800 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 CodeWarrior Linker for DSP56800 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 CodeWarrior Debugger for DSP56800 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Metrowerks Standard Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Development Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Project Files versus Makefiles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Editing Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Compiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Linking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Viewing Preprocessor Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Tutorial
37
CodeWarrior Development Studio for Freescale 56800 Tutorial . . . . . . . . . . . . 37 Creating a Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Working with the Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Table of Contents
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61
Target Settings
63
Target Settings Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 Target Setting Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 Changing Target Settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65 Exporting and Importing Panel Options to XML Files . . . . . . . . . . . . . . . . .66 Restoring Target Settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67 CodeWarrior IDE Target Settings Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67 DSP56800-Specific Target Settings Panels. . . . . . . . . . . . . . . . . . . . . . . . . . . . .68 Target Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68 M56800 Target. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70 C/C++ Language (C only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72 C/C++ Preprocessor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75 C/C++ Warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77 M56800 Assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82 ELF Disassembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83 M56800 Processor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86 M56800 Linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88 Remote Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92 M56800 Target (Debugging) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94 Remote Debug Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99
101
Processor Expert Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101 Processor Expert Code Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 Processor Expert Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103 Processor Expert Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105 Processor Expert Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109 Bean Selector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109 Bean Inspector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110 Target CPU Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Memory Map Window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 CPU Types Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119 Resource Meter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120
4 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual
Table of Contents
Installed Beans Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Peripherals Usage Inspector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Processor Expert Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
C for DSP56800
137
General Notes on C. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 Number Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 DSP56800 Integer Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 DSP56800 Floating-Point Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 DSP56800 Fixed-Point Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Calling Conventions, Stack Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Calling Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Volatile and Non-Volatile Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 Stack Frame. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 User Stack Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Sections Generated by the Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 OMR Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 Optimizing Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Page 0 Register Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Array Optimizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Multiply and Accumulate (MAC) Optimizations . . . . . . . . . . . . . . . . . . . . 152 Compiler or Linker Interactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Deadstripping Unused Code and Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Link Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
155
Working With DSP56800 Assembly Language . . . . . . . . . . . . . . . . . . . . . . . . 155 Inline Assembly Language Syntax for DSP56800 . . . . . . . . . . . . . . . . . . . 156 Adding Assembly Language to C Source Code . . . . . . . . . . . . . . . . . . . . . 157 General Notes on Inline Assembly Language. . . . . . . . . . . . . . . . . . . . . . . 158 Creating Labels for M56800 Inline Assembly . . . . . . . . . . . . . . . . . . . . . . 158 Using Comments in M56800 Inline Assembly . . . . . . . . . . . . . . . . . . . . . . 159 Calling Assembly Language Functions from C Code . . . . . . . . . . . . . . . . . . . 159 Calling Inline Assembly Language Functions . . . . . . . . . . . . . . . . . . . . . . 159 Calling Stand-alone Assembly Language Functions . . . . . . . . . . . . . . . . . 160
56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 5
Table of Contents
Calling Functions from Assembly Language . . . . . . . . . . . . . . . . . . . . . . . . . .161 Intrinsic Functions for DSP56800. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162 An Overview of Intrinsic Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162 Fractional Arithmetic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163 Macros Used with Intrinsics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163 List of Intrinsic Functions: Definitions and Examples . . . . . . . . . . . . . . . . . . .164 Absolute/Negate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166 __abs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166 __negate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166 _L_negate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .167 Addition/Subtraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .167 __add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .167 __sub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .168 _L_add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169 _L_sub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170 __stop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170 Conversion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170 __fixed2int. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171 __fixed2long . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171 __fixed2short . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172 __int2fixed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172 __labs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .173 __long2fixed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174 __short2fixed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174 Copy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174 __memcpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .175 __strcpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .175 Deposit/ Extract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176 __extract_h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176 __extract_l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177 _L_deposit_h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177 _L_deposit_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178 Division . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178 __div . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178
6 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual
Table of Contents
__div_ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Multiplication/ MAC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 __mac_r. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 __msu_r. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 __mult . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 __mult_r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 _L_mac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 _L_msu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 _L_mult . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 _L_mult_ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 Normalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 __norm_l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 __norm_s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 Rounding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 __round . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 Shifting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 __shl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 __shr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 __shr_r. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 _L_shl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 _L_shr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 _L_shr_r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 Pipeline Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
197
Using Remote Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Accessing Remote Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Understanding Remote Connections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 Editing Remote Connections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 Target Settings for Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 Command Converter Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 Essential Target Settings for Command Converter Server . . . . . . . . . . . . . 208 Changing the Command Converter Server Protocol to Parallel Port . . . . . 208 Changing the Command Converter Server Protocol to HTI . . . . . . . . . . . . 210 Changing the Command Converter Server Protocol to PCI . . . . . . . . . . . . 211
56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 7
Table of Contents
Setting Up a Remote Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 Debugging a Remote Target Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .214 Launching and Operating the Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .214 Setting Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .217 Setting Watchpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .217 Viewing and Editing Register Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . .218 Viewing X: Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .219 Viewing P: Memory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .221 Load/Save Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .225 Fill Memory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .228 Save/Restore Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .230 OnCE Debugger Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .232 Watchpoints and Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .232 Trace Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239 Using the 56800 Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .240 Cycle/Instruction Count. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .241 Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .242 Register Details Window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .242 Loading a .elf File without a Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243 Using the Command Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .244 System-Level Connect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .244 Debugging on a Complex Scan Chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245 Setting Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245 JTAG Initialization File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .247 Debugging in the Flash Memory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .249 Flash Memory Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .249 set_hfmclkd <value> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .249 set_hfm_base <address> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .250 set_hfm_config_base <address> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .250 add_hfm_unit <startAddr> <endAddr> <bank> <numSectors> <pageSize> <progMem> <boot> <interleaved> . . . . . . . . . . . . . . . . . . . . . . . . . . . .250 set_hfm_erase_mode units | pages | all . . . . . . . . . . . . . . . . . . . . . . . . . . .250 set_hfm_verify_erase 1 | 0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .251 set_hfm_verify_program 1 | 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .251 Setting up the Debugger for Flash Programming . . . . . . . . . . . . . . . . . . . . . . .251
8 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual
Table of Contents
Use Flash Config File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 Notes for Debugging on Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 Flash Programming the Reset and Interrupt Vectors . . . . . . . . . . . . . . . . . . . . 254
10 Data Visualization
255
Starting Data Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Data Target Dialog Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 Graph Window Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
261 263
Structure of Linker Command Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 Memory Segment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 Closure Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 Sections Segment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 Linker Command File Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 Arithmetic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 Deadstrip Prevention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 Variables, Expressions and Integral Types . . . . . . . . . . . . . . . . . . . . . . . . . 268 File Selection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 Function Selection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 ROM to RAM Copying. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 Stack and Heap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 Writing Data Directly to Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 Linker Command File Keyword Listing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 . (location counter) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 ADDR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 ALIGN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 ALIGNALL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 9
Table of Contents
FORCE_ACTIVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .277 INCLUDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .277 KEEP_SECTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .277 MEMORY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .277 OBJECT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279 REF_INCLUDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279 SECTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280 SIZEOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281 SIZEOFW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281 WRITEB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282 WRITEH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282 WRITES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282 WRITEW. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .283 Sample M56800 Linker Command File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .283
13 Command-Line Tools
289
Usage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .289 Response File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .290 Sample Build Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .291 Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .291 General Command-Line Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .291 Linker. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .302 Assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .306
307
MSL for DSP56800. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .307 Using MSL for DSP56800 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .307 Allocating Stacks and Heaps for the DSP56800 . . . . . . . . . . . . . . . . . . . . .309 Runtime Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .311
15 Troubleshooting
317
Troubleshooting Tips. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .317 The Debugger Crashes or Freezes When Stepping Through a REP Statement. 318 "Cant Locate Program Entry On Start" or "Fstart.c Undefined" . . . . . . . .318
10 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual
Table of Contents
When Opening a Recent Project, the CodeWarrior IDE Asks If My Target Needs To Be Rebuilt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 "Timing values not found in FLASH configuration file. Please upgrade your configuration file. On-chip timing values will be used which may result in programming errors" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 IDE Closes Immediately After Opening . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 Errors When Assigning Physical Addresses With The Org Directive . . . . 319 The Debugger Reports a Plug-in Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 Windows Reports a Failed Service Startup . . . . . . . . . . . . . . . . . . . . . . . . . 320 No Communication With The Target Board . . . . . . . . . . . . . . . . . . . . . . . . 320 Downloading Code to DSP Hardware Fails . . . . . . . . . . . . . . . . . . . . . . . . 321 The CodeWarrior IDE Crashes When Running My Code . . . . . . . . . . . . . 321 The Debugger Acts Strangely . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 Problems With Notebook Computers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 How to make Parallel Port Command Converter work on Windows 2000 Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
A Porting Issues
323
Converting the DSP56800 Projects from Previous Versions . . . . . . . . . . . . . . 323 Removing illegal object_c on pragma directive Warning . . . . . . . . . . . . . . . 324 Setting-up Debugging Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324 Using XDEF and XREF Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324 Using the ORG Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
327
Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 Page Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 Resulting Target Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 Rule Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331 DSP56800x New Project Wizard Graphical User Interface . . . . . . . . . . . . . . . 332 Invoking the New Project Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 New Project Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 Target Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 Program Choice Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 Data Memory Model Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
11
Table of Contents
Index
349
12
1
Introduction
This manual explains how to use the CodeWarrior Integrated Development Environment (IDE) to develop code for the DSP56800 family of processors (DSP56F80x and the DSP56F82x). This chapter contains the following sections: CodeWarrior IDE on page 13 Freescale 56800/E Digital Signal Controllers on page 14 References on page 16
CodeWarrior IDE
The CodeWarrior IDE consists of a project manager, a graphical user interface, compilers, linkers, a debugger, a source-code browser, and editing tools. You can edit, navigate, examine, compile, link, and debug code, within the one CodeWarrior environment. The CodeWarrior IDE lets you configure options for code generation, debugging, and navigation of your project. Unlike command-line development tools, the CodeWarrior IDE organizes all files related to your project. You can see your project at a glance, so organization of your source-code files is easy. Navigation among those files is easy, too. When you use the CodeWarrior IDE, there is no need for complicated build scripts of makefiles. To add files to your project or delete files from your project, you use your mouse and keyboard, instead of tediously editing a build script. For any project, you can create and manage several configurations for use on different computer platforms. The platform on which you run the CodeWarrior IDE is called he host. host, you use the CodeWarrior IDE to develop code to target various platforms. Note the two meanings of the term target: Platform Target The operating system, processor, or microcontroller fin which/ on which your code will execute. Build Target The group of settings and files that determine what your code is, as well as control the process of compiling and linking. The CodeWarrior IDE lets you specify multiple build targets. For example, a project can contain one build target for debugging and another build target optimized for a particular operating system (platform target). These build targets can share files, even though each
13
Introduction
Freescale 56800/E Digital Signal Controllers build target uses its own settings. After you debug the program, the only actions necessary to generate a final version are selecting the projects optimized build target and using a single Make command. The CodeWarrior IDEs extensible architecture uses plug-in compilers and linkers to target various operating systems and microprocessors. For example, the IDE uses a GNU tool adapter for internal calls to DSP56800 development tools. Most features of the CodeWarrior IDE apply to several hosts, languages, and build targets. However, each build target has its own unique features. This manual explains the features unique to the CodeWarrior Development Studio for Freescale 56800. For comprehensive information about the CodeWarrior IDE, see the CodeWarrior IDE Users Guide. NOTE For the very latest information on features, fixes, and other matters, see the CodeWarrior Release Notes, on the CodeWarrior IDE CD.
Table 1.1 Supported DSP56800x Processors for CodeWarrior Development Studio for Freescale 56800 DSP56800
DSP56F801 (60 MHz) DSP56F801 (80 MHz)
DSP56800E
DSP56852 DSP56853
14
Introduction
Freescale 56800/E Digital Signal Controllers Table 1.1 Supported DSP56800x Processors for CodeWarrior Development Studio for Freescale 56800 (continued) DSP56800
DSP56F802 DSP56F803 DSP56F805 DSP56F807 DSP56F826 DSP56F827
DSP56800E
DSP56854 DSP56855 DSP56857 DSP56858 MC56F8013 MC56F8014 MC56F8023 MC56F8025 MC56F8036 MC56F8037 MC56F8122 MC56F8123 MC56F8145 MC56F8146 MC56F8147 MC56F8155 MC56F8156 MC56F8157 MC56F8165 MC56F8166 MC56F8167 MC56F8322 MC56F8323 MC56F8335
15
Introduction
References Table 1.1 Supported DSP56800x Processors for CodeWarrior Development Studio for Freescale 56800 (continued) DSP56800 DSP56800E
MC56F8345 MC56F8346 MC56F8356 MC56F8357 MC56F8365 MC56F8366 MC56F8367
References
Your CodeWarrior IDE includes these manuals: CodeWarrior IDE Users Guide CodeWarrior Development Studio IDE 5.6 Windows Automation Guide CodeWarrior Development Studio for Freescale 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Family Targeting Manual CodeWarrior Development Studio for Freescale 56800/E Digital Signal Controllers: MC56F8xxx/DSP5685x Family Targeting Manual CodeWarrior Builds Tools Reference for Freescale 56800/E Digital Signal Controllers CodeWarrior Development Studio IDE 5.5 Users Guide Profiler Supplement CodeWarrior Development Studio for Freescale DSP56800x Embedded Systems Assembler Manual Codewarrior USB TAP Users Guide Freescale 56800 Family IEEE - 754 Compliant Floating-Point Library User Manual Freescale 56800E Family IEEE - 754 Compliant Floating-Point Library User Manual CodeWarrior Development Studio HTI Host Target Interface (for Once/ JTAG Communication) Users Manual DSP56800 to DSP56800E Porting Guide, Freescale Semiconductors, Inc. 16 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual
Introduction
References 56F807 to 56F8300/56F8100 Porting User Guide, Freescale Semiconductors Inc. To learn more about the DSP56800E processor, refer to the Freescale manual, DSP56800E Family Manual. To learn more about the DSP56800 processor, refer to the following manuals: DSP56800 Family Manual. Freescale Semiconductors, Inc. DSP56F801 Hardware User Manual. Freescale Semiconductors, Inc. DSP56F803 Hardware User Manual. Freescale Semiconductors, Inc. DSP56F805 Hardware User Manual. Freescale Semiconductors, Inc. DSP56F807 Hardware User Manual. Freescale Semiconductors, Inc. DSP56F826 Hardware User Manual. Freescale Semiconductors, Inc. DSP56F827 Hardware User Manual. Freescale Semiconductors, Inc. For more information on the various command converters supported by the CodeWarrior Development Studio for Freescale 56800 (DSP56F80x/DSP56F82x), refer to the following manuals: Suite56 Ethernet Command Converter Users Manual, Freescale Semiconductors, Inc. Suite56 PCI Command Converter Users Manual, Freescale Semiconductors, Inc. Suite56 Parallel Port Command Converter Users Manual, Freescale Semiconductors, Inc. To download electronic copies of these manuals or order printed versions, visit: http://www.freescale.com/
17
Introduction
References
18
2
Getting Started
This chapter explains how to install and run the CodeWarrior IDE on your Windows operating system. This chapter also explains how to connect hardware for each of the communications protocols supported by the CodeWarrior debugger. This chapter contains the following sections: System Requirements on page 19 Installing and Registering the CodeWarrior IDE on page 20 Installing DSP56800 Hardware on page 24
System Requirements
Table 2.1 on page 19 lists system requirements for installing and using the CodeWarrior IDE for DSP56800. Table 2.1 Requirements for the CodeWarrior IDE Category
Host Computer Hardware Operating System Hard Drive
Requirement
PC or compatible host computer with 1.0-GHz Pentium-compatible processor, 512 megabytes of RAM, and a CD-ROM drive Microsoft Windows 2000/XP 2.0 gigabytes of free space, plus space for user projects and source code
19
Getting Started
Installing and Registering the CodeWarrior IDE
Boards Supported
All 56800 targets
25-pin OCD ribbon cable Target Interface Module JTAG 14-pin ribbon interface cable
b. Click Launch CodeWarrior Setup the install wizard displays welcome page. c. Follow the wizard instructions, accepting all the default settings. d. At the prompt to check for updates, click the Yes button the CodeWarrior updater opens. 2. To check for updates: NOTE If the updater already has Internet connection settings, you may proceed directly to substep f.
20
Getting Started
Installing and Registering the CodeWarrior IDE a. Click the Settings button the Updater Settings dialog box appears. b. Click the Load Settings button the updater loads settings from your Windows control panel. c. Modify the settings, as appropriate. d. If necessary, enter the proxy username and the password. e. Click the Save button the Updater Settings dialog box disappears. f. In the updater screen, click the Check for Updates button. g. If updates are available, follow the on-screen instructions to download the updates to your computer. h. When you see the message, Your version is up to date, click the OK button the message box closes. i. Click the updater Close button the installation resumes. j. At the prompt to restart the computer, select the Yes option button. k. Click the Finish button the computer restarts, completing installation. 3. To register the CodeWarrior software: a. Select Start> Programs>Freescale CodeWarrior> CW for DSC56800 R8.0>CodeWarrior IDE. b. Select Help > Register Product the Freescale registration page appears. Figure 2.1 Freescale Registration Page
c. Click item number 1 Register your CodeWarrior product. d. Login or Register on the Freescale site.
21
Getting Started
Installing and Registering the CodeWarrior IDE
NOTE
In the next screen you will be asked to confirm your Registration code by clicking Continue a second time. After registration is complete, you will
22
Getting Started
Installing and Registering the CodeWarrior IDE receive an email with the activation code and directions on how to activate your product. f. Click the Activation link in the email that you receive. g. Login to the Freescale site. h. Enter the License Authorization Code into the field.
i. For the default selection: Ethernet Address determine your ethernet address: Launch a Command Prompt window Enter ipconfig /all Copy the Physical Address value of the first Ethernet adapter listed Paste value into the "Node Lock ID for license" text box (remove spaces or dashes) j. Click Continue Activation. k. Click Continue to confirm the Host ID and License Authorization Code. The website will display your license keys along with instructions on installing the license. Copy and paste these keys into the top of the "license.dat" file located at the root of your CodeWarrior installation directory. Your product should now be fully licensed and operational. Table 2.3 on page 24 lists the directories created during full installation. To test your system, follow the instructions of the next section to create a project.
23
Getting Started
Installing DSP56800 Hardware
Contents
Target-specific projects and code. Applications such as cwspawn.exe and cvs.exe. The CodeWarrior IDE application and associated plugin tools. Command converter server executable files and related support files. Default files used by the CodeWariior IDE for the DSP56800 stationery. Drivers to the CCS and command line tools, plus IDE default files for the DSP56800x stationery. Documentation specific to the Freescale DSP56800 series. Core IDE and target-specific help files. (Access help files through the Help menu or F1 key.) Licensing information. Support for PCLint. Initialization files, Metrowerks Standard Library (MSL) and Runtime Library. Profiler libraries. Files for the Processor Expert. Release notes for the CodeWarrior IDE and each tool. Templates for creating DSP56800 projects. Each template pertains to a specific debugging protocol.
ccs
DSP 56800x_EABI_Support
DSP56800x_EABI_Tools
Freescale_Documentation
Help
24
Getting Started
Installing DSP56800 Hardware
NOTE
You can use the DSP56800 Simulator provided with the CodeWarrior IDE instead of installing additional DSP568xx hardware. However, the DSP56800 Simulator is a core simulator and will not give you product specific features (such as peripherals, specialized memory maps, etc.)
DSP568xxEVM
25
Getting Started
Installing DSP56800 Hardware
Connecting via the Suite56 Parallel Port Command Converter Module and DSP568xxEVM Board
1. Enable the JTAG port. See the Hardware Manual or Kit Installation Guide for the jumpers that you need to change from the default configuration for your particular hardware. 2. Connect the 25-pin male connector at one end of a parallel port cable to the 25-pin female connector on your computer (Figure 2.3 on page 26). Figure 2.3 Connecting Parallel Port Cable to Suite56TM Parallel Command Converter Module and DSP568xxEVM Board
14-pin Ribbon Cable 25-pin Parallel Port Cable Host Computer
DSP568xxEVM
Suite56TM Parallel Command Converter JTAG / OnCE port Module Parallel Port Power Supply Connector
3. Connect the 25-pin female connector at the other end of the parallel port cable to the 25-pin male connector on the Suite56TM Parallel Port Command Converter module. 4. Locate the 14-pin ribbon cable hanging from the Suite56TM Parallel Port Command Converter module. Connect the 14-pin female connector of the ribbon cable to the 14pin JTAG male connector on the DSP568xxEVM board. Ensure that the red stripe on the ribbon cable corresponds to pin 1 on the DSP568xxEVM card. 5. Plug the power supply into a wall socket. 6. Connect the power supply to the power connector on the DSP568xxEVM board. The green LED next to the power connector lights up.
26
Getting Started
Installing DSP56800 Hardware
3. Locate an empty card slot in your computer. 4. Insert the PCI Command Converter card in the empty card slot. NOTE One end of the 25-pin cable has a 24-pin female connector. A ground cable is retrofitted to a wire of the 25-pin cable at the same end of the cable. The ground cable is crimped to a female disconnect terminal.
5. Connect the 24-pin female connector at one end of the 25-pin cable to the 24-pin female connector on the PCI Command Converter card (Figure 2.4 on page 29). 6. Connect the female disconnect terminal of the ground cable to the socket protruding from the PCI Command Converter card in your computer. 7. Connect the 25-pin female connector at the other end of the 25-pin cable to the 25-pin male connector on the OCDemonTM Wiggler.
27
Getting Started
Installing DSP56800 Hardware 6. Type the following: wdreg -file mac_mot remove wdreg remove wdreg install wdreg -file mac_mot install 7. Shut down your computer. 8. Turn on your computer.
28
Getting Started
Installing DSP56800 Hardware Figure 2.4 Attaching PCI Command Converter to DSP568xxEVM Board
14-pin Ribbon Cable DSP568xxEVM Host Computer
OCDemon Wiggler
29
Getting Started
Installing DSP56800 Hardware
30
3
Development Studio Overview
This chapter is for new users of the CodeWarrior IDE. This chapter contains the following sections: CodeWarrior IDE on page 31 Development Process on page 32 If you are an experienced CodeWarrior IDE user, you will recognize the look and feel of the user interface. However, it is necessary that you become familiar with the DSP56800 runtime software environment.
CodeWarrior IDE
The CodeWarrior IDE lets you create software applications. It controls the project manager, the source-code editor, the class browser, the compiler, linker, and the debugger. In the project manager, you can organize all the files and settings related to your project so that you can see your project at a glance and easily navigate among your source-code files. The CodeWarrior IDE automatically manages build dependencies. A project can have multiple build targets. A build target is a separate build (with its own settings) that uses some or all of the files in the project. For example, you can have both a debug version and a release version of your software as separate build targets within the same project. The CodeWarrior IDE has an extensible architecture that uses plug-in compilers and linkers to target various operating systems and microprocessors. The CodeWarrior CD includes a C compiler for the DSP56800 family of processors. Other CodeWarrior software packages include C, C++, and Java compilers for Win32, Linux, and other hardware and software combinations.
NOTE
Development Process
The CodeWarrior IDE helps you manage your development work more effectively than you can with a traditional command-line environment. Figure 3.1 on page 33 depicts application development using the IDE.
32
Create/Manage Project
(4) Notes: (1) Use any combination: stationery (template) files, library files, or your own source files. (2) Compiler, linker, debugger settings; target specification; optimizations. (3) Edit source and resource files. (4) Possible corrections: adding a file, changing settings, or editing a file.
Edit Files
(3)
no Success?
no
End
33
Editing Code
The CodeWarrior IDE features a text editor. It handles text files in MS-DOS/Windows, and UNIX formats. To open and edit a source-code file, or any other editable file in a project, use either of the following options: Double-click the file in the project window. Click the file. The file is highlighted. Drag the file to the Freescale CodeWarrior IDE window. The editor window has excellent navigational features that allow you switch between related files, locate any particular function, mark any location within a file, or go to a specific line of code.
Compiling
To compile any source-code file in the current build target, select the source-code file in the project window and then select Project > Compile from the menu bar of the Freescale CodeWarrior window. To compile all the files in the current build target that were modified since they were last compiled, select Project >Bring Up To Date from the menu bar of the Freescale CodeWarrior window.
34
As a result of this architecture, 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. Users derive significant benefit from this architecture. For example, an advance in the C/C++ front-end compiler means an immediate advance in all code generation. Optimizations in the IR mean that any new code generator is highly optimized. Targeting a new processor does not require compilerrelated changes in the source code, so porting is much simpler. All compilers are built as plug-in modules. The compiler and linker components are modular plug-ins. Freescale publishes this API, allowing developers to create custom or proprietary tools. For more information, go to Freescale Support at this URL: http://www.Freescale.com/MW/Support Once the compiler generates object code, the plug-in linker generates the final executable file. Multiple linkers are available for some platform targets to support different objectcode formats. 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 35
Linking
To link object code into a final binary file, select Project > Make from the menu bar of the Freescale CodeWarrior window. The Make command brings the active project up to date, then links the resulting object code into a final output file. The CodeWarrior IDE controls the linker through the use of linker command files. There is no need to specify a list of object files. The Project Manager tracks all the object files automatically. You can also use the Project Manager to specify link order. The Target>M56800 Target settings panel lets you set the name of the final output file.
Debugging
To debug a project, select Project > Debug from the menu bar of the Freescale CodeWarrior window.
36
4
Tutorial
This chapter gives you a quick start at learning how to use the CodeWarrior Development Studio for Freescale DSC56800/E for the DSP56F80x/DSP56F82x Controllers.
Creating a Project
You can create a DSP56800x project by using the: DSP56800x new project stationery 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 Stationery Project Wizard. To create a new project with the DSP56800x EABI stationery, please see the sub-section Creating a New Project with the DSP56800x EABI Stationery. 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 37
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial
Creating a New Project with the DSP56800x New Stationery Project Wizard
In this section of the tutorial, you work with the CodeWarrior IDE to create a project. with the DSP56800x New Stationery Project Wizard. To create a project: 1. From the menu bar of the Freescale CodeWarrior window, select File>New. The New dialog box appears. Figure 4.1 New Dialog Box
2. Select DSP56800x New Project Wizard (Figure 4.2 on page 39). 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 Target dialog box (Figure 4.2 on page 39) appears.
38
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial Figure 4.2 DSP56800x New Project Wizard Target Dialog Box
6. Select the target board and processor a. Select the family, such as Simulators, from the DSP56800x Family list. b. Select the processor, such as DSP56800_simulator, from the Processors list. 7. Click Next. The DSP56800x New Project Wizard Program Choice dialog box (Figure 4.3 on page 40) appears.
39
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial Figure 4.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 () appears.
40
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial Figure 4.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 Stationery Wizard, please see DSP56800x New Project Wizard..
41
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial 1. Launch the CodeWarrior IDE. The Freescale CodeWarrior window appears with a menu bar at the top. To create a new project from project stationery: 1. From the menu bar of the Freescale CodeWarrior window, select File > New. The New window appears with a list of options in the Project tab (Figure 4.5 on page 42). Figure 4.5 New Window
2. Select DSP56800x EABI Stationery in the Project tab. NOTE To create a new project without using stationery, select Empty Project in the New window. This option lets you create a project from scratch. If you are a beginner, you should not try to use an Empty Project as it will not have any of the necessary target settings, startup files, or libraries included that are specific to the DSP56800 that allow you to quickly get up and running. This is why we include the DSP56800x_EABI Stationery, as it takes care of these tasks and minimizes the startup effort that is required.
42
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial 3. Type a name in the Project name field (in this tutorial use sample as the name). The CodeWarrior IDE adds the .mcp extension automatically to your file when the project is saved. The .mcp extension allows any user to recognize the file as a Freescale CodeWarrior project file. In this tutorial, the file name is sample.mcp. 4. Set the location for the project. If you want to change the default location, perform the following steps: a. In the New window, click the Set button. The Create New Project dialog box (Figure 4.6 on page 43) appears: Figure 4.6 Create New Project Dialog Box
b. Use the standard navigation controls in the Create New Project dialog box to specify the path where you want the project file to be saved. c. Click the Save button. The CodeWarrior IDE closes the Create New Project dialog box. If you want to use the default location for your project, go to step 5. In either case, the CodeWarrior IDE creates a folder with the same name as your project in the directory you select.
43
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial
NOTE
Enable the Create Folder checkbox in the Create New Project file dialog box to create a new folder for your project in the selected location.
5. Click OK in the New window. The New Project window appears (Figure 4.7 on page 44) with a list of boardspecific project stationeries. Figure 4.7 New Project Window
6. Select DSP56F80x as the Project Stationery for your target. Click the hierarchical control for the Project Stationery to expand the hierarchical view. Then, select DSP56F805 and select Simple_C language from the hierarchical tree. 7. Click OK in the New Project window. A project window appears (Figure 4.8 on page 45). This window displays all the files and libraries that are part of the project stationery.
44
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial Figure 4.8 CodeWarrior Project Window
Target Settings
Run
Project Inspector
The project window is the central location from which you control development. You can use this window to: Add or remove source files Add libraries of code Compile code Generate debugging information and much more Confirm that the Files tab is selected in the project window (it should be selected by default). Click the hierarchical controls next to code and support to expand and view their contents (Figure 4.9 on page 46).
45
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial Figure 4.9 CodeWarrior Project Window with Expanded Hierarchical Folders
8. View a Source File a. Double-click the main.c file in the project window, the source code in the file is displayed in a CodeWarrior source-code editor window (Figure 4.10 on page 47). NOTE For more details about the CodeWarrior editor and its features, see the IDE Users Guide.
46
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial Figure 4.10 CodeWarrior Editor Window
9. Examine the build target settings. The CodeWarrior IDE allows your project to have several different configurations contained within the project. These are called build targets. When you work with a new CodeWarrior project, you will want to examine your build target settings. a. To specify a build target, double-click the Settings icon in the Project window (see Figure 4.8 on page 45 for location of icons in the Project window). The Target Settings window {external RAM (mode 3) Settings in sample} appears (Figure 4.11 on page 48). This window contains several different panels. In Figure 4.11 on page 48, the Target Settings Panels is displayed in the Target Settings window.
47
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial Figure 4.11 Target Settings Window
b. If it is not already visible, click Target from the tree structure in the Target Settings Panels pane to expand the hierarchical view. c. Click Target Settings from the hierarchical tree. The Target Settings panel appears which displays all the options related to selecting a build target. NOTE By selecting M56800 Linker from the Linker list box, the CodeWarrior IDE recognizes that the code you are writing is intended for DSP56800 processors, and populates the Target Settings Panel with the DSP56800 specific panels.
The Target Settings window is the location for all options related to the build target. Every panel and option is explained in the CodeWarrior documentation. Most of the general settings panels are explained in the IDE User Guide. DSP56800 targetspecific panels are explained in this targeting manual. 10. Set build target options: a. In the Target Settings Panels panel, click Target in the tree structure to expand the hierarchical view. b. Click M56800 Target from the hierarchical tree. The M56800 Target panel appears (Figure 4.12 on page 49).
48
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial Figure 4.12 M56800 Target Settings Panel
11. Set linker options. a. In the Target Settings Panels pane, click Linker in the tree structure to expand the hierarchical view. b. Click M56800 Linker from the hierarchical tree. The M56800 Linker panel appears (Figure 4.13 on page 50).
49
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial Figure 4.13 M56800 Linker Settings
12. Examine the default settings and select the options according to your requirements. Close the Target window when you are finished by clicking the OK button. 13. Verify debugging information is generated. For the debugger to work, it needs certain information from the CodeWarrior IDE so that it can connect object code to source code. You must instruct the CodeWarrior IDE to produce this information. There is a debug-related column in the project window (Figure 4.14 on page 51). Every file, for which the IDE generates debugging information, has a dot in the Debug column. To enable symbolic information for a file, click the Debug column next to the file. A dot appears confirming that debugging information is generated for that file.
50
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial Figure 4.14 Turning on Debugging Per File
Debug Column
14. Compile the code using either of the following options: From the menu bar of the Freescale CodeWarrior window, select Project > Make. In the project window, click the Make icon. The above step updates all files that need to be compiled and re-linked in the project. The IDE tracks these dependencies automatically. NOTE The Make command in the menu bar of the Freescale CodeWarrior window compiles selected files, not all changed files. The Bring Up To Date command in the menu bar compiles all changed files, but does not link the project into an executable.
When you select the Make command, the IDE compiles all of the code. This may take some time as the IDE locates the files, opens them, and generates the object code. When the compiler completes the task, the linker creates an executable from the objects. You can see the compilers progress in the project window and in the toolbar.
51
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial
1. Access the Target Settings window (Figure 4.12 on page 49). 2. Set debugger options. a. In the Target Settings Panels pane, click Debugger in the tree structure to expand the hierarchical view.
52
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial b. Click M56800 Target Settings from the hierarchical tree The M56800 Target Settings panel appears (Figure 4.15 on page 53). Figure 4.15 Selecting Debugger Settings
3. Set protocol specific options: Always reset on download Select this option to reset the board every time you download code to the board. If unchecked, the board is reset only before the initial download. NOTE This option is not displayed if you select Simulator from the Protocol menu.
Breakpoint Mode From the pull-down menu, select Software. Initialize OMR for Program Memory Enable OMR For Program Memory checkbox and select External memory. 4. Debug the project by using either of the following options: From the Freescale CodeWarrior window, select Project > Debug. Click the Debug button in the project window. This command instructs the IDE to compile and link the project. An ELF file is created in the process. ELF is the file format created by the CodeWarrior linker for 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 53
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial DSP56800. The ELF file contains the information required by the debugger and prepared by the IDE. When you debug the project on DSP hardware, the debugger displays the following message: Resetting hardware. Please wait. This reset step occurs automatically only once per debugging session. To reset the boards manually, press the Reset button on your board. Next, the debugger displays this message: Download external_memory.elf When the download to the board is complete, the IDE displays the Program window (external_memory .elf in sample) shown in Figure 4.16 on page 55. NOTE Source code is shown only for files that are in the project folder or that have been added to the project in the project manager, and for which the IDE has created debug information. You must navigate the file system in order to locate sources that are outside the project folder and not in the project manager, such as library source files.
54
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial Figure 4.16 Program Window
Kill Break Run Step Over Step Into Step Out
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 panel displays source or assembly code. The toolbar at the top of the Program window has buttons that allows you access to the execution commands in the Debug menu. 6. Set breakpoints.
55
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial a. Scroll through the code in the Source pane of the Program window until you come across the main() function.
b. 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 4.17 on page 56), confirming you have set your breakpoint. Figure 4.17 Breakpoint in the Program Window
Breakpoint Setting
NOTE
To remove the breakpoint, click the red dot. The red dot disappears.
7. View and edit register values. 8. Registers are platform-specific. Different chip architectures have different registers. a. From the menu bar of the Freescale CodeWarrior window, select View > Registers. Expand the General Purpose Registers tree control to view the registers as in Figure 4.18 on page 57, or double-click on General Purpose Registers to view the registers as in Figure 4.19 on page 58.
56
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial Figure 4.18 General Purpose Registers for DSP56800
57
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial Figure 4.19 General Purpose Registers Window
b. To edit values in the register window, double-click a register value. Change the value as you wish. 9. View Data X:Memory. All variables reside at a specific memory address determined at runtime. a. To view the memory address range of a variable, select Data > View Memory from the menu bar of the Freescale CodeWarrior window. TIP If Data > View Memory is greyed out, make sure that you have the
Program window as the highlighted window and that you either have the cursor in the Source pane or have a function selected in the Stack pane.
The Memory window appears (Figure 4.20 on page 59).
58
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial b. Locate the Page list box at the bottom of the View Memory window. Select X Memory from the Page list box. Figure 4.20 View X:Memory Window
10. Enter the memory address in the Display field. Enter a hexadecimal address in standard C hex notation, for example, 0x100. The window displays the contents of X: memory. If you are using the EVM hardware, type the address, 0x2000 in the Display text field and press Enter. You see the memory starting at that location. This is the beginning of the .data section. The memory address location for .data section (or any other section) are set through a combination of the Memory Segment on page 263 and Sections Segment on page 265 of the linker command file. Note that you see both the hexadecimal and ASCII values for X: memory. The contents of this window are editable as well. 11. View Program P:Memory.
59
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial a. To view the memory address range of a variable, select Data > View Memory from the menu bar of the Freescale CodeWarrior window. TIP If Data > View Memory is greyed out, make sure that you have the
Program window as the highlighted window and that you either have the cursor in the Source pane or have a function selected in the Stack pane.
The Memory window appears (Figure 4.21 on page 60). b. Locate the Page list box at the bottom of the View Memory. Select P Memory from the Page list box. c. Using the View list box, you have the option to view four types of P:Memory: Raw Data Disassembly Source Mixed d. Enter the memory address in the Display field. Enter a hexadecimal address in standard C hex notation, for example, 0x1000. Figure 4.21 on page 60 shows Raw Data. Figure 4.21 View P:Memory Window
60
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial a. Select Project > Run. b. Click the Run icon in the toolbar of the Program window. In this simple example, the debugger will halt at a debug instruction after printing out messages to the console window. This debug instruction is the portion of the startup code which handles the programs exit. 13. Quit the application. From the menu bar of the Freescale CodeWarrior window, select Debug > Kill. This stops the code execution and quits debugging. Use either of the following options: a. Select Debug > Kill b. Click the Kill icon in the toolbar of the Program window. This will stop code execution and close the Program window if the project is running. In this case, it will simply close the Program window, as we are currently halted.
References
You have completed the tutorial and used the basic elements of the CodeWarrior Development Studio for Freescale 56800. Refer to the IDE User Guide to learn more about the features available to you.
61
Tutorial
CodeWarrior Development Studio for Freescale 56800 Tutorial
62
5
Target Settings
Each build target in a CodeWarrior project has its own settings. This chapter explains the target settings panels for DSP56800 software development. The settings that you select affect the DSP56800 compiler, linker, assembler, and debugger. This chapter contains the following sections: Target Settings Overview on page 63 CodeWarrior IDE Target Settings Panels on page 67 DSP56800-Specific Target Settings Panels on page 68
63
Target Settings
Target Settings Overview
Panel Name
Target Settings on page 68 Access Paths
Use
Selects the paths that the IDE searches to find files of your project. Types include absolute and projectrelative. Sets options for building a project, including using a third-party debugger. Associates a filename extension, such as .c, with a plug-in compiler. Defines project -specific source trees (root paths) for your project.
Build Extras
File Mappings
Source Trees
M56800 Target on page 70 Language Settings C/C++ Language (C only) on page 72 C/C++ Preprocessor on page 75 C/C++ Warnings on page 77 M56800 Assembler on page 82 Code Generation ELF Disassembler on page 83 M56800 Processor on page 86 Global Optimization Configures how the compiler optimizes code.
Linker
64
Target Settings
Target Settings Overview Table 5.1 Target Setting Panels (continued) Group
Editor
Panel Name
Custom Keywords
Use
Changes colors for different types of text. Specifies settings for the CodeWarrior debugger.
Debugger
Debugger Settings Remote Debugging on page 92 M56800 Target (Debugging) on page 94 Remote Debug Options on page 99
Target is the name of the current build target in the CodeWarrior project.
After you select this menu item, the CodeWarrior IDE displays the Target Settings window (Figure 5.1 on page 66).
65
Target Settings
Target Settings Overview Figure 5.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
CodeWarrior IDE Target Settings Panels
67
Target Settings
DSP56800-Specific Target Settings Panels
Table 5.2 Code Warrior IDE Target Settings Panels Target Settings Panels
Access Paths
Description
Use this panel to select the paths that the CodeWarrior IDE searches to find files in your project. You can add several kinds of paths including absolute and project-relative. See IDE User Guide.
Build Extras
Use this panel to set options that affect the way the CodeWarrior IDE builds a project, including the use of a third-party debugger. See IDE User Guide.
File Mappings
Use this panel to associate a file name extension, such as.c, with a plug-in compiler. See IDE User Guide.
Source Trees
Use this panel to define project-specific source trees (root paths) for use in your projects. See IDE User Guide.
Custom Keywords
Use this panel to change the colors that the CodeWarrior IDE uses for different types of text. See IDE User Guide.
Global Optimizations
Use this panel to configure how the compiler optimizes the object code. See IDE User Guide.
Debugger Settings
Target Settings
The Target Settings panel (Figure 5.2 on page 69), lets you set the name of your build target, as well as the linker and post-linker plug-ins to be used with the build target. By
68
Target Settings
DSP56800-Specific Target Settings Panels selecting a linker, you are specifying which family of processors to use. The other available panels in the Target Settings window change to reflect your choice. Because the linker choice affects the visibility of other related panels, you must first set your build target before you can specify other options, like compiler and linker settings. Figure 5.2 Target Settings Panel
Target Name
Use the Target Name field to set or change the name of a build target. When you use the Targets view in the project window, you see the name entered in the Target Name field. The name you specify here is not the name of your final output file. It is instead a name for your personal use that you assign to the build target. You specify the name of the final output file in the Output File Name field of the M56800 Target panel.
Linker
Select a linker from the items listed in the Linker menu.
69
Target Settings
DSP56800-Specific Target Settings Panels For DSP56800 projects, you must select the M56800 Linker. The selected linker defines the build targets. After you select a linker, only the panels appropriate for your build target (in this case, DSP56800) are available.
Pre-Linker
Some build targets have pre-linkers that perform additional work, such as data-format conversion, before the final executable file is built. CodeWarrior Development Studio for Freescale 56800 does not require a pre-linker, so set the Pre-Linker menu to None.
Post-Linker
Some build targets have post-linkers that perform additional work, such as data-format conversion, on the final executable file. CodeWarrior Development Studio for Freescale 56800 does not require a post-linker, so set the Post-Linker menu set to None.
Output Directory
This field shows the directory to which the IDE saves the executable file that is built from the current project. The default output directory is the same directory in which the project file is located. If you want to save the executable file to a different directory, click the Choose. To erase the contents of this field, click Clear.
M56800 Target
The M56800 Target panel (Figure 5.3 on page 71) instructs the compiler and linker about the environment in which they are working, such as available memory and stack size. This panel is only available when the current build target uses the M56800 Linker.
70
Target Settings
DSP56800-Specific Target Settings Panels Figure 5.3 M56800 Target Panel
Project Type
The Project Type menu determines the kind of project you are creating. The available project types are Application and Library. Use this menu to select the project type that reflects the kind of project you are building (Figure 5.3 on page 71).
If you wish to change an extension, you must add a file-mapping entry in the File Mappings settings panel.
71
Target Settings
DSP56800-Specific Target Settings Panels
NOTE
Always disable the following optionw, which do not apply to the DSP56800 compiler: Legacy for-scoping and Pool Strings
72
Target Settings
DSP56800-Specific Target Settings Panels
Purpose
Specifies Interprocedural Analysis (IPA): Off IPA is disabled File inlining is deferred to the end of the file processing Program Inlining is deferred until all files within the program are processed.
Comments
When the Program option is selected the Disable Deadstripping option on the linker preference panel must be enabled.
Together with the ANSI Keyword Only checkbox, specifies whether to inline functions: Dont Inline do not inline any Smart inline small functions to a depth of 2 to 4 1 to 8 Always inline functions to the numbers depth Always inline inline all functions, regardless of depth
If you call an inline function, the compiler inserts the function code, instead of issuing calling instructions. Inline functions execute faster, as there is no call. But overall code may be larger if function code is repeated in several places.
Auto-Inline checkbox
Checked Compiler selects the functions to inline Clear Compiler does not select functions for inlining
To check whether automatic inlining is in effect, use the __option(auto_inline) command. To check whether bottom-up inlining is in effect, use the __option(inline_bottom_up) command.
Checked For a chain of function calls, the compiler begins inlining with the last function. Clear Compiler does not do bottom-up inlining.
73
Target Settings
DSP56800-Specific Target Settings Panels Table 5.3 C/C++ Language (C Only) Panel Elements (continued) Element
ANSI Strict checkbox
Purpose
Checked Disables CodeWarrior compiler extensions to C Clear Permits CodeWarrior compiler extensions to C
Comments
Extensions are C++-style comments, unnamed arguments in function definitions, # not and argument in macros, identifier after #endif, typecasted pointers as lvalues, converting pointers to same-size types, arrays of zero length in structures, and the D constant suffix. To check whether ANSI strictness is in effect, use the __option(ANSI_strict) command.
Checked Does not permit additional keywords of CodeWarrior C. Clear Does permit additional keywords.
Additional keywords are asm (use the compiler built-in assembler) and inline (lets you declare a C function to be inline). To check whether this keyword restriction is in effect, use the __option(only_std_keywords) command.
Checked C Compiler ignores trigraph characters. Clear C Compiler does not allow trigraph characters, per strict ANSI/ ISO standards.
Many common character constants resemble trigraph sequences, especially on the Mac OS. This extension lets you use these constants without including escape characters. NOTE: If this option is on, be careful about initializing strings or multi-character constants that include question marks. To check whether this option is on. use the __option(trigraphs) command.
74
Target Settings
DSP56800-Specific Target Settings Panels Table 5.3 C/C++ Language (C Only) Panel Elements (continued) Element
Require Function Prototypes checkbox
Purpose
Checked Compiler does not allow functions that do not have prototypes. Clear Compiler allows functions without prototypes.
Comments
This option helps prevent errors from calling a function before its declaration or definition. To check whether this option is in effect, use the __option(require_prototypes) command. To check whether this restriction is in effect, use the __option(enumalwasysint) command.
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.
Checked Compiler treats a char declaration as an unsigned char declaration. Clear Compiler treats char and unsigned char declarations differently.
Some libraries were compiled without this option. Selecting this option may make your code incompatible with such libraries. To check whether this option is in effect, use the __option(unsigned_char) command. If you select this option, changing one of the strings affects them all.
Checked Compiler stores only one copy of identical string literals, saving memory space. Clear Compiler stores each string literal.
C/C++ Preprocessor
The C/C++ Preprocessor (Figure 5.5 on page 76) panel controls how the preprocessor interprets source code. By modifying the settings on this panel, you can control how the preprocessor translates source code into preprocessed code. More specifically, the C/C++ Preprocessor panel provides an editable text field that can be used to #define macros, set #pragmas, or #include prefix files.
75
Target Settings
DSP56800-Specific Target Settings Panels Figure 5.5 The C/C++ Preprocessor Panel
Table 5.4 on page 76 provides information about the options in this panel. Table 5.4 C/C++ Language Preprocessor Elements Element
Source encoding
Purpose
Allows you to specify the default encoding of source files. Multibyte and Unicode source text is supported.
Comments
To replicate the obsolete option Multi-Byte Aware, set this option to System or Autodetect. Additionally, options that affect the "preprocessing" request appear in this panel. This option defaults to off to correspond with previous versions of the compiler that ignore the prefix file when building precompiled headers. If any #pragmas are imported from old C/C++ Language (C Only) Panel settings, this option is set to on.
Controls whether a *.pch or *.pch++ file incorporates the prefix text into itself.
76
Target Settings
DSP56800-Specific Target Settings Panels Table 5.4 C/C++ Language Preprocessor Elements (continued) Element
Emit file changes
Purpose
Controls whether notification of file changes (or #line changes) appear in the output. Controls whether #pragmas encountered in the source text appear in the preprocessor output. Controls whether file changes show the full path or the base filename of the file. Controls whether comments are emitted in the output. Controls whether file changes appear in comments (as before) or in #line directives. Controls whether whitespace is stripped out or copied into the output.
Comments
Emit #pragmas
This option is essential for producing reproducible test cases for bug reports.
Keep whitespace
This is useful for keeping the starting column aligned with the original source, though we attempt to preserve space within the line. This doesnt apply when macros are expanded.
C/C++ Warnings
Use the C/C++ Warnings panel (Figure 5.6 on page 78) to specify C language features for the DSP56800. Table 5.5 on page 79 explains the elements of this panel. NOTE The CodeWarrior compiler for DSP56800 does not support C++.
77
Target Settings
DSP56800-Specific Target Settings Panels Figure 5.6 C/C++ Warnings Panel
78
Target Settings
DSP56800-Specific Target Settings Panels
Purpose
Checked Compiler issues warnings about invalid pragma statements. Clear Compiler does not issue such warnings.
Comments
According to this option, the invalid statement #pragma near_data off would prompt the compiler response WARNING: near data is not a pragma. To check whether this option is in effect, use the __option(warn_illpragma) command.
Checked Compiler checks for common typing mistakes, such as == for =. Clear Compiler does not perform such checks.
If this option is in effect, any of these conditions triggers a warning: an assignment in a logical expression; an assignment in a while, if, or for expression; an equal comparison in a statement that contains a single expression; a semicolon immediately after a while, if, or for statement. To check whether this option is in effect, use the __option(warn_possunwant) command.
Checked Compiler issues warnings in response to specific syntax problems. Clear Compiler does not perform such checks.
Syntax problems are: a nonvoid 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. To check whether this option is in effect, use the __option(extended_errorcheck ) command.
Leave clear.
79
Target Settings
DSP56800-Specific Target Settings Panels Table 5.5 C/C++ Warnings Panel Elements (continued) Element
Implicit Arithmetic Conversions checkbox
Purpose
Checked Compiler verifies that operation destinations are large enough to hold all possible results. Clear Compiler does not perform such checks.
Comments
If this option is in effect, the compiler would issue a warning in response to assigning a long value to a char variable. To check whether this option is in effect, use the __option(warn_implicitconv) command. See #pragma warn_any_ptr_int_conv and #pragma warn_ptr_int_conv.
Checked Compiler checks for pointer/integral conversions. Clear Compiler does not perform such checks. Checked Compiler checks for declared, but unused, variables. Clear Compiler does not perform such checks.
The pragma unused overrides this option. To check whether this option is in effect, use the __option(warn_unusedvar) command. The pragma unused overrides this option. Another way to override this option is clearing the ANSI Strict checkbox of the C/C++ Language (C Only) panel, then not assigning a name to the unused argument. To check whether this option is in effect, use the __option(warn_unusedarg) command.
Checked Compiler checks for declared, but unused, arguments. Clear Compiler does not perform such checks.
Checked Compiler checks for missing return statements. Clear Compiler does not perform such checks.
80
Target Settings
DSP56800-Specific Target Settings Panels Table 5.5 C/C++ Warnings Panel Elements (continued) Element
Expression Has No Side Effect
Purpose
Checked Compiler issues warning if expression has no side effect. Clear Compiler does not perform such checks.
Comments
See #pragma warn_no_side_effect.
Checked Compiler checks for extra commas in enums. Clear Compiler does not perform such checks. Leave clear.
To check whether this option is in effect, use the __option(warn_extracomma) command. Does not apply to C.
Inconsistent Use of class and struct Keywords checkbox Empty Declarations checkbox
Checked Compiler issues warnings about declarations without variable names. Clear Compiler does not issue such warnings.
According to this option, the incomplete declaration int ; would prompt the compiler response WARNING. To check whether this option is in effect, use the __option(warn_emptydecl) command. See #pragma warn_filenamecaps.
Checked Compiler issues warning about include file capitialization. Clear Compiler does not perform such checks.
Checked Compiler checks for pad bytes added. Clear Compiler does not perform such checks.
Checked Compiler checks for undefined macro in #if. Clear Compiler does not perform such checks.
81
Target Settings
DSP56800-Specific Target Settings Panels Table 5.5 C/C++ Warnings Panel Elements (continued) Element
Non-Inlined Functions checkbox
Purpose
Checked Compiler issues a warning if unable to inline a function. Clear Compiler does not issue such warnings. Checked System displays warnings as error messages. Clear System keeps warnings and error messages distinct.
Comments
To check whether this option is in effect, use the __option(warn_notinlined) command.
M56800 Assembler
The M56800 Assembler panel (Figure 5.7 on page 82) determines the format used for the assembly source files and the code generated by the DSP56800 assembler. Figure 5.7 M56800 Assembler Settings Panel
82
Target Settings
DSP56800-Specific Target Settings Panels
Prefix File
The Prefix File field contains the name of a file to be included automatically at the beginning of every assembly file in the project. This field lets you include common definitions without using an include directive in every file.
ELF Disassembler
The ELF Disassembler panel (Figure 5.8 on page 84) appears when you disassemble object files. To view the disassembly of a module, select Project > Disassemble.
83
Target Settings
DSP56800-Specific Target Settings Panels Figure 5.8 ELF Disassembler Panel
The ELF Disassembler panel options are: Show Headers The Show Headers option determines whether the assembled file lists any ELF header information in the disassembled output. Show Symbol and String Tables The Show Symbol and String Tables option determines whether the disassembler lists the symbol and string table for the disassembled module. Verbose Info The Verbose Info option instructs the disassembler to show additional information in the ELF file. For the .symtab section, some of the descriptive constants are shown with their numeric equivalents. The sections .line and .debug are shown with an unstructured hex dump. Show Relocations The Show Relocations option shows relocation information for the corresponding text (.rela.text) or data (.rela.data) section. Show Code Modules
84
Target Settings
DSP56800-Specific Target Settings Panels The Show Code Modules option determines whether the disassembler outputs the ELF code sections for the disassembled module. If enabled, the Use Extended Mnemonics, Show Source Code, Show Addresses and Object Code, and Show Comments options become available. Use Extended Mnemonics The Use Extended Mnemonics option determines whether the disassembler lists the extended mnemonics for each instruction of the disassembled module. This option is available only if the Show Code Modules option is enabled. Show Addresses and Object Code The Show Addresses and Object Code option determines whether the disassembler lists the address and object code for the disassembled module. This option is available only if the Show Code Modules option is enabled. Show Source Code The Show Source Code option determines whether the disassembler lists the source code for the current module. Source code is displayed in mixed mode with line number information from the original C source. This option is available only if the Show Code Modules option is enabled. Show Comments The Show Comments option displays comments produced by the disassembler, in sections where comment columns are provided. This option is available only if the Show Code Modules option is enabled. Show Data Modules The Show Data Modules option determines whether or not the disassembler outputs any ELF data sections (such as .data and .bss) for the disassembled module. Disassemble Exception Tables The Disassemble Exception Tables option determines whether or not the disassembler outputs any C++ exception tables for the disassembled module. This option is available when you select Show Data Modules. NOTE
85
Target Settings
DSP56800-Specific Target Settings Panels The Show Debug Info option directs the disassembler to include DWARF symbol information in the disassembled output.
M56800 Processor
The M56800 Processor settings panel (Figure 5.9 on page 86) determines the kind of code the compiler creates. This panel is available only when the current build target uses the M56800 Linker. Figure 5.9 M56800 Processor Settings Panel
Peephole Optimization
This option controls the use of peephole optimizations. The peephole optimizations are small local optimizations that eliminate some compare instructions and optimize some address register updates for more efficient sequences.
86
Target Settings
DSP56800-Specific Target Settings Panels
Instruction Scheduling
This option determines whether the compiler rearranges instructions to take advantage of the M56800s scheduling architecture. This option results in faster execution speed, but is often difficult to debug. NOTE Instruction Scheduling can make source-level debugging difficult because the source code might not correspond exactly to the underlying instructions. Disable this option when debugging code.
Allow DO Instructions
This option controls the compilers support for the DO instruction. Since the compiler never nests DO instructions, interrupt routines are always free to use those instructions.
87
Target Settings
DSP56800-Specific Target Settings Panels
M56800 Linker
The M56800 Linker panel (Figure 5.10 on page 88) controls the behavior of the linker. This panel is only available if the current build target uses the M56800 Linker. Figure 5.10 M56800 Linker Settings Panel
The M56800 Linker panel options are: Generate Symbolic Info The Generate Symbolic Info option controls whether the linker generates debugging information. If the option is enabled, the linker generates debugging
88
Target Settings
DSP56800-Specific Target Settings Panels information. This information is included within the linked ELF file. This setting does not generate a separate file. If you select Project > Debug, the CodeWarrior IDE enables the Generate
Store Full Path Names The Store Full Path Names option controls how the linker includes path information for source files when generating debugging information. If this option is enabled, the linker includes full path names to the source files. If this option is disabled, the linker uses only the file names. By default, this option is enabled. This option is available only if you enable the Generate Symbolic Info on page 88 option. Generate Link Map The Generate Link Map option controls whether the linker generates a link map. Enable this option to let the linker generate a link map. The file name for the link map adds the extension .xMAP to the generated file name. The linker places the link map in the same folder as the output .elf file. For each object and function in the output file, the link map shows which file provided the definition. The link map also shows the address given to each object and function, a memory map of where each section resides in memory, and the value of each linker-generated symbol. Although the linker aggressively strips unused code and data when the CodeWarrior IDE compiles the relocatable file, it never deadstrips assembler relocatable files or relocatable files built with other compilers. If a relocatable file was not built with the CodeWarrior C compiler, the link map lists all of the unused but unstripped symbols. List Unused Objects The List Unused Objects option controls whether the linker includes unused objects in the link map. Enable the option to let the linker include unused objects in the link map. The linker does not link unused code in the program. Usually, this option is disabled. However, you might want to enable it in certain cases. For example, you might discover that an object you expect to be used is not
89
Target Settings
DSP56800-Specific Target Settings Panels actually used. This option is not available unless you enable the Generate
90
Target Settings
DSP56800-Specific Target Settings Panels The Generate ELF Symbol Table option instructs the linker to generate an ELF symbol table, as well as a list of relocations in the ELF executable file. Suppress Warning Messages The Suppress Warning Messages option controls whether the linker displays warnings. If this option is disabled, the linker displays warnings in the Message window. If this option is disabled, the linker does not display warnings. Generate S-Record File The Generate S-Record File option controls whether the linker generates an S-record file based on the application object image. The S-record files have the extension .s. In the case of the DSP56800, the linker generates three different S-record files. Their contents are: {output file name}.S S-record file containing both P and X memory contents. {output file name}.p.S S-record file containing P memory contents only. {output file name}.x.S S-record file containing X memory contents only. The linker places the S-record files in the output folder, which is a sub-folder of the project folder. The linker generates the following S3 type S-records: Sort by Address This option enables the compiler to sort S-records generated by the linker using byte address. This option is not available unless you enable the Generate SRecord File on page 91 option. Generate Byte Addresses This option enables the linker to generate S-records in bytes. This option is not available unless you enable the Generate S-Record File on page 91 option. Max Record Length The Max Record Length field specifies the maximum length of the S-record generated by the linker. This field is available only if the Generate S-Record File on page 91 option is enabled. The maximum value for an S-record length is 256 bytes. NOTE Most programs that load applications onto embedded systems have a maximum length for S-records. The CodeWarrior debugger can handle S-records as large
91
Target Settings
DSP56800-Specific Target Settings Panels as 256 bytes. If you are using something other than the CodeWarrior debugger to load your embedded application, you need to determine its maximum length. EOL Character The EOL Character list box defines the end-of-line character for the S-record file. This list box is available only if you enable the Generate S-Record File on page 91 option. Entry Point The starting point for a program is set in the Entry Point field in the M56800 settings panel. The Entry Point field specifies the function that the linker first uses when the program runs. The default function found in this field is located within the startup code that sets up the DSP56800 environment before your code executes. This function and its corresponding startup code will be different depending upon which stationery you have selected. In the case of hardware targeted stationery, the startup code can be found in the stationery-generated projects startup folder. The startup code performs other tasks, such as clearing the hardware stack, creating an interrupt table, and getting the stack start and exception handler addresses. The final task performed by the startup code is to call your main() function. Force Active Symbols The Force Active Symbols field instructs the linker to include symbols in the link even if the symbols are not referenced. In essence, it is a way to make symbols immune to deadstripping. When listing multiple symbols, use a single space between them as a separator.
Remote Debugging
Use the Remote Debugging panel (Figure 5.11 on page 93, Figure 5.12 on page 93) to set parameters for communication between a DSP56800 board or Simulator and the CodeWarrior DSP56800 debugger. Table 5.6 on page 94 explains the elements of this panel. NOTE Communications specifications also involve settings of the debugging M56800 Target panel (Figure 5.13 on page 95).
92
Target Settings
DSP56800-Specific Target Settings Panels Figure 5.11 Remote Debugging Panel (56800 Simulator)
93
Target Settings
DSP56800-Specific Target Settings Panels
Purpose
Specifies the connection type: 56800 Simulator appropriate for testing code on the simulator before downloading code to an actual board. 56800 Local Hardware Connection (CSS) appropriate for using your computers command converter server, connected to a DSP56800 board.
Comments
Selecting 56800 Simulator keeps the panel as Figure 5.11 on page 93 shows. Selecting 56800 Local Hardware Connection adds the JTAG Clock Speed text box to the panel, as Figure 5.12 on page 93 shows.
Remote Download Path text box Launch Remote Host Application checkbox Multi-Core Debugging Allows debugging of multiple boards on a complex scan chain.
For more details, see Debugging on a Complex Scan Chain on page 245 This list box is available only if the Connection list box specifies 56800 Local Hardware Connection (CSS). The HTI will not work properly with a clock speed over 800 kHz.
Specifies the JTAG lock speed for local hardware connection. (Default is 600 kilohertz.)
94
Target Settings
DSP56800-Specific Target Settings Panels Figure 5.13 M56800 Target Settings Panel
95
Target Settings
DSP56800-Specific Target Settings Panels
Purpose
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.
Comments
Checked When
the
option is enabled, you can specify the use of a flash configuration file (Listing 5.3 on page 98) in the text box .
Clear Debugger assumes no flash on the target. Breakpoint Mode checkbox Specifies the breakpoint mode: Automatic CodeWarrior software determines when to use software or hardware breakpoints. Software CodeWarrior software always uses software breakpoints. Hardware CodeWarrior software always uses the available hardware breakpoints.
If the full path and file name are not specified, the default location is the same as the project file. You can click the Choose button to specify the file. The
Choose File
dialog box appears (Figure 5.14 on page 97).
Software breakpoints contain debug instructions that the debugger writes into your code. You cannot set such breakpoints in flash, as it is readonly. Hardware breakpoints use the onchip debugging capabilities of the DSP56800. The number of available hardware breakpoints limits these capabilities. Note, Breakpoint Mode only effects HW targets.
96
Target Settings
DSP56800-Specific Target Settings Panels Table 5.7 Debugging M56800 Target Panel Elements (continued) Element
Auto-clear previous hardware breakpoint
Purpose
Checked Automatically clears the previous harware breakpoint. Clear Does not Automatically clears the previous harware breakpoint. Checked Choose the program memory mode (external or internal) at connect. Clear OMR is unchanged.
Comments
97
Target Settings
DSP56800-Specific Target Settings Panels Listing 5.3 Flash Configuration File Line Format baseAddr startAddr endAddr TME Tnvs Tpgs Tprog Tnvh progMem regBaseAddr Tnvh1 Trcv Terase
Each text line of the configuration file specifies a flash unit on the target. The prototype is shown in Listing 5.3 on page 98 and its arguments are shown in Table 5.8 on page 98. Table 5.8 Flash Configuration File Line Format Argument
baseAddr startAddr endAddr progMem regBaseAddr
Description
address where row 0 (zero) starts first flash memory address last flash memory address 0 = data (X:), 1 = program memory (P:) location in data memory map where the control registers are mapped erase time mass erase time PROG/ERASE to NVSTR set up time NVSTR to program set up time program time NVSTR hold time NVSTR hold time(mass erase) recovery time
A sample flash configuration file for DSP56F803 and DSP56F805 is in Table 5.9 on page 98. Do not change the contents of this file. Table 5.9 Sample Flash Configuration File for DSP56F803/5
0 0x0 004 0x7 dff 1 0x0 f40 0x0 002 0x0 006 0x0 01A 0x0 033 0x0 066 0x0 01A 0x0 19A 0x0 006
98
Target Settings
DSP56800-Specific Target Settings Panels Table 5.9 Sample Flash Configuration File for DSP56F803/5 (continued)
0 0x8 000 0 0x1 000 0x8 7ff 0x1 fff 1 0x0 f80 0 0x0 f60 0x0 002 0x0 002 0x0 006 0x0 006 0x0 01A 0x0 01A 0x0 033 0x0 033 0x0 066 0x0 066 0x0 01A 0x0 01A 0x0 19A 0x0 19A 0x0 006 0x0 006
NOTE
You cannot use Flash ROM with the board set in development mode. Ensure the Debugger sets OMR on launch is not enabled if you are using this feature.
99
Target Settings
DSP56800-Specific Target Settings Panels
Purpose
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).
Comments
Section types: Executable programcode sections that have X flags in the linker command file. Constant Data programdata sections that do not have X or W flags in the linker command file. Initialized Data program-data sections with initial values. These sections have W flags, but not X flags, in the linker command file. Uninitialized Data program-data sections without initial values. These sections have W flags, but not X flags, in the linker command file.
100
6
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. This chapter contains these sections: Processor Expert Overview on page 101 Processor Expert Windows on page 109 Processor Expert Tutorial on page 122
101
When you start code design, the PEI generates commented code from the bean settings. This code generation takes advantage of the Processor Expert CPU knowledge system and solution bank, which consists of hand-written, tested code optimized for efficiency. To add new functionalities, you select and configure additional beans, then restart code design. Another straightforward expansion of PEI code is combining other code that you already had produced with different tools.
103
The bean selectors tree structures list all available beans; double-clicking the name adds the bean to your project. Clicking the Quick Help button opens or closes an explanation pane that describes the highlighted bean. Once you determine the appropriate beans, you use the Bean Inspector (Figure 6.3 on page 105) to fine tune each bean, making it optimal for your application.
104
Using the Bean Inspector to set a beans initialization properties automatically adds bean initialization code to CPU initialization code. You use the Bean Inspector to adjust bean properties, so that generated code is optimal for your application. Beans greatly facilitate management of on-chip peripherals. When you choose a peripheral from bean properties, the PEI presents all possible candidates. But the PEI indicates which candidates already are allocated, and which are not compatible with current bean settings.
105
Subitem
none
Action
Opens the PEI for the current project. (Available only if the current project does not already involve the PEI.)
none
Generates code, including drivers, for the current project. Access these files via the Generate Code folder, of the projectwindow Files page. Deletes the most recently-generated code, returning project files to their state after the previous, error-free code generation. Brings the Processor Expert page to the front of the CodeWarrior project window. (Not available if the project window does not include a Processor Expert page.)
none
View
Project Panel
Bean Inspector
Opens the Bean Inspector window, which gives you access to bean properties. Opens the Beans Selector window, which you use to choose the most appropriate beans. Opens the Target CPU Package window, which depicts the processor. As you move your cursor over the pins of this picture, text boxes show pin numbers and signal names. Opens the Target CPU Package window, but portrays the processor as a large block diagram. Scroll bars let you view any part of the diagram. As you move your cursor over modules, floating text boxes identify pin numbers and signals. Opens the Error Window, which shows hints, warnings, and error messages.
Bean Selector
Error Window
106
Action
Opens the Resource Meter window, which shows usage and availability of processor resources. Opens the CPU Structure window, which uses an expandible tree structure to portray the processor. Opens the Peripherals Usage Inspector window, which shows which bean allocates each peripheral. Opens the Peripherals Initialization Inspector window, which show the initialization value and value after reset for all peripheral register bits. Opens the Beans Overview window, which provides information about all beans in your project. Opens the CPU Overview window, which lists supported processors in an expandable tree structure. Opens the CPU Parameters window, which lists clock-speed ranges, number of pins, number of timers, and other reference information for the supported processors. Opens the Memory Map window, which depicts CPU address space, internal memory, and external memory. Starts the specified compiler, linker or other tool. (You use the Tools Setup window to add tool names to this menu.) Opens a command-line window. Opens the Tools Setup window, which you use to add tools to this menu. Opens the help start page.
View (continued)
Memory Map
Tools
<tool name>
Help
107
Action
Opens the PEI help introduction. Opens an explanation of PEI benefits. Opens an explanation of the PEI environment. [None available for the DSP56800/E.] Opens PEI quick start instructions. Opens the first page of a description database of all beans. Opens the first page of a description database of beans, organized by category. Opens the list of processors and tools that the PEI plug-in supports.
Supported CPUs, Compilers, and Debuggers PESL Library User Manual User Guide
Opens the Processor Expert System Library, for advanced developers. Opens a .pdf guide that focuses on the DSP56800/E processor family. Opens documentation of the target processor, in a .pdf search window.
Search in PDF Documentation of the Target CPU Go to Processor Expert Home Page About Processor Expert Update Update Processor Exert Beans from Package
Opens your default browser, taking you to the PEI home page. Opens a standard About dialog box for the PEI. Opens the Open Update Package window. You can use this file-selection window to add updated or new beans (which you downloaded over the web) to your project.
108
Action
Checks for updates available over the web. If any are available, opens your default browser, so that you can download them. Moves PEI windows to the front of your monitor screen. Restores the default arrangement of all open PEI windows.
none
none
Bean Selector
The Bean Selector window (Figure 6.4 on page 109) 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 6.4 Bean Selector Window
The Bean Categories page, at the left side of this window, lists the available beans in category order, in an expandable tree structure. Green string bean symbols identify beans
109
Bean Inspector
The Bean Inspector window (Figure 6.5 on page 111) lets you modify bean properties and other settings. To open this window, select Processor Expert > View > Bean Inspector, from the main-window menu bar.
110
This window shows information about the currently selected bean that is, the highlighted bean name in the project-window Processor Expert page. The title of the Bean Inspector window includes the bean name. The Bean Inspector consists of Properties, Methods, Events, and Comment pages. The first three pages have these columns: Item names Items to be set. Double-click on group names to expand or collapse this list. For the Method or Event page, double-clicking on an item may open the file editor, at the corresponding code location. Selected settings Possible settings for your application. To change any ON/OFFtype setting, click the circular-arrow button. Settings with multiple possible values have triangle symbols: click the triangle to open a context menu, then select the appropriate value. Timing settings have an ellipsis (...) button: click this button to open a setting dialog box.
111
The Basic, Advanced, and Expert view mode buttons, at the bottom of the window, let you change the detail level of Bean Inspector information. The Bean Inspector window has its own menu bar. Selections include restoring default settings, saving the selected bean as a template, changing the beans icon, disconnecting from the CPU, and several kinds of help information.
112
Arrows on pins indicate input, output, or bidirectional signals. As you move your cursor over the processor pins, text boxes at the bottom of this window show the pin numbers and signal names. Use the control buttons at the left edge of this window to modify the depiction of the processor. One button, for example, changes the picture view the CPU package with peripherals. However, as Figure 6.7 on page 114 shows, it is not always possible for the picture of a sophisticated processor to display internal peripherals.
113
In such a case, you can click the Always show internal peripheral devices control button. Figure 6.8 on page 115 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.
114
Click the Show MCU Block Diagram to change the picture to a block diagram, as Figure 6.9 on page 116 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.)
115
Other control buttons at the left edge of the window let you: Show bean icons attached to processor pins. Rotate the CPU picture clockwise 90 degrees. Toggle default and user-defined names of pins and peripherals. Print the CPU picture. NOTE As you move your cursor over bean icons, peripherals, and modules, text boxes or floating hints show information such as names, descriptions, and the allocating beans.
And note these additional mouse control actions for the Target CPU window: Clicking a bean icon selects the bean in the project windows Processor Expert page.
116
117
The color key for memory blocks is: White Non-usable space Dark Blue I/O space Medium Blue RAM Light Blue ROM Cyan FLASH memory or EEPROM Black External memory.
118
Right-click the window to open a context menu that lets you add the selected CPU to the project, expand the tree structure, collapse the tree structure, or get help information.
119
Resource Meter
The Resource Meter window (Figure 6.12 on page 120) 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 6.12 Resource Meter Window
Bars of this window indicate: The number of pins used The number of ports used Allocation of timer compare registers The number of timer capture registers used Allocation of serial communication channels Allocation of A/D converter channels. Pausing your cursor over some fields of this window brings up details of specific resources.
120
This windows View menu lets you change the display contents, such as showing driver status and information, restricting the kinds of beans the display covers, and so on.
121
The pages of this window reflect the peripheral categories: I/O, interrupts, timers, and channels. The columns of each page list peripheral pins, signal names, and the allocating beans. Pausing your cursor over various parts of this window brings up brief descriptions of items. This windows View menu lets you expand or collapse the display.
2. Select the sdm external memory target. a. Click the project windows Targets tab. The Targets page moves to the front of the window. b. Click the target icon of the sdm external memory entry. The black arrow symbol moves to this icon, confirming your selection. 3. Add six BitIO beans to the project.
123
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.
124
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.
125
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. c. In the Pin for I/O line, click the triangle symbol of the middle-column list box. The list box opens. d. Use this list box to select GPIOC0_SCLK1_TB0_PHASEA1. (Figure 6.19 on page 127 depicts this selection.)
126
e. In the project windows Processor Expert page, select the bean name GPIO_C1. The Bean Inspector information changes accordingly. f. Use the Pin for I/O middle-column list box to select GPIOC1_MOSI1_TB1_PHASEB1. g. Repeat substeps e and f, for bean GPIO_C2, to change its associated pin to GPIOC2_MISO1_TB2_INDEX1. h. Repeat substeps e and f, for bean GPIO_C3, to change its associated pin to GPIOC3_SSA_B_TB3_HOME1. i. Repeat substeps e and f, for bean GPIO_D6, to change its associated pin to GPIOD6_TxD1. j. Repeat substeps e and f, for bean GPIO_D7, to change its associated pin to GPIOD7_RxD1. k. In the project windows Processor Expert page, select the bean name IRQA. The Bean Inspector information changes accordingly. l. Use the Pin middle-column list box to select IRQA_B. m. Repeat substeps k and l, for bean IRQB, to change its associated pin to IRQB_B. n. You may close the Bean Inspector window. 7. Enable BitIO SetDir, ClrVal, and SetVal functions.
127
c. Click the GPIO_C0 minus-sign control. The function list collapses. d. Repeat substeps a, b, and c for beans GPIO_C1, GPIO_C2, GPIO_C3, GPIO_D6, and GPIO_D7. 8. Enable ExtInt OnInterrupt, GetVal functions. a. In the Processor Expert page, click the plus-sign control for the IRQA bean. The function list expands. b. Double-click function symbols as necessary, so that only OnInterrupt and GetVal have green check symbols. c. Click the IRQA minus-sign control. The function list collapses. d. Repeat substeps a, b, and c for bean IRQB. 9. Design (generate) project code. a. From the main-window menu bar, select Processor Expert > Code Design LEDcontrol.mcp. (This selection shows the actual name of your project.) The IDE and PEI generate several new files for your project. b. You may close all windows except the project window. 10. Update file Events.c. a. Click the project windows Files tab. The Files page moves to the front of the window.
128
j. Save and close file Events.c. 11. Update file LEDcontrol.c. a. In the project windows Files page, double-click filename LEDcontrol.c (or the actual .c filename of your project). An editor window opens, displaying this files text. b. Add custom code, to utilize the beans. NOTE Listing 6.2 on page 132 shows custom entries as bold italics. Processor Expert software generated all other code of the file.
c. Save and close the file. 12. Build and debug the project. a. From the main-window menu bar, select Project > Make. The IDE compiles and links your project, generating executable code. b. Debug your project, as you would any other CodeWarrior project. 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 6.1 File Events.c /* ** ################################################################# ** ** Filename : Events.C ** ** Project : LEDcontrol
129
130
/* ** ========================================================== ** Event : IRQA_OnInterrupt (module Events) ** ** From bean : IRQA [ExtInt] ** Description : ** This event is called when the active signal edge/level ** occurs. ** Parameters : None ** Returns : Nothing ** =================================================================== */ #pragma interrupt called extern short IRQA_On; void IRQA_OnInterrupt(void) { IRQA_On ^= 1; /* place your IRQA interrupt procedure body here */
131
/* END Events */ /* ** ######################################################## ** ** This file was created by UNIS Processor Expert 03.15 for ** the Freescale DSP56x series of microcontrollers. ** ** ########################################################## */ Listing 6.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. ** ** Settings : ** ** ** Contents : ** ** No public methods ** ** ** (c) Copyright UNIS, spol. s r.o. 1997-2002 ** ** UNIS, spol. s r.o. ** Jundrovska 33
132
133
1: 2: 3: 4: 5: 6:
1: 2: 3: 4: 5: 6:
134
1: 2: 3: 4: 5: 6:
1: 2: 3: 4: 5: 6:
135
for (i=0; i<=0b111111; ++i) { showNumberWithLEDs(i); wait(100000); } } void main(void) { /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/ /*Write your code here*/ #pragma warn_possunwant off IRQA_On = IRQA_GetVal() ? 1 : 0; IRQB_On = IRQB_GetVal() ? 1 : 0; for(;;); { CLEARLEDS; pattern(); } #pragma } warn_possunwant reset
/* END LEDcontrol */ /* ** ################################################################### /* ** This file was created by UNIS Processor Expert 03.15 for ** the Freescale DSP56x series of microcontrollers. ** ** ############################################################### */
136
7
C for DSP56800
This chapter explains the CodeWarrior compiler for DSP56800. This chapter contains the following sections: General Notes on C on page 137 Number Formats on page 137 Calling Conventions, Stack Frames on page 139 User Stack Allocation on page 144 Sections Generated by the Compiler on page 149 Optimizing Code on page 151 Compiler or Linker Interactions on page 154
General Notes on C
Note the following on the DSP56800 processors: C++ language is not supported. Floating-point math functions (for example, sin, cos, and sqrt) are not supported. The sizeof function in C is not the same as the SIZEOF function in the linker. In C, the sizeof function returns a number of type SIZE_T, which the complier declares to be of type unsigned long int. The sizeof function in C returns the number of words, whereas the SIZEOF function in the linker returns the number of bytes.
Number Formats
This section explains how the CodeWarrior compilers implement integer and floatingpoint types for DSP56800 processors. Look at limits.h for more information on integer types and float.h for more information on floating-point types. Both limits.h and float.h are explained in the MSL C Reference Manual.
C for DSP56800
Number Formats
Option Setting
n/a Use Unsigned Chars is disabled in the C/C++ Language (C Only) settings panel Use Unsigned Chars is enabled
Size (bits)
16 16
Range
true or false -32,768 to 32,767
16
0 to 65,535
signed char unsigned char short unsigned short int unsigned int long
n/a n/a
16 16
n/a n/a
16 16
n/a n/a
16 16
n/a
32
unsigned long
n/a
32
Size (bits)
32 32
Range
1.17549e-38 to 3.40282e+38 1.17549e-38 to 3.40282e+38
138
C for DSP56800
Calling Conventions, Stack Frames Table 7.2 DSP56800 Floating-Point Types (continued) Type
double long double
Size (bits)
32 32
Range
1.17549e-38 to 3.40282e+38 1.17549e-38 to 3.40282e+38
Declared As
Size (bits)
16 16 32
Range
(-1.0 <= x < 1.0) (-1.0 <= x < 1.0) (-1.0 <= x < 1.0)
NOTE
For compatibility reasons, preferably use DSP intrinsics instead of fixed-point types in Table 7.3 on page 139 for fractional arithmetic.
Calling Conventions
The registers A, R2, R3, Y0, and Y1 pass parameters to functions. When a function is called, the parameter list is scanned from left to right. The parameters are passed in this way: 1. The first 32-bit value is placed in A. 2. The first two 16-bit values are placed in Y0 and Y1, respectively.
139
C for DSP56800
Calling Conventions, Stack Frames 3. The first two 16-bit addresses are placed in R2 and R3. All remaining parameters are pushed onto the stack, beginning with the rightmost parameter. Multiple-word parameters have the least significant word pushed onto the stack first. When calling a routine that returns a structure, the caller passes an address in R0 which specifies where to copy the structure. The registers A, R0, R2, and Y0 are used to return function results as follows: 32-bit values are returned in A. 16-bit addresses are returned in R2. All 16-bit non-address values are returned in Y0.
Volatile Registers
Volatile registers are registers that cannot be saved across functions calls. These registers are also called non-SOC registers. NOTE See Table 7.4 on page 140 for a list of volatile (non-SOC) and non-volatile (SOC) registers.
Register Name
Y1
Size
16
Type
Volatile (nonSOC)
Comments
Y0
16
32
140
C for DSP56800
Calling Conventions, Stack Frames Table 7.4 Volatile and Non-Volatile Registers (continued) Unit Register Name
X0
Size
16
Type
Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC)
Comments
A2
A1
16
A0
16
A10
32
36
B2
B1
16
B0
16
B10
32
36
R0
16
R1
16
R2
16
R3
16
141
C for DSP56800
Calling Conventions, Stack Frames Table 7.4 Volatile and Non-Volatile Registers (continued) Unit Register Name
N
Size
16
Type
Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC)
Comments
SP
16
M01
16
In certain registers, values must be kept for proper C execution. Set to 0xFFFF for proper execution of C code.
Program Controller
PC
21
Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) In certain registers, values must be kept for proper C execution. For example, set the CM bit. (See OMR Settings.)
LA
16
HWS
16
OMR
16
SR
16
Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC)
LC
16
Page 0
MR0
16
MR1
16
MR2
16
142
C for DSP56800
Calling Conventions, Stack Frames Table 7.4 Volatile and Non-Volatile Registers (continued) Unit Register Name
MR3
Size
16
Type
Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Volatile (nonSOC) Non-volatile (non-SOC) Non-volatile (non-SOC) Non-volatile (non-SOC) Non-volatile (non-SOC) Non-volatile (non-SOC) Non-volatile (non-SOC) Non-volatile (non-SOC) Non-volatile (non-SOC)
Comments
MR4
16
MR5
16
MR6
16
MR7
16
MR8
16
MR9
16
MR10
16
MR11
16
MR12
16
MR13
16
MR14
16
MR15
16
Stack Frame
The stack frame is generated as shown in Figure 7.1 on page 144. The stack grows upward, meaning that pushing data onto the stack increments the address in the stack pointer.
143
C for DSP56800
User Stack Allocation Figure 7.1 The Stack Frame
SP
called function stack user locals compiler locals nonvolatile registers status registers return address parameters volatile register space calling function stack
SP-size
The stack pointer register (SP) is a 16-bit register used implicitly in all PUSH and POP instructions. The software stack supports structured programming, such as parameter passing to subroutines and local variables. If you are programming in both assemblylanguage and high-level language programming, use stack techniques. Note that it is possible to support passed parameters and local variables for a subroutine at the same time within the stack frame.
144
C for DSP56800
User Stack Allocation The User Stack Allocation feature allows you to simply add inline assembly modification of the SP anywhere in the function. The restrictions are straight-forward: 1. The SP must be modified by the same amount on all paths leading to a control flow merge point. 2. The SP must be modified by a literal constant amount. That is, address modes such as (SP)+N and direct writes to SP are not handled. 3. The SP must remain properly aligned. 4. You must not overwrite the compilers 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. To prevent this from happening, the User Stack Allocation feature traverses the control flow graph, recording the inline assembly SP modifications through all program paths. It then checks all control flow merge points to make sure that the SP has been modified consistently in each branch converging on the merge point. If not, a warning is emitted citing the inconsistency. Once the compiler determined that inline SP modifications are consistent in the control flow graph, the SPs offsets used to reference local variables, function arguments, or temps are fixed up with knowledge of inline assembly modifications of the SP. Note, you may freely allocate local stack storage: 1. As long as it is equally modified along all branches leading to a control flow merge point. 2. The SP is properly aligned. The SP must be modified by an amount the compiler can determine at compile time. A single new pragma is defined. #pragma check_inline_sp_effects [on|off|reset] will generate a warning if the user specifies an inline assembly instruction which modifies the SP by a run-time dependent amount. If the pragma is not specified, then stack offsets used to access stack-based variables will be incorrect. It is the users responsibility to enable #pragma check_inline_sp_effects, if they desire to modify the SP with inline assembly and access local stack-based variables. Note this pragma has no effect in function level assembly functions or separate assembly only source files (.asm files). In general, inline assembly may be used to create arbitrary flow graphs and not all can be detected by the compiler. For example: REP #3 LEA (SP)+
145
C for DSP56800
User Stack Allocation This example would modify the SP by three, but the compiler would only see a modification of one. Other cases such as these might be created by the user using inline jumps or branches. These are dangerous constructs and are not detected by the compiler. In cases where the SP is modified by a run-time dependent amount, a warning is issued. Listing 7.1 Example 1 Legal modification of SP Using Inline Assembly #define EnterCritical() { asm(lea (SP)+);\ asm(move SR,X:(SP)+); \ asm(bfset #0x0300,SR); \ asm(nop); \ asm(nop);} #define ExitCritical() { asm(lea (SP)-;\ asm(move X:SP) ,SR); \ asm(nop);\ asm(nop);}
#pragma check_inline_sp_effects on int func() { int a=1, b=1, c; EnterCritical(); c = a+b; ExitCritical(); } This case will work because there are no control flow merge points. SP is modified consistently along all paths from the beginning to the end of the function and is properly aligned. Listing 7.2 Example 2 Illegal Modification of SP using Inline Assembly #define EnterCritical() { asm(lea (SP)+);\ asm(move SR,X:(SP)+); \ asm(bfset #0x0300,SR); \ asm(nop); \ asm(nop);} #define ExitCritical() { asm(lea (SP)-;\ asm(move X:SP) ,SR); \ asm(nop);\
146
C for DSP56800
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 { 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. M56800_main.c line 29 ExitCritical();
Listing 7.3 Example 3 Modification of SP by a Run-time Dependent Amount #define EnterCritical() { asm(move n,SP);\ asm(move SR,X:(SP)+); \ asm(nop); \ asm(nop);} #define ExitCritical() { asm(lea (SP)-;\ asm(move X:(SP) ,SR); \ asm(nop);\ asm(nop);}
#pragma check_inline_sp_effects on
147
C for DSP56800
User Stack Allocation 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 M56800_main.c line 20 EnterCritical(); This example is not legal since the SP is modified by run-time dependent amount. If all inline assembly modifications to the SP along all branches are equal approaching the exit of a function, it is not necessary to explicitly deallocate the increased stack space. The compiler cleans up the extra inline assembly stack allocation automatically at the end of the function. Listing 7.4 Example 4 Automatic Deallocation of Inline Assembly Stack Allocation #pragma check_inline_sp_effects on int func() { int a=1, b=1, c; if (a) { EnterCritical(); c = a+b; }
148
C for DSP56800
Sections Generated by the Compiler 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.
If the project has the Write constant data to .rodata section checkbox enabled in the M56800 Processor portion of the Target Settings, then the compiler will generate the .rodata section for constant data. This option is overridden by the #pragma use_rodata. NOTE The .rodata section is not handled by the default LCF. Thus, you need to add how you would like the LCF to place this section within the memory map. For more details on how to work with LCFs, see ELF Linker.
By default, zero-initialized data is put into the .bss section by the compiler. This is done to reduce the load size of the application. The load size is reduced because instead of the debugger loading a sequence of zeros into the .data section (a loadable section), the compiler simply moves the zero-initialized data to the .bss section (not a loadable 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 149
C for DSP56800
OMR Settings section) which is initialized to zero by the startup code. This behavior can be overridden by using the #pragma explicit_zero_data or by using the #pragma use_rodata, which put all constant data into a special .rodata section. Table 7.5 on page 150 shows the memory map. Table 7.5 Memory Map Section
PROGRAM DATA
Size
64K x 16 bit 64K x 16 bit
Range (Hexadecimal)
0000 - FFFF 0000 - FFFF
OMR Settings
The Operating Mode Register (OMR) is part of the program controller of the DSP56800 core. This register is responsible for the majority of how the core operates. NOTE For general details about the OMR, see the DSP56800 Family Manual. For specific register details of your chip, see your chip manual.
The CodeWarrior compiler has some requirements about the value contained within this register and the mode in which the DSP56800 core operated. These requirements are described in Table 7.6 on page 150. Table 7.6 OMR Bit Requirements Bit Number
4 5
Bit Name
Saturation or SA bit
Requirements
This bit must be cleared for the compiled code to work properly. This bit must be cleared for the compiled code to work properly. This bit must be set for the compiled code to work properly.
Rounding or R bit
NOTE
For general details about the OMR, see the DSP56800 Family Manual. For specific register details of your chip, see your chip manual.
150
C for DSP56800
Optimizing Code
Optimizing Code
Optimizations that are specific to DSP56800 development with the CodeWarrior IDE are: Page 0 Register Assignment on page 151 Array Optimizations on page 151 Multiply and Accumulate (MAC) Optimizations on page 152
Array Optimizations
Array indexing operations are optimized when optimizations are turned on in the Global Optimizations settings panel. In Listing 7.5 on page 151, the i index is optimized out and the operation performs with address registers. Listing 7.5 C Code Example for Array Optimizations void main( void ) { short a[100], b[100]; int i; // ... other code for ( i = 0; i < 100; i++ ) { ArrayA[i] = ArrayB[i]; } // ... other code } It is easier to understand the optimization process by viewing the assembler code mixed with C code, created both before (Listing 7.6 on page 152) and after (Listing 7.7 on page 152) optimizations are turned on.
151
C for DSP56800
Optimizing Code Listing 7.6 Array Example Before Optimizations - Mixed View for (i = 0;i < 100; 00001004: A7B20000 00001006: A90B { a[i] = b[i]; 00001007: 880F 00001008: DE40FF9D 0000100A: BC32 0000100B: F044 0000100C: 880F 0000100D: DE40FF39 0000100F: BC32 00001010: D044 } i++ ) moves bra
; 0x000812
The optimization level has been set to 3 (Listing 7.7 on page 152). Note that i is optimized out and the operation is now performed with address registers. This optimization is called induction. NOTE With induction, the variable "i" is no longer used.
Listing 7.7 Array Example After Optimizations - Mixed View for ( i = 0; i < 100; i++ ) 00001008: A7B20000 moves 0000100A: A905 bra { a[i] = b[i]; 0000100B: F016 move 0000100C: D017 move 0000100D: DE02 lea 0000100E: DE03 lea }
; 0x000810
152
C for DSP56800
Optimizing Code Listing 7.8 Sample Multiply and Accumulate Operation void main( void ) { __fixed__ a[100], b[100]; __fixed__ sum = 0; int i=0; for ( i = 0; i < 100; i++ ){ sum += a[i] * b[i]; } } The mixed view without optimizations is as follows: Listing 7.9 Assembly Output for Multiply and Accumulate Operation for ( i = 0; i < 100; i++ ) 00001006: A7B20000 moves 00001008: A90E bra { sum += a[i] * b[i]; 00001009: 880F move 0000100A: DE40FF39 lea 0000100C: BC32 moves 0000100D: F344 move 0000100E: 880F move 0000100F: DE40FF9D lea 00001011: BC32 moves 00001012: F144 move 00001013: B033 moves 00001014: 7C79 macr 00001015: 9033 moves }
; 0x000817
SP,R0 (R0+-199) X:0x0032,N X:(R0+N),Y1 SP,R0 (R0+-99) X:0x0032,N X:(R0+N),Y0 X:0x0033,X0 +Y1,Y0,X0 X0,X:0x0033
The optimized version with level 3 optimizations (Listing 7.10 on page 153): Listing 7.10 Assembly Output for Optimized Multiply and Accumulate Operation for ( i = 0; i < 100; i++ ) 0000100A: A7B20000 moves 0000100C: A908 bra { sum += a[i] * b[i]; 0000100D: F316 move 0000100E: F117 move
; 0x000815
C for DSP56800
Compiler or Linker Interactions 0000100F: 00001010: 00001011: 00001012: 00001013: } B033 7C79 9033 DE02 DE03 moves macr moves lea lea X:0x0033,X0 +Y1,Y0,X0 X0,X:0x0033 (R2)+ (R3)+
Link Order
The DSP56800 linker always processes C and assembly source files, as well as archive files (.a and .lib) in the order specified under the Link Order tab in the project window. This is important in the case of symbol duplication. For example, if a symbol is defined in a source-code file and a library, the linker uses the definition which appears first in the link order. If you want to change the link order, select the Link Order tab in the project window and drag your source or library file to the preferred location in the link order list. Files that appear at the top of the list are linked first.
154
8
Inline Assembly Language and Intrinsic Functions
This chapter explains the support for assembly language and intrinsic functions that is built into the CodeWarrior compiler. This chapter only covers the CodeWarrior IDE implementation of Freescale assembly language.
155
156
There are two different ways to represent statement-level assembly. In the first way, you use braces "{}" to contain the block. Within this type of block, the semicolon that separates statements is optional. In the second way, you use parentheses "()" to contain the block and the semicolon between statements is mandatory.
157
158
159
SECTION user
160
GLOBAL Fpmemwrite
NOTE
The compiler prepends the letter F to every function label name. Therefore, when calling C functions from either Assembly Language or Inline Assembly, the F must be prepended.
You can now call your assembly language function from C, as shown in Listing 8.10 on page 161. Listing 8.10 Sample Code - Calling an Assembly Language Function from C void pmemwrite( short, short ); /* Write a value into P: memory */ void main( void ) { // ...other code // Write the value given in the first parameter to the address // of the second parameter in P: memory pmemwrite( (short)0xE9C8, (short)0x0010 ); // other code... }
161
162
Fractional Arithmetic
Many of the intrinsic functions for Freescale DSP56800 use fractional arithmetic with implied fractional values. An implied fractional value is a symbol, which has been declared as an integer type, but is to be calculated as a fractional type. Data in a memory location or register can be interpreted as fractional or integer, depending on the needs of a user's program. All intrinsic functions that generate multiply and divide instructions (DIV, MPY, MAC, MPYR, and MACR) perform fractional arithmetic on implied fractional values. The following equation shows the relationship between a 16-bit integer and a fractional value: Fractional Value = Integer Value / (215) Similarly, the equation for converting a 32-bit integer to a fractional value is as follows: Fractional Value = Long Integer Value / (231) Table 8.1 on page 163 shows how both 16 and 32-bit values can be interpreted as either fractional or integer values. Table 8.1 Interpretation of 16- and 32-bit Values Type
short int short int long int long int
Hex
0x2000 0xE000 0x20000000 0xE0000000
Integer Value
8192 -8192 536870912 -536870912
Fixed-point Value
0.25 -0.25 0.25 -0.25
163
Function
__abs on page 166
Category
Multiplication/ MAC on page 179
Function
__mac_r on page 180 __msu_r on page 181 __mult on page 181 __mult_r on page 182 _L_mac on page 183 _L_msu on page 184 _L_mult on page 184 _L_mult_ls o n page 185
__negate on page 166 _L_negate on page 167 Addition/ Subtraction on page 167 __add on page 167
164
__long2fixed on page 174 __short2fixed on page 174 Copy on page 174 __memcpy on page 175 __strcpy on page 175 Deposit/ Extract on page 176 __extract_h on page 176 __extract_l on page 177 _L_deposit_h on page 177 _L_deposit_I on page 178 Division on page 178 __div on page 178 __div_ls on page 179
165
Absolute/Negate
on page 166__abs on page 166 __negate on page 166 _L_negate on page 167
__abs
Definition
Computes and returns the absolute value of a 16-bit integer. Generates an ABS instruction.
Assumption Prototype
int __abs( int );
Example
int i = -2; i = __abs( i );
__negate
Definition
Negates a 16-bit integer or fractional value returning a 16-bit result. for an input of 0x8000. Returns 0x7FFF
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
Prototype
Word16 __negate(Word16 svar1)
166
Example
int result, s1 = 0xE000;/* result = __negate(s1); // Expected value of result: 0x2000 = 0.25 - 0.25 */
_L_negate
Definition
Negates a 32-bit integer or fractional value returning a 32-bit result. 0x7FFFFFFF for an input of 0x80000000. Returns
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
Prototype
Word32 _L_negate(Word32 lvar1)
Example
long result, sl = 0xE0000000; result = _L_negate(s1); // Expected value of result: 0x20000000 = 0.25 /* - 0.25 */
Addition/Subtraction
__add on page 167 __sub on page 168 _L_add on page 169 _L_sub on page 169
__add
Definition
Addition of two 16-bit integer or fractional values, returning a 16-bit result. 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 167
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
Prototype
Word16 __add(Word16 src_dst, Word16 src2)
Example
short s1 = 0x4000;/* 0.5 */ short s2 = 0x2000;/* 0.25 */ short result;
__sub
Definition
Subtraction of two 16-bit integer or fractional values, returning a 16-bit result.
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
Prototype
Word16 __sub(Word16 src_dst, Word16 src2)
Example
short s1 = 0x4000;/* 0.5 */ short s2 = 0xE000;/* -0.25 */ short result;
168
_L_add
Definition
Addition of two 32-bit integer or fractional values, returning a 32-bit result.
Assumptions
OMRs 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;
_L_sub
Definition
Subtraction of two 32-bit integer or fractional values, returning a 32-bit result.
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
Prototype
Word32 _L_sub(Word32 src_dst, Word32 src2)
169
Example
long la = 0x40000000;/* 0.5 */ long lb = 0xE0000000;/* -0.25 */ long result;
Control
__stop on page 170
__stop
Definition
Generates a STOP instruction which places the processor in the low power STOP mode.
Prototype
void __stop(void)
Usage
__stop();
Conversion
The following intrinsics are provided to convert between various integer and fixed point types. The appropriate intrinsic should always be used when referencing an integer constant in fixed point context (i.e., assignment and comparisons). __fixed2int on page 171 __fixed2long on page 171 __fixed2short on page 172 __int2fixed on page 172 __labs on page 173 __long2fixed on page 174 __short2fixed on page 174 170 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual
__fixed2int
Definition
Converts a 16-bit __fixed__ value to a 16-bit integer.
Prototype
int __fixed2int ( __fixed__ );
Example
int int i; j; i_fix = 0.645;
__fixed__
i = __fixed2int( j = __fixed2int(
if (i == j) printf("PASSED\n");
if (i == __fixed2int( printf("PASSED\n");
0.645 ))
if (j == 21135) printf("PASSED\n");
__fixed2long
Definition
Converts a 32-bit __longfixed__ value to a 32-bit long integer.
Prototype
long __fixed2long ( __longfixed__ ); 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 171
Example
long l; __longfixed__ lfix = 0.645;
__fixed2short
Definition
Converts a 16-bit __shortfixed__ value to a 16-bit short integer.
Prototype
short __fixed2short ( __shortfixed__ );
Example
short s; sfix = 0.645; __shortfixed__
__int2fixed
Definition
Converts a 16-bit integer value to a 16-bit __fixed__ value.
Prototype
__fixed__ __int2fixed ( int );
172
Example
int i = 0x2000; __fixed__ ifix; __fixed__ jfix;
__labs
Definition
Computes and returns the absolute value of a 32-bit long integer. Generates an ABS instruction.
Prototype
long __labs ( long );
Example
long l = -2; l = __labs( l ); /* Returns 2 */
173
__long2fixed
Definition
Converts a 32-bit long integer to a 32-bit __longfixed__ type.
Prototype
__longfixed__ __long2fixed ( long );
Example
long l = 2; __longfixed__ lfix; /* Returns 9.31e-10 (2-30)*/
lfix = __long2fixed( l );
__short2fixed
Definition
Converts a 16-bit short integer to a 16-bit __shortfixed__ type.
Prototype
__shortfixed__ __short2fixed ( short );
Example
short s = 2; sfix; __shortfixed__
Copy
__memcpy on page 175 __strcpy on page 175
174
__memcpy
Definition
Copy a contiguous block of memory of n characters from the item pointed to by source to the item pointed to by dest. The behavior of __memcpy( ) is undefined if the areas pointed to by dest and source overlap.
Prototype
void * __memcpy ( void *dest, const void *source, size_t n );
Example
const int len = 9; char a1[len] = Socrates\0; char a2[len] = null;
__strcpy
Definition
Copies the character array pointed to by source to the character array pointed to by dest. The source argument must be a constant string. The function will not be inlined if source is defined outside of the function call. The resulting character array at dest is null terminated as well.
Prototype
char * __strcpy ( char *dest, const char *source );
175
Example
char d[11];
Deposit/ Extract
__extract_h on page 176 __extract_l on page 177 _L_deposit_h on page 177 _L_deposit_I on page 178
__extract_h
Definition
Extracts the 16 MSBs of a 32-bit integer or fractional value. Returns a 16-bit value. Does not perform saturation. When an accumulator is the destination, zeroes out the LSP portion. Corresponds to "truncation" when applied to fractional values.
Prototype
Word16 __extract_h(Word32 lsrc)
Example
long l = 0x87654321; short result;
176
__extract_l
Definition
Extracts the 16 LSBs of a 32-bit integer or fractional value. Returns a 16-bit value. Does not perform saturation. When an accumulator is the destination, zeroes out the LSP portion.
Prototype
Word16 __extract_l(Word32 lsrc)
Example
long l = 0x87654321; short result;
_L_deposit_h
Definition
Deposits the 16-bit integer or fractional value into the upper 16 bits of a 32-bit value, and zeroes out the lower 16 bits of a 32-bit value.
Prototype
Word32 _L_deposit_h(Word16 ssrc)
Example
short s1 = 0x3FFF; long result;
177
_L_deposit_I
Definition
Deposits the 16-bit integer or fractional value into the lower 16 bits of a 32- bit value, and sign extends the upper 16 bits of a 32-bit value.
Prototype
Word32 _L_deposit_l(Word16 ssrc)
Example
short s1 = 0x7FFF; long result;
Division
__div on page 178 __div_ls on page 179
__div
Definition
Divides two 16-bit short integers as a fractional operation and returns the result as a 16-bit short integer. Generates a DIV instruction.
Prototype
short __div( short, short );
178
Example
short i = 0x2000; /* Assign 0.25 to i */ short j = 0x4000; /* Assign 0.50 to j */ __fixed__ f;
i = __div( i, j );
/* Returns 16384 */
__div_ls
Definition
Single quadrant division, that is, both operands are positive two 16-bit fractional values, returning a 16-bit result. If both operands are equal, returns 0x7FFF (occurs naturally).
Note
Does not check for division overflow cases. Does not check for divide by zero cases.
Prototype
Word16 __div_s(Word16 s_denominator, Word16 s_numerator)
Example
short s1=0x2000;/* short s2=0x4000;/* short result; 0.25 */ 0.5 */
Multiplication/ MAC
__mac_r on page 180 __msu_r on page 181 __mult on page 181
179
__mac_r
Definition
Multiply two 16-bit fractional values and add to 32-bit fractional value. Round into a 16bit result, saturating if necessary. When an accumulator is the destination, zeroes out the LSP portion.
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled. OMRs R bit was set to 1 at least 3 cycles before this code, that is, 2s complement rounding, not convergent rounding.
Prototype
Word16 __mac_r(Word32 laccum, Word16 sinp1, Word16 sinp2)
Example
short s1 = 0xC000;/* - 0.5 */ short s2 = 0x4000;/* short result; long Acc = 0x0000FFFF; 0.5 */
180
__msu_r
Definition
Multiply two 16-bit fractional values and subtract this product from a 32-bit fractional value. Round into a 16-bit result, saturating if necessary. When an accumulator is the destination, zeroes out the LSP portion.
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled. OMRs R bit was set to 1 at least 3 cycles before this code, that is, 2s complement rounding, not convergent rounding.
Prototype
Word16 __msu_r(Word32 laccum, Word16 sinp1, Word16 sinp2)
Example
short s1 = 0xC000;/* - 0.5 */ short s2 = 0x4000;/* short result; long Acc = 0x20000000; 0.5 */
__mult
Definition
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.
181
Assumptions
OMRs 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;/* short s2 = 0x2000;/* short result; 0.25 */ 0.25 */
__mult_r
Definition
Multiply two 16-bit fractional values, round into a 16-bit fractional result. Saturates only for the case of 0x8000 x 0x8000. When an accumulator is the destination, zeroes out the LSP portion.
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled. OMRs R bit was set to 1 at least 3 cycles before this code, that is, 2s complement rounding, not convergent rounding.
Prototype
Word16 __mult_r(Word16 sinp1, Word16 sinp2)
182
Example
short s1 = 0x2000;/* short s2 = 0x2000;/* short result; 0.25 */ 0.25 */
_L_mac
Definition
Multiply two 16-bit fractional values and add to 32-bit fractional value, generating a 32bit result, saturating if necessary.
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
Prototype
Word32 _L_mac(Word32 laccum, Word16 sinp1, Word16 sinp2)
Example
short s1 = 0xC000;/* - 0.5 */ short s2 = 0x4000;/* 0.5 */ 0.25 */
183
_L_msu
Definition
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
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
Prototype
Word32 _L_msu(Word32 laccum, Word16 sinp1, Word16 sinp2)
Example
short s1 = 0xC000;/* - 0.5 */ short s2 = 0xC000;/* - 0.5 */ long result, Acc = 0;
_L_mult
Definition
Multiply two 16-bit fractional values generating a signed 32-bit fractional result. Saturates only for the case of 0x8000 x 0x8000.
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
Prototype
Word32 _L_mult(Word16 sinp1, Word16 sinp2)
184
Example
short s1 = 0x2000;/* short s2 = 0x2000;/* long result; 0.25 */ 0.25 */
_L_mult_ls
Definition
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
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
Prototype
Word32 _L_mult_ls(Word32 linp1, Word16 sinp2)
Example
long l1 = 0x20000000;/* 0.25 */ short s2 = 0x2000;/* 0.25 */ long result;
Normalization
__norm_l on page 186 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 185
__norm_l
Definition
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 DSP56800 because of the case of returning 0 for an input of 0x00000000.
Prototype
Word16 __norm_l(Word32 lsrc)
Example
long ll = 0x20000000;/* .25 */ short result;
__norm_s
Definition
Computes the number of left shifts required to normalize a 16-bit value, returning a 16-bit result. Returns a shift count of 0 for an input of 0x0000.
Note
Does not actually normalize the value!
186
Prototype
Word16 __norm_s(Word16 ssrc)
Example
short s1 = 0x2000;/* .25 */ short result;
Rounding
__round on page 187
__round
Definition
Rounds a 32-bit fractional value into a 16-bit result. When an accumulator is the destination, zeroes out the LSP portion.
Assumptions
OMRs R bit was set to 1 at least 3 cycles before this code, that is, 2s complement rounding, not convergent rounding. OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
Prototype
Word16 __round(Word32 lvar1)
Example
long l = 0x12348002;/*if low 16 bits = 0xFFFF > 0x8000 then
187
Shifting
__shl on page 188 __shr on page 189 __shr_r on page 190 _L_shl on page 190 _L_shr on page 191 _L_shr_r on page 192
__shl
Definition
Arithmetic shift of 16-bit value by a specified shift amount. If the shift count is positive, a left shift is performed. Otherwise, a right shift is performed. Saturation may occur during a left shift. When an accumulator is the destination, zeroes out the LSP portion.
Note
This operation is not optimal on the DSP56800 because of the saturation requirements and the bidirectional capability.
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
Prototype
Word16 __shl(Word16 sval2shft, Word16 s_shftamount)
188
Example
short result; short s1 = 0x1234; short s2= 1;
__shr
Definition
Arithmetic shift of 16-bit value by a specified shift amount. If the shift count is positive, a right shift is performed. Otherwise, a left shift is performed. Saturation may occur during a left shift. When an accumulator is the destination, zeroes out the LSP portion.
Note
This operation is not optimal on the DSP56800 because of the saturation requirements and the bidirectional capability.
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
Prototype
Word16 __shr(Word16 sval2shft, Word16 s_shftamount)
Example
short result; short s1 = 0x2468; short s2= 1;
189
__shr_r
Definition
Arithmetic shift of 16-bit value by a specified shift amount. If the shift count is positive, a right shift is performed. Otherwise, a left shift is performed. If a right shift is performed, then rounding performed on result. Saturation may occur during a left shift. When an accumulator is the destination, zeroes out the LSP portion.
Note
This operation is not optimal on the DSP56800 because of the saturation requirements and the bidirectional capability.
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
Prototype
Word16 __shr_r(Word16 s_val2shft, Word16 s_shftamount)
Example
short result; short s1 = 0x2468; short s2= 1;
_L_shl
Definition
Arithmetic shift of 32-bit value by a specified shift amount. If the shift count is positive, a left shift is performed. Otherwise, a right shift is performed. Saturation may occur during a left shift. When an accumulator is the destination, zeroes out the LSP portion.
190
Note
This operation is not optimal on the DSP56800 because of the saturation requirements and the bidirectional capability. See the intrinsic _L_shl on page 190 or result = shlfts(l, s1); on page 191 which are more optimal.
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
Prototype
Word32 _L_shl(Word32 lval2shft, Word16 s_shftamount)
Example
long result, l = 0x12345678; short s2= 1;
result = _L_shl(l,s2); // Expected value of result: 0x2468ACF0 result = shlfts(l, s1); // Expected value of result: 0x91A259E0
_L_shr
Definition
Arithmetic shift of 32-bit value by a specified shift amount. If the shift count is positive, a right shift is performed. Otherwise, a left shift is performed. Saturation may occur during a left shift. When an accumulator is the destination, zeroes out the LSP portion.
Note
This operation is not optimal on the DSP56800 because of the saturation requirements and the bidirectional capability.
Assumptions
OMRs SA bit was set to 1 at least 3 cycles before this code, that is, saturation on data ALU results enabled.
191
Prototype
Word32 _L_shr(Word32 lval2shft, Word16 s_shftamount)
Example
long result, l = 0x24680000; short s2= 1;
_L_shr_r
Definition
Arithmetic shift of 32-bit value by a specified shift amount. If the shift count is positive, a right shift is performed. Otherwise, a left shift is performed. If a right shift is performed, then rounding performed on result. Saturation may occur during a left shift.
Assumptions
OMR's SA bit was set to 1 at least 3 cycles before this code, that is, ALU results enabled. saturation on data
Prototype
Word32 _L_shr_r(Word32 lval2shft, Word16 s_shftamount)
Example
long l1 = 0x41111111; short s2 = 1; long result;
192
Pipeline Restrictions
This section gives an overview of how the pipeline restrictions are handled by the DSP56800 compiler. The following list contains pipeline restrictions that are detected and handled. If any of these cases are detected by the compilers inline assembler, the compiler generates a warning and inserts a NOP instruction to correct the violation of the pipeline restriction. 1. A NORM instruction cannot be immediately followed by an instruction that accesses X memory using the R0 pointer. The following example shows a warning is generated: NORM MOVE R0,A X:(R0)+,A ;Cannot reference R0 after NORM
2. Any jump, branch, or branch on bit field may not specify the instruction at LA or LA1 of a hardware DO loop as their target addresses. DO #7,LABEL BCC LABEL ;Cannot branch to LA ;instruction LABEL: 3. Any jump, branch, or branch on bit field instructions may not be located in the last two locations of a hardware DO loop (that is, at LA or at LA-1). DO #7,LABEL BCC ULABEL ;Cannot branch in LA ;instruction LABEL: NOTE A warning will be emitted when pipeline conflicts are detected.
4. If a MOVE instruction changes the value in one of the address registers (R0R3), then the contents of the register are not available for use until the second following instruction. That is, the instruction immediately following the MOVE instruction does not use the modified register to access X memory or update an address. This also applies to the SP register and M01 register. MOVE MOVE X:(SP-2),R1 X:(R1)+,A; ; R1 is not available
193
5. If a bit-field instruction changes the value in one of the address registers (R0R3), then the contents of the register are not available for use until the second following instruction. That is, the instruction immediately following the MOVE instruction does not use the modified register to access X memory or update an address. This applies to the SP and M01 registers. BFCLR MOVE #1,R1 X:(R1)+,A; ; R1 is not available
In addition, it applies to the N register when the Compiler adjusts for delayed load of N register option in the M56800 Processor target settings panel is enabled. BFCLR MOVE #1,N X:(R0+N),Y0 ;N is not available
6. For the case of nested hardware DO loops, it is required that there be at least two instructions after the pop of the LA and LC registers before the instruction at the last address of the outer loop. DO #3,OLABEL ; Beginning of outer loop PUSH LC PUSH LA DO X0,ILABEL ; Beginning of inner loop ; (instructions) REP Y0 ; Skips ASL if y0 = 0 ASL A ; (instructions) ILABEL: ; End of inner loop
POP LA POP LC NOP; 3 instructions required after POP NOP; 3 instructions required after POP NOP; 3 instructions required after POP OLABEL: ; End of outer loop
194
195
196
9
Debugging for DSP56800
This chapter, which explains the generic features of the CodeWarrior debugger, consists of these sections: Using Remote Connections on page 197 Target Settings for Debugging on page 207 Command Converter Server on page 207 Launching and Operating the Debugger Load/Save Memory on page 225 Fill Memory on page 228 Save/Restore Registers on page 230 OnCE Debugger Features on page 232 Using the 56800 Simulator Register Details Window on page 242 Loading a .elf File without a Project on page 243 Using the Command Window on page 244 System-Level Connect on page 244 Debugging on a Complex Scan Chain on page 245 Debugging in the Flash Memory on page 249 Setting up the Debugger for Flash Programming on page 251 Notes for Debugging on Hardware on page 253 Flash Programming the Reset and Interrupt Vectors on page 254
197
NOTE
We have included several types of remote connections in the default CodeWarrior installation. You can modify these default remote connections to suit your particular needs.
TIP
When you import a Makefile into the CodeWarrior IDE to create a CodeWarrior project, the IDE asks you to specify the type of debugger interface (remote connection) you want to use. To debug the generated CodeWarrior project, you must properly configure the remote connection you selected when you created the project.
198
NOTE
The specific remote connections that appear in the Remote Connections list differ between CodeWarrior products and hosts.
The Remote Connections preference panel lists all of the remote connections of which the CodeWarrior IDE is aware. You use this preference panel to add your own remote connections, remove remote connections, and configure existing remote connections to suit your needs. To add a new remote connection, click Add. To configure an existing remote connection, select it and click Change. To remove an existing remote connection, select it and click Remove. TIP To specify a remote connection for a particular build target in a CodeWarrior project, you select the remote connection from the Connection list box in the Remote Debugging target settings panel. For an overview of the Remote Debugging settings panel, see the CodeWarrior IDE Users Guide.
199
Description
Select to use a CCS hardware target system. Select to use the Simulator on the host computer.
Each of these protocols supports one or more types of connections (CCS, USBTAP, and Simulator). Editing Remote Connections on page 200 describes each supported connection type and how to configure them.
56800 Simulator
To configure a remote connection to correspond to your particular setup, you must edit the connection settings. You access the settings with the Edit Connection dialog box. You can view this dialog box in one of these ways: In the Remote Connections IDE preference panel, select a connection from the list, and click Edit. The Edit Connection dialog box appears. 200 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual
201
Table 9.3 on page 202 describes the options in this dialog box. Table 9.3 CCS Remote Connection Options Option
Name
Description
Enter the name you want to use to refer to this remote connection within the CodeWarrior IDE. Select CCS 56800 Protocol Plugin. Select CCS Remote Connection. Check to debug code on a target system when the system already has CCS running and connected.
202
Description
Enter the Internet Protocol (IP) address assigned to the target system. Enter the port number on the target system to which the IDE should connect for CCS operations. The default port number for CCS hardware connections is 41475. Enter 41476 for the CCS Simulator. Check to use another CCS executable file rather than the default CCS executable file: CWInstall\ccs\bin\ccs.exe Check to debug code on a target system with multiple cores where you need to specify the JTAG chain for debugging. Click Choose to specify the JTAG initialization file. A JTAG initialization file contains the names and order of the boards / cores you want to debug. Enter the duration (in seconds) after which the CCS should attempt to reconnect to the target system if a connection attempt fails.
Port #
Multi-Core Debugging
CCS Timeout
USBTAP
Use this connection type to configure how the IDE uses CodeWarrior USB TAP device to connect with the target system. This connection type is available only when the CCS 56800 Protocol Plugin debugger protocol is selected. Figure 9.4 on page 204 shows the settings that are available to you when you select USBTAP from the Connection Type list box in the Edit Connection dialog box.
203
Table 9.4 on page 204 describes the options in this dialog box. Table 9.4 UBTAP Options Option
Name
Description
Enter the name you want to use to refer to this remote connection within the CodeWarrior IDE. Select CCS 56800 Protocol Plugin. Select USBTAP Connection. Enter the maximum number of seconds the debugger should wait for a response from CCS. By default, the debugger waits up to 10 seconds for responses.
204
Description
Check to debug code on a target system with multiple cores where you need to specify the JTAG chain for debugging. Click Choose to specify the JTAG initialization file. A JTAG initialization file contains the names and order of the boards / cores you want to debug. Check to have the debugger send a reset signal to the target system when you start debugging. Clear to prevent the debugger from resetting the target device when you start debugging.
Simulator
Use this connection type to configure the behavior of the simulator. This connection type is available only when the 56800 Simulator Protocol Plugin debugger protocol is selected. Figure 9.5 on page 206 shows the setting that are available to you when you select Simulator from the Connection Type list box in the Edit Connection dialog box.
205
Table 9.5 on page 206 describes the options in this dialog box. Table 9.5 Simulator Options Option
Name
Description
Enter the name you want to use to refer to this remote connection within the CodeWarrior IDE. Select SIM 56800 Protocol Plugin. Select Simulator. Select the simulator bandwidth (low, medium, or high).
206
Affects
symbolics, linker warnings optimizations Debugging options Debugging communication protocol Debugging options
Refer to
M56800 Linker
Optimizing Code
Remote Debugging
The M56800 Target panel is unique to DSP56800 debugging. The available options in this panel depend on the DSP56800 hardware you are using and are described in detail in the section on Remote Debug Options.
207
208
A menu appears (Figure 9.7 on page 209): Figure 9.7 Command Converter Server Menu
2. Select Show console from the menu. The Freescale Command Converter Server window appears (Figure 9.8 on page 209). Figure 9.8 Freescale Command Converter Server Window
209
6. Press Enter. 7. Type the following command to save the configuration: config save 8. Press Enter.
210
211
212
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. Use this text box to specify the IP address where the command converter server resides when running the command converter server from a location on the network. 5. Enter the Port # to which the command converter server listens or use the default port, which is 41475. 6. Click the OK button.
213
1. Set debugger preferences. Select Edit >external memory Settings from the menu bar of the Freescale CodeWarrior window. The IDE displays the Remote Debugging window.
214
2. Select the Connection. For example, select 56800 Local Hardware Connection (CCS). 3. Click OK button. 4. Debug the project. Use either of the following options: From the Freescale CodeWarrior window, select Project > Debug. Click the Debug button in the project window. This command resets the board (if Always reset on download is checked in the Debuggers M56800 Target panel shown in Figure 5.13 on page 95) and the download process begins. When the download to the board is complete, the IDE displays the Program window (sim.elf in sample) shown in Figure 9.12 on page 216. NOTE Source code is shown only for files that are in the project folder or that have been added to the project in the project manager, and for which the IDE has created debug information. You must navigate the file system in order to locate sources that are outside the project folder and not in the project manager, such as library source files.
215
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. The toolbar at the top of the window has buttons that allows you access to the execution commands in the Debug menu.
216
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 9.13 on page 217), confirming you have set your breakpoint. Figure 9.13 Breakpoint in the Program Window
Breakpoint Setting
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 OnCE Debugger Features.. NOTE For the DSP56800 only one watchpoint is available. This watchpoint is only available on hardware targets.
217
218
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. NOTE To view peripheral registers, select the appropriate processor form the processor list box in the M56800 Target Settings Panel.
Viewing X: Memory
You can view X memory space values as hexadecimal values with ASCII equivalents. You can edit these values at debug time. 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 219
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. From the menu bar of the Freescale 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 9.16 on page 220). Figure 9.16 View X:Memory Window
2. Select type of memory. Locate the Page list box at the bottom of the View Memory window. Select X Memory for X Memory.
220
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. To view program memory, from the menu bar of the Freescale CodeWarrior window, select Data > View Memory. The Memory window appears (Figure 9.16 on page 220). 2. Select type of memory. Locate the Page list box at the bottom of the View Memory window. Select P Memory for P Memory. 3. Enter memory address. Type the memory address in the Display field located at the top of the Memory window. To enter a hexadecimal address, use standard C hex notation, for example: 0x82. 4. Select how you want to view P memory. Using the View list box, you have the option to view P Memory in four different ways. Raw Data (Figure 9.17 on page 222).
221
222
223
224
Load/Save Memory
From the menu bar of the Freescale CodeWarrior window, select Debug > 56800 > Load/Save Memory to display the Load/Save Memory dialog box (Figure 9.21 on page 226).
225
Use this dialog box to load and save memory at a specified location and size with a userspecified 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.
226
Radio Buttons
The Load/Save Memory dialog box has two radio buttons: Load Memory Save Memory The default is Load Memory.
227
Browse Button
Clicking the Browse button displays OPENFILENAME or SAVEFILENAME, depending on whether you selected the Load Memory or Save Memory radio button.
Fill Memory
From the menu bar of the Freescale CodeWarrior window, select Debug > 56800> Fill memory to display the Fill Memory dialog box (Figure 9.22 on page 228). Figure 9.22 Fill Memory Dialog Box
Use this dialog box to fill memory at a specified location and size with user- specified raw memory data. You can associate a key binding with this dialog box for quick access. Press the Tab key to cycle through the dialog box display, which lets you quickly make changes without using the mouse.
228
229
ASCII Strings
ASCII strings can be quoted to have literal interpretation of spaces inside the quotes. Otherwise, spaces in the string are ignored. Note that if the ASCII strings are not quoted and they are numbers, it is possible to create illegal numbers. If the number is illegal, an error message is displayed.
Save/Restore Registers
From the menu bar of the Freescale CodeWarrior window, select Debug > 56800 > Save/Restore Registers to display the Save/Restore Registers dialog box (Figure 9.23 on page 231).
230
Use this dialog box to save and restore register groups to and from a user-specified file.
Radio Buttons
The Save/Restore Registers dialog box has two radio buttons: Save Registers Restore Registers The default is Save Registers.
231
Browse Button
Clicking the Browse button displays OPENFILENAME or SAVEFILENAME, depending on whether you selected the Restore Registers or Save Registers radio button.
233
NOTE
When you clear a custom watchpoint, the settings you last used are now selected instead of the previous default values. These settings do not carry over from previous debugging sessions.
Breakpoint Unit 1
Breakpoint unit 1 (BPU1) of the watchpoint status window allows you to monitor address values and access type for any X or P memory location. Options for setting BPU1 are in the Breakpoint Unit 1 group box shown in Figure 9.25 on page 235 and listed in Table 9.7 on page 235.
234
Value
Execute program fetch
Comment
When a P memory instruction is executed. Mode defaults to Read. Useful when only interest is opcode instructions. Any time a P memory address is accessed, depending on the value of Mode. Useful when writing or reading data from P memory. Access for all X address values through XAB1 (internal or external memory) depending on the Mode you select. Range: 0x0 to 0xFFFF
X Address Bus 1
Value
Mode
NOTE
If Breakpoint Unit 2 is disabled (in use by the debugger), then the occurrence counter is set to 1 as the default.
Breakpoint Unit 2
Breakpoint unit 2 (BPU2) of the watchpoint status window allows you to monitor values (and their masks) in either the Core Global Data Bus (CGDB) or Program Address Bus (PAB). When you use BPU2 in conjunction with BPU1 and the occurrence counter, you 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 235
NOTE
If you are using Breakpoint Unit 2, ensure that one of the radio buttons is set to use Breakpoint 2 in the Sequence group box.
Value
Enabled
Comment
Breakpoint unit 2 cannot be user defined and the occurrence counter defaults to 1 for BPU1. Breakpoint unit 2 is user-defined and occurrence counter is available for both BPU1 and BPU2. Single stepping, stepping over, and stepping out of functions cannot be done when hardware breakpoints are enabled. Data transfer between the data ALU and X data memory for one memory access. 19-bit program memory address bus.
Disabled
Bus
236
Value
The hexadecimal value read from the specified Bus. Mask value in C hex notation from 0x0 to 0xFFFF.
Comment
To read full value, set Mask to 0xFFFF.
Mask
Specify a value of 0xFFFF for full value specified by Value. Specify other hex value to exclude bits. For example, if you wanted to stop at any value where bit 15 is set, you would specify 0x8000 in both the Mask and Value fields
Occurrence Counter
The Occurrence Counter uses the OnCE breakpoint counter (OCNTR) for stopping on the nth iteration of a program loop or when the nth occurrence of a data memory access occurs. When you specify a value from 1 to 256 in the Occurrence Counter text box, it sets ONCTR to that value minus 1. Refer to OnCE Breakpoint Counter (OCNTR) in the DSP56800 Family Manual for more information. NOTE Once the Occurrence Counter is decremented and a breakpoint is reached, the counter is not reset. Hence, the Occurrence Counter remains at one and stops at every specified breakpoint.
Sequence Options
To define the criteria for how often the debugger stops on a watchpoint, use the Sequence group box (Figure 9.27 on page 238). The value you set in the Occurrence Counter text box determines the value of COUNTER.
237
Table 9.9 on page 238 explains the options available in the Sequence group box
.
Comment
If Reserve Breakpoint Unit 2 for Debugger is enabled, this is the default option and COUNTER is 1. BPU1 and BPU2 work independently. If you are only interested in using BPU2, set BPU1 to a value you know will not be reached during program execution. BPU1 and BPU2 work together. This is useful for monitoring bit status with a defined mask.
Breakpoint 1 and Breakpoint 2 simultaneously occur COUNTER times Breakpoint 2 occurs once, then Breakpoint 1 occurs COUNTER times Breakpoint 2 occurs COUNTER times, then Breakpoint 1 occurs once
238
Trace Buffer
From the menu bar of the Freescale CodeWarrior window, select DSP56800 > Dump Trace Buffer to see the most recent changes in the program flow and a reconstructed program trace (Figure 9.28 on page 239). Use this feature to query the Trace Buffer, located in the On-Chip Emulation module of a hardware target. This buffer stores the eight most recent changes in the program flow. The debugger retrieves these addresses and attempts to reconstruct a trace of the program flow. This occurs both when the window is opened and whenever debugging stops while the window is open. The Trace Buffer menu item is enabled when the IDE is debugging a hardware target and debugging has stopped. Figure 9.28 Trace Buffer Window
The trace buffer lets you view the target addresses of change-of-flow instructions that the program executes.
239
240
Cycle/Instruction Count
From the menu bar of the Freescale CodeWarrior window, select 56800 > Display Cycle/Instruction count. The following window appears (Figure 9.30 on page 241): Figure 9.30 Simulator Cycle/Instruction Count
NOTE
Cycle counting is not accurate while single stepping through source code in the debugger. It is only accurate while running. Thus, the cycle counter is more of a profiling tool than an interactive tool.
Press the Reset button to zero out the current machine-cycle and machine-instruction readings.
241
Memory Map
Figure 9.31 Simulator Memory Map
$FFFF
$0 X:
Figure 9.31 on page 242 is the memory map configuration for the simulator. Therefore, the simulator does not simulate each DSP568xx devices specific memory map, but assumes the memory map of the DSP56824.
242
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\M56800\GPR Register description files must end with the .xml extension. Alternatively, you can use the Browse button to locate the register description files. Using the Format list box in the Register Details window, you can change the format in which the CodeWarrior IDE displays the registers. Using the Text View list box in the Register Details window, you can change the text information the CodeWarrior IDE displays.
The project that the CodeWarrior tools uses to create a new project for the given .elf file is 56800_Default_Project.xml and is located in the path: CodeWarrior\bin\plugins\support directory You can create your own version of this file to use as a default setting when opening a .elf file: 1. Create a new project with the default setting you want. 2. Export the project to xml format. 3. Rename the xml format of the project to 56800_Default_Project.xml and place it in the support directory. NOTE Back up or rename the original version of the default xml project before overwriting it with your own customized version.
System-Level Connect
The CodeWarrior DSP56800 debugger lets you connect to a loaded target board and view system registers and memory. A system-level connect does not let you view symbolic information during a connection. NOTE The following procedure explains how to connect in the context of developing and debugging code on a target board. However, you can select the Debug > Connect command anytime you have a project window open, even if you have not yet downloaded a file to your target board.
244
Setting Up
The general steps for debugging a DSP56800 chip connected on a complex scan chain are: 1. Set up and connect your JTAG chain of target boards. 2. Write a JTAG initialization file that describes the items on the JTAG chain. 3. Open a project to debug. 4. In the project you are debugging, open the Remote Debugging preference panel (Figure 9.33 on page 246).
245
5. Click the Edit Connection button and enable the Multi-Core Debugging checkbox (Figure 9.34 on page 247).
246
6. Specify the name and path of the JTAG initialization file in the JTAG Configuration File text field. 7. Click OK to close the connection panel. 8. In the Remote Debugging panel, specify the index of the core to debug by enabling the Multi-Core Debugging checkbox and changing the Core Index selection. 9. Select Project > Run. The IDE downloads the program to the specified core. You can begin debugging.
247
NOTE
Device 0 is the device closest to the TDO signal on the Command Converter Server.
Listing 9.1 Example JTAG Initialization File for DSP56800, SC140 and MCore210 Boards # JTAG Initialization File # Has an DSP56800 # Has an DSP56800 # Has an DSP56800 # Has an SC140 # Has an MCore210 index value of 0 in the JTAG chain index value of 1 in the JTAG chain index value of 2 in the JTAG chain index value of 3 in the JTAG chain index value of 4 in the JTAG chain
NOTE
In addition, you can specify other chips to debug on the JTAG chain. To do so, you use the following syntax to specify the chip as a generic device: Generic instruct_reg_length data_reg_bypass_length JTAG_bypass_instruction on page 249Table 9.10 on page 248 shows the definitions of the variables that you must specify for a generic device. Table 9.10 Syntax Variables to Specify a Generic Device on a JTAG Chain Variable
instruct_reg_length data_reg_bypass_length JTAG_bypass_instruct
Description
Length in bits of the JTAG instruction register. Length in bits of the JTAG bypass register. Hexadecimal value that specifies the JTAG bypass instruction.
Listing 9.2 on page 249 shows a JTAG initialization file that includes a DSP56800 chip and a generic device in a JTAG chain.
248
set_hfmclkd <value>
This command writes the value which represents the clock divider for the flash memory to the hfmclkd register. The value for the set_hfmclkd command depends on the frequency of the clock. If you are using a supported EVM, this value should not be changed from the value provided in the default initialization file. However, if you are using an unsupported board and the clock frequency is different from that of the supported EVM, a new value must be calculated as described in the users manual of the particular processor that you are using. NOTE The set_hfmclkd, set_hfm_base, and at least one add_hfm_unit command must exist to enable flash programming. All other flash memory commands are optional.
249
set_hfm_base <address>
This command sets the address of hfm_base, which is where the flash control registers are mapped in X: memory. 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_config_base <address>
This command sets the address of hfm_config_base, which is where the flash security values are written in program flash memory. If this command is present, the debugger used the address to mimic part of the hardware reset behavior by copying the protection values from the configuration field to the appropriate flash control registers.
250
set_hfm_verify_erase 1 | 0
If you set this to 1, the debugger verifies that the flash memory has been erased, and alerts you if the erase failed. If this command is omitted, the flash erase is not verified.
set_hfm_verify_program 1 | 0
If you set this to 1, the debugger verifies that the flash has been programmed correctly, and alerts you if the programming failed. If you omit this command, flash programming is not verified.
251
252
For more information on the Flash Configuration File Line Format, see M56800 Target (Debugging).
253
254
10
Data Visualization
Data visualization lets you graph variables, registers, and regions of memory as they change over time. The Data Visualization tools can plot memory data, register data, and global variable data. Starting Data Visualization on page 255 Data Target Dialog Boxes on page 256 Graph Window Properties on page 259
3. Configure the data target dialog box and filter dialog box.
255
Data Visualization
Data Target Dialog Boxes 4. Run your program to display the data (Figure 10.2 on page 256). Figure 10.2 Graph Window
Memory
The Target Memory dialog box lets you graph memory contents in real-time.
256
Data Visualization
Data Target Dialog Boxes Figure 10.3 Target Memory Dialog Box
Data Type
The Data Type list box lets you select the type of data to be plotted.
Data Unit
The Data Units text field lets you enter a value for number of data units to be plotted. This option is only available when you select Memory Region Changing Over Time.
257
Data Visualization
Data Target Dialog Boxes
Registers
The Target Registers dialog box lets you graph the value of registers in real-time. Figure 10.4 Target Registers Dialog Box
Select registers from the left column, and click the -> button to add them to the list of registers to be plotted.
Variables
The Target Globals dialog box lets you graph the value of global variables in real-time. (See Figure 10.5 on page 259.)
258
Data Visualization
Graph Window Properties Figure 10.5 Target Globals Dialog Box
Select global variables from the left column, and click the -> button to add them to the list of variables to be plotted.
259
Data Visualization
Graph Window Properties Figure 10.6 Format Axis Dialog Box
Scaling
The default scaling settings of the data visualization tools automatically scale the graph window to fit the existing data points. To override the automatic scaling, uncheck a scaling checkbox to enable the text field and enter your own value. To scale either axis logarithmically, enable the Logarithmic Scale option of the corresponding axis.
Display
The Display settings let you change the maximum number of data points that are plotted on the graph.
260
11
Profiler
The profiler is a run-time feature that collects information about your program. It records the minimum, maximum, and total number of clock cycles spent in each function. The profiler allows you to evaluate your code and determine which functions require optimization. When profiling is enabled, the compiler adds code to call the entry functions in the profiler library. These profiler library functions do all of the data collection. The profiler library, with the help of the debugger create a binary output file, which is opened and displayed by the CodeWarrior IDE. NOTE For more information on the profiler library and its usage, see the CodeWarrior Development Studio IDE 5.5 Users Guide Profiler Supplement.
To enable your project for profiling: 1. Add the following path to your list of user paths in the Access Paths settings panel: {Compiler}M56800x Support\profiler 2. Add the following line to the file that contains the function main(): #include "Profiler.h" 3. Add the profiler library file to your project. Select the library that matches your target from this path: {CodeWarrior path}M56800x Support\profiler\lib 4. Add the following function calls to main(): ProfilerInit() ProfilerClear() ProfilerSetStatus() ProfilerDump() ProfilerTerm() For more details of these functions, see the CodeWarrior Development Studio IDE 5.5 Users Guide Profiler Supplement. 5. It may be necessary to increase the heap size to accommodate the profiler data collection. This can be set in the linker command file by changing the value of __heap_size.
261
Profiler
6. Enable profiling by setting the Generate code for profiling option in the M56800 Processor settings panel or by using the profile on | off pragma to select individual functions to profile. NOTE For a profiler example, see the profiler example in this path: {CodeWarrior path}(CodeWarrior_Examples)\ SimpleProfiler
262
12
ELF Linker
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. All of these functions are accessed through commands in the linker command file (LCF). The linker command file has its own language complete with keywords, directives, and expressions, that are used to create the specifications for your output code. The syntax and structure of the linker command file is similar to that of a programming language. This chapter contains the following sections: Structure of Linker Command Files on page 263 Linker Command File Syntax on page 266 Linker Command File Keyword Listing on page 273 on page 283Sample M56800 Linker Command File on page 283
Memory Segment
In the memory segment, available memory is divided into segments. Listing 12.1 on page 263 shows a sample memory-segment format. Listing 12.1 Sample MEMORY Segment MEMORY {
263
ELF Linker
Structure of Linker Command Files segment_1 (RWX): ORIGIN = 0x1000, 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... } The (RWX) portion consists of ELF access permission flags, read, write, and execute where: ORIGIN represents the start address of the memory segment. LENGTH represents the maximum size allowed for the memory segment. Memory segments with RWX attributes are placed into P memory while RW attributes are placed into X memory. Memory segments with R attributes denote X ROM memory, and memory segments with RX attributes denote P ROM memory. You can put a segment immediately after the previous one using the AFTER command. If you cannot predict how much space a segment will occupy, you can use the command LENGTH = 0 (unlimited length) and let the linker figure out the size of the segment.
Closure Blocks
The linker is very good at deadstripping unused code and data. Sometimes, however, symbols need to be kept in the output file even if they are never directly referenced. Interrupt handlers, for example, are usually linked at special addresses, without any explicit jumps to transfer control to these places. Closure blocks provide a way to make symbols immune from deadstripping. The closure is transitive, meaning that symbols referenced by the symbol being closed are also forced into closure, as are any symbols referenced by those symbols, and so on. NOTE The closure blocks need to be in place before the SECTIONS definition in the linker command file.
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 in Listing 12.2 on page 265.
264
ELF Linker
Structure of Linker Command Files Listing 12.2 Sample Symbol-level Closure Block FORCE_ACTIVE {break_handler, interrupt_handler, my_function} Section-level Use KEEP_SECTION when you want to keep a section (usually a user-defined section) in the link. Listing 12.3 on page 265 is an example. Listing 12.3 Sample Section-level Closure Block KEEP_SECTION {.interrupt1, .interrupt2} A variant is REF_INCLUDE. It keeps a section in the link, but only if the file where it is coming from is referenced. This is very useful to include version numbers. Listing 12.4 on page 265 is an example. Listing 12.4 Sample Section-level Closure Block With File Dependency REF_INCLUDE {.version}
Sections Segment
In the Sections segment, you define the contents of memory segments and any global symbols to be used in the output file. The format of a typical sections block is in Listing 12.5 on page 265. Listing 12.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. } > segment_1 #this means "map these contents to segment_1" .next_section_name: { more content descriptions } > segment_x # end of .next_section_name definition 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 265
ELF Linker
Linker Command File Syntax } # end of the sections block
Alignment
To align data on a specific word-boundary, you use the ALIGN and ALIGNALL commands to bump the location counter to the preferred boundary. For example, the following fragment uses ALIGN to bump the location counter to the next 16-byte (word) boundary. A sample is in Listing 12.6 on page 266. Listing 12.6 Sample ALIGN Command Usage file.c (.text) . = ALIGN (0x10); file.c (.data) # aligned on a 16-byte (word) boundary. You can also align data on a specific word-boundary with ALIGNALL as shown in (Listing 12.7 on page 266). Listing 12.7 Sample ALIGNALL Command Usage file.c (.text) ALIGNALL (0x10); (word) file.c (.data)
Arithmetic Operations
Standard C arithmetic and logical operations may be used to define and use symbols in the linker command file. Table 12.1 on page 267 shows the order of precedence for each operator. All operators are left-associative.
266
ELF Linker
Linker Command File Syntax
Operators
- ! * + >> == & | && || / << != > < <= >= %
NOTE
The shift operator shifts two-bits for each shift operation. The divide operator performs division and rounding.
Comments
Add comments by using the pound character (#) or C++ style double-slashes (//). C-style comments are not accepted by the LCF parser. Listing 12.8 on page 267 shows examples of valid comments. Listing 12.8 Example Comments # This is a one-line comment * (.text) // This is a partial-line comment
Deadstrip Prevention
The M56800 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.
267
ELF Linker
Linker Command File Syntax
Global Variables
Global variables are accessed in a linker command file with an F prepended to the symbol name. This is because the compiler adds an F prefix to externally defined symbols. Listing 12.10 on page 268 shows an example of using a global variable in a linker command file. This example sets the global variable _foot, declared in C with the extern keyword, to the location of the address location current counter. Listing 12.10 Using a Global Variable in the LCF F_foot = .; If you use a global symbol in an LCF, as in Listing 12.10 on page 268, it can be accessed from C program sources as shown in Listing 12.11 on page 268. Listing 12.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 // ... }
268
ELF Linker
Linker Command File Syntax
Integral Types
The syntax for linker command file expressions is very similar to the syntax of the C programming language. All integer types are long or unsigned long. Octal integers (commonly know as base eight integers) are specified with a leading zero, followed by numeral in the range of zero through seven. Listing 12.13 on page 269 shows valid octal patterns you could put into your linker command file. Listing 12.13 Sample Octal Patterns _octal_number = 012; _octal_number2 = 03245; Decimal integers are specified as a non-zero numeral, followed by numerals in the range of zero through nine. To create a negative integer, use the minus sign (-) in front of the number. Listing 12.14 on page 269 shows examples of valid decimal integers that you could write into your linker command file. Listing 12.14 Sample Decimal Integers _dec_num = 9999; _decimalNumber = -1234; Hexadecimal (base sixteen) integers are specified as 0x or 0X (a zero with an X), followed by numerals in the range of zero through nine, and/or characters A through F.
269
ELF Linker
Linker Command File Syntax Examples of valid hexadecimal integers you could put in your linker command file appear in Listing 12.15 on page 270. Listing 12.15 Example Hexadecimal Integers _somenumber = 0x0F21; _fudgefactorspace = 0XF00D; _hexonyou = 0xcafe;
File Selection
When defining the contents of a SECTION block, specify the source files that are contributing to their sections. The standard method of doing this is to list the files. In a large project, the list can grow to become very long. For this reason, use the asterix (*) keyword. The asterix (*) keyword represents the filenames of every file in your project. Note, that since you have already added the .text sections from the files main.c, file2.c, and file3.c, the '*' keyword does not include the .text sections from those files again.
Function Selection
The OBJECT keyword allows precise control over how functions are placed within a section. For example, if the functions pad and foot are to be placed before anything else in a section, use code like the example in Listing 12.16 on page 270. Listing 12.16 Sample Function Selection Using the 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, you can prevent the same object from being written again using the '*' file selection keyword.
270
ELF Linker
Linker Command File Syntax
For example, you have a program and you want to copy all your initialized data into RAM at runtime. Listing 12.17 on page 271shows you the LCF used to set up for writing initialized data to ROM. NOTE If you want to write initialized data to program ROM, use the WRITE commands in the LCF. Also, write your own P to X memory copy routine in assembly to copy data from program ROM to data RAM at runtime.
Listing 12.17 LCF File to Prepare Data Copy From ROM to RAM MEMORY { .text (RWX) : ORIGIN = 0x8000, LENGTH = 0x0 .data (RW) : ORIGIN = 0x3000, LENGTH = 0x0 } SECTIONS{ F__ROM_Address = 0x1000; .main_application : { # .text sections *(.text) *(.rtlib.text) *(.fp_engine.txt) *(user.text) } > .text # ROM Starting Address
271
ELF Linker
Linker Command File Syntax
.data : AT( F__ROM_Address ) { # .data sections F_Begin_Data = .; *(.data) *(fp_state.data); *(rtlib.data); F_End_Data = .; # .bss sections * (rtlib.bss.lo) * (.bss) } > .data }
# Get start location for RAM # Write data to the section (ROM)
To make the runtime copy the section from ROM to RAM, you need to know where the data start in ROM (__ROM_Address) and the size of the block in ROM you want to copy to RAM. In Listing 12.18 on page 272, all variables in the data section from ROM to RAM in C code are copied. Listing 12.18 ROM to RAM Copy From C After Data-Flash Write #include <stdio.h> #include <string.h> int GlobalFlash = 6; // From linker command file extern __Begin_Data, __ROMAddress, __End_Data; void main( { unsigned unsigned unsigned void ) short a = 0, b = 0, c = 0; long dataLen = 0x0; 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 );
272
ELF Linker
Linker Command File Keyword Listing a = GlobalFlash; return; }
NOTE
For this example to work, you must be writing to Flash with the CodeWarrior debugger and have your board jumpered to mode 0.
273
ELF Linker
Linker Command File Keyword Listing ADDR on page 275 ALIGN on page 276 ALIGNALL on page 276 FORCE_ACTIVE on page 277 INCLUDE on page 277 INCLUDE on page 277 KEEP_SECTION on page 277 MEMORY on page 277 OBJECT on page 279 REF_INCLUDE on page 279 SECTIONS on page 280 SIZEOF on page 281 SIZEOFW on page 281 WRITEB on page 282 WRITEH on page 282 WRITES on page 282 WRITEW on page 283
. (location counter)
The period character (.) always maintains the current position of the output location. Since the period always refers to a location in a SECTIONS block, it can not be used outside a section definition. A period may appear anywhere a symbol is allowed. Assigning a value to period that is greater than its current value causes the location counter to move, but the location counter can never be decremented. This effect can be used to create empty space in an output section. In the example below, the location counter is moved to a position that is 0x1000 words past the symbol FSTART_.
274
ELF Linker
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) 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
275
ELF Linker
Linker Command File Keyword Listing
ALIGN
The ALIGN function returns the value of the location counter aligned on a boundary specified by the value of alignValue. The alignValue must be a power of two.
Prototype
ALIGN(alignValue) Please note that ALIGN does not update the location counter; it only performs arithmetic. To update the location counter, use an assignment such as the following:
Example
. = ALIGN(0x10); #update location counter to 16 #byte alignment
ALIGNALL
ALIGNALL is the command version of the ALIGN function. It forces the minimum alignment for all the objects in the current segment to the value of alignValue. The alignValue must be a power of two.
Prototype
ALIGNALL(alignValue); Unlike its counterpart ALIGN, ALIGNALL is an actual command. It updates the location counter as each object is written to the output.
Example
.code : { ALIGNALL(16); * * (.init) (.text) // Align code on 16 byte boundary
ALIGNALL(16); * (.rodata)
} > .text 276 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual
ELF Linker
Linker Command File Keyword Listing
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.
Prototype
FORCE_ACTIVE{ symbol[, symbol] }
INCLUDE
The INCLUDE command allows you to include a binary file in the output file.
Prototype
INCLUDE filename
KEEP_SECTION
The KEEP_SECTION directive allows you to specify sections that you do not want the linker to deadstrip. You must specify the section(s) you want to keep before you use the SECTION keyword.
Prototype
KEEP_SECTION{ sectionType[, sectionType] }
MEMORY
The MEMORY directive allows you to describe the location and size of memory segment blocks in the target. This directive specifies the linker the memory areas to avoid, and the memory areas into which it links the code and date. The linker command file may only contain one MEMORY directive. However, within the confines of the MEMORY directive, you may define as many memory segments as you wish.
277
ELF Linker
Linker Command File Keyword Listing
Prototype
MEMORY { memory_spec } The memory_spec is: segmentName (accessFlags) : ORIGIN = address, LENGTH = length [,COMPRESS] [> fileName] segmentName can include alphanumeric characters and underscore '_' characters. accessFlags are passed into the output ELF file (Phdr.p_flags). The accessFlags can be: R-read W-write X-executable (for P memory placement) address origin is one of the following: Memory address Specify a hex address, such as 0x8000. AFTER command Use the AFTER(name [,name]) command to instruct the linker to place the memory segment after the specified segment. In the example below, overlay1 and overlay2 are placed after the code segment. When multiple memory segments are specified as parameters for AFTER, the highest memory address is used.
Example
MEMORY{ code (RWX) : ORIGIN = 0x8000, LENGTH = 0
ORIGIN is the assigned address. LENGTH is any of the following: A value greater than zero. If you try to put more code and data into a memory segment greater than your specified length allows, the linker stops with an error. Autolength by specifying zero.
278
ELF Linker
Linker Command File Keyword Listing When the length is 0, the linker lets you put as much code and data into a memory segment as you want. NOTE There is no overflow checking with autolength. The linker can produce an unexpected result if you use the autolength feature without leaving enough free memory space to contain the memory segment. Using the AFTER keyword to specify origin addresses prevents this.
> fileName is an option to write the segment to a binary file on disk instead of an ELF program header. The binary file is put in the same folder as the ELF output file. This option has two variants: > fileName Writes the segment to a new file. >> fileName Appends the segment to an existing file.
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 an object is written to the outfile using the OBJECT keyword, the IDE does not allow the same object to be written again by using the '*' wildcard selector.
REF_INCLUDE
The REF_INCLUDE directive allows you to specify sections that you do not want the linker to deadstrip, but only if they satisfy a certain condition: the file that contains the section must be referenced. This is useful if you want to include version information from your source file components. You must specify the section(s) you want to keep before you use the SECTIONS keyword.
Prototype
REF_INCLUDE{ sectionType [, sectionType]}
279
ELF Linker
Linker Command File Keyword Listing
SECTIONS
A basic SECTIONS directive has the following form:
Prototype
SECTIONS { <section_spec> } section_spec is one of the following: sectionName : [AT (loadAddress)] {contents} segmentName >
sectionName : [AT (loadAddress]] {contents} >> segmentName Table 12.2 Sections Directive
sectionName The section name for the output section. It must start with a period character. For example, .mysection. 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. Made up of statements.
AT (loadAddress)
contents
These statements can: assign a value to a symbol. describe the placement of an output section, including which input sections are placed into it. segmentName is the predefined memory segment into which you want to put the contents of the section. The two variants are: Table 12.3 segmentName Variants
> segmentName Places the section contents at the beginning of the memory segment segmentName. Appends the section contents to the memory segment segmentName.
>> segmentName
280
ELF Linker
Linker Command File Keyword Listing
Example
SECTIONS { .text : { F_textSegmentStart = .; footpad.c (.text) . = ALIGN (0x10); padfoot.c (.text) F_textSegmentEnd = .; } .data : { *(.data) } .bss : { *(.bss) *(COMMON) } }
SIZEOF
The SIZEOF function returns the size of the given segment or section. The return value is the size in bytes.
Prototype
SIZEOF(segmentName | sectionName)
SIZEOFW
The SIZEOFW function returns the size of the given segment or section. The return value is the size in words.
Prototype
SIZEOFW(segmentName | sectionName)
281
ELF Linker
Linker Command File Keyword Listing
WRITEB
The WRITEB command inserts a byte of data at the current address of a section.
Prototype
WRITEB (expression); expression is any expression that returns a value 0x00 to 0xFF.
WRITEH
The WRITEH command inserts two bytes of data at the current address of a section.
Prototype
WRITEH (expression); expression is any expression that returns a value 0x0000 to 0xFFFF.
WRITES
The WRITES command is a string of variables with maximum length of 255 characters. You can use DATE and TIME in conjunction with the WRITES command. DATE returns the current date as a C string (must be within parentheses). TIME returns the current time as a C string (must be within parentheses).
Prototype
WRITES (string); string is any string within parentheses.
Examples
WRITES ("Hello World"). WRITES ("Today is" DATE). WRITES ("The time is " TIME).
282
ELF Linker
Sample M56800 Linker Command File
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.
283
ELF Linker
Sample M56800 Linker Command File # dynamic data --> external xRAM
# stack size is set to 0x1000 for external RAM LCF # requirements: Mode 3 and EX=0 # note -- there is a mode OB but any Reset or COP Reset # resets the memory map back to Mode 0A.
# DSP56805EVM eval board settings: # OFF --> jumper JG7 (mode 0 upon exit from reset) # ON --> jumper JG8 (enable external board SRAM) # CodeWarrior debugger Target option settings # OFF --> "Use Hardware Breakpoints" # ON --> "Debugger sets OMR at Launch" option # note: with above option on, CW debugger sets OMR as # OMR: # 0 --> EX bit (stay in Debug processing state) # 1 --> MA bit # 1 --> MB bit
# 56805 # mode 3 (development) # EX = 0 MEMORY { .p_interrupts_RAM .p_external_RAM .x_compiler_regs_iRAM .x_internal_RAM .x_reserved .x_peripherals .x_flash_ROM .x_external_RAM .x_core_regs }
: : : : : : : : :
= = = = = = = = =
= = = = = = = = =
284
ELF Linker
Sample M56800 Linker Command File KEEP_SECTION{ interrupt_vectors.text }
# place all executing code & data in external memory SECTIONS { interrupt_vectors_for_p_ram :{ (interrupt_vectors.text) } > .p_interrupts_RAM # from 56805_vector.asm *
285
ELF Linker
Sample M56800 Linker Command File __bss_end = .; __bss_size = __bss_end - __bss_start;
# setup the heap address __heap_addr = .; __heap_size = 0x1000; # larger heap for hostIO __heap_end = __heap_addr + __heap_size; . = __heap_end;
# setup the stack address _min_stack_size = 0x0200; __stack_addr = __heap_end; __stack_end = __stack_addr + _min_stack_size; . = __stack_end; # set global vars # MSL uses these globals: F_heap_addr = __heap_addr; F_heap_end = __heap_end; F_stack_addr = __stack_addr;
next not used in this LCF we define anyway so init code will link these can be removed with removal of rom-to-ram copy code in init file
F_data_size = 0x0000; F_data_RAM_addr = 0x0000; F_data_ROM_addr = 0x0000; F_rom_to_ram = 0x0000; # zero is no rom-to-ram copy
286
ELF Linker
Sample M56800 Linker Command File } > .x_external_RAM }
# ------------------------------------------------------# additional notes: # about the reserved sections # for this external RAM only LCF: # # # # p_interrupts_RAM -- reserved in external pRAM memory space reserved for interrupt vectors interrupt vectors must start at address zero interrupt vector space size is 0x80
# x_compiler_regs_iRAM -- reserved in internal xRAM # The compiler uses page 0 address locations 0x30-0x40 # as register variables. See the Target manual for more info.
# # # #
notes: program memory (p memory) (RWX) read/write/execute for pRAM (RX) read/execute for flashed pROM
# data memory (X memory) # (RW) read/write for xRAM # (R) read for data flashed xROM # LENGTH = next start address - previous # LENGTH = 0x0000 means use all remaining memory
287
ELF Linker
Sample M56800 Linker Command File
288
13
Command-Line Tools
This chapter contains the following sections: Usage on page 289 Response File on page 290 Sample Build Script on page 291 Arguments on page 291
Usage
To call the command-line tools, use the following format: Table 13.1 Format Tools
Compiler Linker Assemble r
File Names
mwcc56800.exe mwld56800.exe mwasm56800.exe
Format
compiler-options [linker-options] file-list linker-options file-list assembler-options file-list
The compiler automatically calls the linker by default and any options from the linker is passed on by the compiler to the assembler. However, you may choose to only compile with the c flag. In this case, the assembler will only assemble and will not call the linker. Also, available are environment variables. These are used to provide path information for includes or libraries, and to specify which libraries are to be included. You can specify the variables listed in Table 13.2 on page 290.
289
Command-Line Tools
Response File
Library
MWCM56800Includes
Description
Similar to Access Paths panel; separate paths with ; and prefix a path with + to specify a recursive path Similar to MWC56800Includes
Linker
MW56800Libraries
List of library names to link with project; separate with ; (similar to MWC56800Includes)
These are the target-specific variables, and will only work with the DSP56800 tools. The generic variables MWCIncludes, MWLibraries, MWLibraryFiles, and MWAsmIncludes apply to all target tools on your system (such as Windows). If you only have the DSP56800 tools installed, then you may use the generic variables if you prefer.
Response File
In addition to specifying commands in the argument list, you may also specify a response file. A response files filename begins with an @ (for example, @file), and the contents of the response file are commands to be inserted into the argument list. The response file supports standard UNIX-style comments. For example, the response file @file, contain the following: # Response file @file -o out.elf # change output file name to out.elf -g # generate debugging symbols The above response file can used in a command such as: mwcc56800 @file main.c It would be the same as using the following command: mwcc56800 o out.elf g main.c
290
Command-Line Tools
Sample Build Script
REM *** set GUI compiler path *** set COMPILER={path to compiler} REM set set set *** set includes path *** MWCIncludes=+%COMPILER%\M56800 Support MWLibraries=+%COMPILER%\M56800 Support MWLibraryFiles=MSL C 56800.lib;FP56800.lib
REM *** add CLT directory to PATH *** set PATH=%PATH%;%COMPILER%\DSP56800_EABI_Tools\Command_Line_Tools\ REM set set set set *** compile options and files *** COPTIONS=-O3 CFILELIST=file1.c file2.c LOPTIONS=-m FSTART_ -o output.elf -g LCF=linker.cmd
REM *** compile, assemble and link *** mwcc56800 %COPTIONS% %CFILELIST% mwasm56800 %AFILELIST% mwld56800 %LOPTIONS% %LFILELIST% %LCF%
Arguments
General Command-Line Options
---------------------------------------------------------------------General Command-Line Options All the options are passed to the linker unless otherwise noted. Please see '-help usage' for details about the meaning of this help. ----------------------------------------------------------------------help [keyword[,...]] # global; for this tool; # display help 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 291
Command-Line Tools
Arguments usage [no]spaces all [no]normal [no]obsolete [no]ignored [no]deprecated [no]meaningless [no]compatible opt[ion]=name # # # # # # # # # # # # search=keyword # # # # # # tool=keyword[,...] # # all # this # # other|skipped # both # # # -version # # -timing # -progress # -v[erbose] # # -search # # # # # # -[no]wraplines # -maxerrors max # # # -maxwarnings max # group=keyword show usage information insert blank lines between options in printout show all standard options show only standard options show obsolete options show ignored options show deprecated options # show options meaningless for this target show compatibility options # show help for a given option; for 'name', maximum length 63 chars # show help for an option whose name or help contains 'keyword' (case-sensitive);
for 'keyword', maximum length 63 chars show help for groups whose names contain 'keyword' (case-sensitive); for 'keyword' maximum length 63 chars categorize groups of options by tool; default show all options available in this tool show options executed by this tool default show options passed to another tool show options used in all tools
global; for this tool; show version, configuration,and build date global; collect timing statistics global; show progress and version global; verbose information; cumulative; implies -progress global; search access paths for source files specified on the command line; may specify object code and libraries as well; this option provides the IDE's 'access paths' functionality global; word wrap messages; default specify maximum number of errors to print, zero means no maximum; default is 0 specify maximum number of warnings to
292
Command-Line Tools
Arguments # print, 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 # -[no]stderr # global; use separate stderr and # stdout streams; # if using -nostderr, stderr goes # to stdout Compiler ---------------------------------------------------------------Preprocessing, Precompiling, and Input File Control Options ----------------------------------------------------------------c # global; compile only, do not link -[no]codegen # global; generate object code -[no]convertpaths # global; interpret #include filepaths # specified for a foreign operating system; # i.e., <sys/stat.h> or <:sys:stat.h>; when # enabled, # '/' and ':' will separate directories and # cannot be used in filenames (note: this is # not a problem on Win32, since these # characters are already disallowed in # filenames; it is safe to leave the option # 'on'); default -cwd keyword # specify #include searching semantics: # before # searching any access paths, the path # specified by this option will be searched proj # begin search in current working directory; # default source # begin search in directory of source file explicit # no implicit directory; only search '-I' or # '-ir' paths include # begin search in directory of referencing # file # -D+ | -d[efine # cased; define symbol 'name' to 'value' if name[=value] # specified, else '1' -[no]defaults # global; passed to linker; # same as '-[no]stdinc'; default -dis[assemble] # global; passed to all tools; # disassemble files to stdout -E # global; cased; preprocess source files -EP # global; cased; preprocess and strip out -msgstyle keyword mpw std gcc IDE parseable
293
Command-Line Tools
Arguments # line # directives -enc[oding] keyword# specify default source encoding; compiler # will automatically detect UTF-8 header or # UCS-2/UCS-4 encodings regardless of setting [no]ascii # ASCII; default [no]autodetect | # scan file for multibyte_encoding (slower) [no]multibyte # [no]mb # [no]ascii # ASCII; [no]system # use system locale [no]UTF[8|-8] # UTF-8 [no]SJIS | # shift-JIS [no]Shift-JIS | # [no]ShiftJIS # [no]EUC[JP|-JP] # EUC-JP [no]ISO[2022JP| # ISO-2022-JP -2022-JP] # -ext extension # global; specify extension for generated # object # files; with a leading period ('.'), appends # extension; without, replaces source file's # extension; for 'extension', maximum length 14 # chars; default is none -gccinc[ludes] # global;adopt GCC #include semantics:add '# I paths to system list if '-I-' is not # specified, and search directory of # referencing file first for #includes (same # as'-cwd include') # global; change target for '-I' # access paths to # the system list; implies '-cwd explicit'; # while compiling, user paths then system # paths # are searched when using # '#include "..."; only # system paths are searched with '#include # <...>' # global; cased; append access path to include list(see '-gccincludes' and '-I-' prefix text file or precompiled header onto all source files global; append a recursive access path to current #include list global; keep object files generated after
-i- | -I-
294
Command-Line Tools
Arguments # # after # # # # # # # # # # # # # link stage; objects are always kept when compiling global; cased; scan source files for dependencies and emit Makefile, do not generate object code global; cased; like -M, but do not list system include files global; cased; like -M, but write dependency map to a file and generate object code global;cased; like -MD, but do not list system include files global;scan source files for dependencies invoking linker; if disabled, intermediate object files are temporary and deleted
-M
-MM
# emit Makefile, do not generate object #continue working after errors in earlier
# global; compile only, do not link # do not precompile any files based on the # filename extension -nosyspath # global; treat #include <...> like #include #"..."; always search both user and system # path lists -o file|dir # specify output filename or directory for # object # file(s) or text output, or output filename # for linker if called -P # global; cased; preprocess and send output to # file; do not generate code -precompile file|di#generate precompiled header from source; # write # header to 'file' if specified, or put header # in 'dir'; if argument is "", write header # # # # # source-specified location; if neither is defined, header filename is derived from source filename; note: the driver can tell whether to precompile a file based on its extension; '-precompile file source' then
to
is # the same as '-c -o file source' -preprocess # global; preprocess source files -ppopt keyword[,...] # specify options affecting the preprocessed # output [no]break # emit file/line breaks; default
295
Command-Line Tools
Arguments [no]line [no]full[path] [no] pragma [no comment] [no] space -prefix file emit #line directives, else comments emit full path of file, else base filename # keep #pragma directives, else strip them; # default # keep comments, else strip them # keep whitespace, else strip it # # prefix text file or precompiled header # onto all # source files # global; cased; passed to all tools; # disassemble and send output to file # global; use standard system include paths # (specified by the environment variable # %MWCIncludes%); added after all system '# #
-S -[no]stdinc
I' # paths; default -U+ | -u[ndefine] name # cased; undefine symbol 'name' ---------------------------------------------------------------------Front-End C/C++ Language Options ----------------------------------------------------------------------ansi keyword # specify ANSI conformance options, # overriding the given settings off # same as '-stdkeywords off', '-enum min', # and '-strict off'; default on|relaxed # same as '-stdkeywords on', '-enum min', # and '-strict on' strict # same as '-stdkeywords on', '-enum int', # and '-strict on' # -ARM on|off # check code for ARM (Annotated C++ Reference # Manual) conformance; default is off -bool on|off # enable C++ 'bool' type, 'true' and 'false' # constants; default is off -char keyword # set sign of 'char' signed # chars are signed; default unsigned # 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
296
Command-Line Tools
Arguments ec++ # # # # # # # # # # # generate warnings for use of C++ features outside Embedded C++ subset (implies 'dialect cplus') dialect cplus) compile with c99 extensions specify word size for enumeration types use minimum sized enums; default use int-sized enums control legacy (non-standard) for-scoping # behavior; when enabled, varaibles # declared in for loops are visible # to the enclosing scope; when disabled, # such variables are scoped to the # only; default is off # specify an on/off compiler #pragma; # -flag foo is the same as #pragma # foo on # -flag no-foo is the same as # foo off; use -pragma option for other cases specify inline options # turn on inlining for 'inline' # functions; # default # turn off inlining # auto-inline small functions (without # 'inline' explicitly specified) # do not auto-inline; default # turn on aggressive inlining: same as # '-inline on, auto' # defer inlining until end of compilation #unit; this allows inlining of functions # # # both directions # cased; inline functions up to 'n' levels #deep; level 0 is the same as '-inline # for 'n', range 0 - 8 # inline bootom-up, starting from # leaves of the call graph rather # than the top-level funcion; default # #enable ISO C++ template parser (note: # requires a different MSL C++ library);
#pragma
297
Command-Line Tools
Arguments # default is off # reverse mapping of '\n' and '\r' so that # '\n'==13 and '\r'==10 (for Macintosh # # # # # # # # compatability) [dis]allow Microsoft VC++ extensions enable extensions: redefining macros, allowing XXX::yyy syntax when declaring method yyy of class XXX, allowing extra commas, ignoring casts to the same type, treating function types with equivalent # parameter lists but different return
types # as equal, # allowing pointer-to-integer # conversions, # and various syntactical differences # disable extensions; default on non-x86 # targets # # enable multi-byte character encodings
off
-[no]multibyte[aware] for -once more -pragma -r[equireprotos] -relax_pointers -RTTI on|off C++); -som implementation -som_env_check new
# source text, comments, and strings # prevent header files from being processed # than once # define a pragma for the compiler such as # "#pragma ..." # require prototypes # relax pointer type-checking rules # select run-time typing information (for # default is on # enable Apple's Direct-to-SOM # enables automatic SOM environment and
# allocation checking; implies -som -stdkeywords on|off # allow only standard keywords; default is off -str[ings] keyword[,...] # specify string constant options [no]reuse # reuse strings; equivalent strings are the # same object; default [no]pool # pool strings into a single data object [no]readonly # make all string constants read-only
298
Command-Line Tools
Arguments # # specify ANSI strictness checking; default # off # enable recognition of trigraphs; default is # enable wchar_t as a built-in C++ type; # is on
---------------------------------------------------------------------Optimizer Options Note that all options besides '-opt off|on|all|space|speed|level=...' are for backwards compatibility; other optimization options may be superceded by use of '-opt level=xxx'. ----------------------------------------------------------------------O # same as '-O2' -O+keyword[,...] # 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[,...] # specify optimization options off|none # suppress all optimizations; default on # same as '-opt level=2' all|full # same as '-opt speed, level=4' [no]space # optimize for space [no]speed # optimize for speed l[evel]=num # set optimization level: # level 0: no optimizations # # level 1: global register allocation, # peephole, dead code elimination # # level 2: adds common subexpression # elimination and copy propagation # # level 3: adds loop transformations,
299
Command-Line Tools
Arguments # # # # # # # [no]cse [no]commonsubs [no]deadcode [no]deadstore [no]lifetimes [no]loop[invariants] [no]prop[agation] # assignments [no]strength # multiplication [no]dead display|dump strength reduction, loop-invariant code motion level 4: adds repeated common subexpression elimination and loop-invariant code motion ; for 'num', range 0 - 4; default is 0 common subexpression elimination
# # # removal of dead code # removal of dead assignments # computation of variable lifetimes # removal of loop invariants propagation of constant and copy strength reduction; reducing # # # # # #
by an index variable into addition same as '-opt [no]deadcode' and '-opt [no]deadstore' display complete list of active optimizations
---------------------------------------------------------------------DSP M56800 CodeGen Options ---------------------------------------------------------------------[no]DO # for this tool; # specify hardware DO loops [no]segchardata # for this tool; # segregate character data [no]asmout # for this tool; # assembly file output [no]peep # for this tool; # active peepholer; [no]NDelay # for this tool; # adjust for delayed load of N register; [no]sched # for this tool; # activate scheduler [no]REP # for this tool; # specify REP instruction [no]cmp32 # for this tool; # emit 32-bit compare; [no]rodata # for this tool; # write constant data to .rodata section; ----------------------------------------------------------------------
300
Command-Line Tools
Arguments Debugging Control Options ----------------------------------------------------------------------g # global; cased; generate debugging information; # same as '-sym full' -sym keyword[,...] # global; specify debugging options off # do not generate debugging information; # default on # turn on debugging information full[path] # store full paths to source files # ---------------------------------------------------------------------C/C++ Warning Options ----------------------------------------------------------------------w[arn[ings]] # global; for this tool; keyword[,...] # warning options off # passed to all tools; # turn off all warnings on # passed to all tools; # turn on most warnings [no]cmdline # passed to all tools; # command-line driver/parser warnings [no]err[or] | # passed to all tools; [no]iserr[or] # treat warnings as errors all #turn on all warnings, require prototypes [no]pragmas | # illegal #pragmas [no]illpragmas # [no]empty[decl] # empty declarations [no]possible | # possible unwanted effects [no]unwanted # [no]unusedarg # unused arguments [no]unusedvar # unused variables [no]unused # same as -w [no]unusedarg,[no]unusedvar [no]extracomma | # extra commas [no]comma # [no]pedantic | # pedantic error checking [no]extended # [no]hidevirtual | # hidden virtual functions [no]hidden[virtual] # [no]implicit[conv] # implicit arithmetic conversions # warn impl_float2int, # impl_signedunsigned [no]impl_int2float # implicit integral to floating # conversions [no]impl_float2int # implicit floating to integral
301
Command-Line Tools
Arguments # conversions [no]impl_signed unsigned # implicit signed/unsigned conversions # [no]notinlined # 'inline' functions not inlined [no]largeargs # passing large arguments to unprototyped # functions [no]structclass #inconsistent use of 'class' and # 'struct' [no]padding # padding added between struct members [no]notused #result of non-void-returning function # not used [no]missingreturn # return without a value in a # non-void-returning function [no]unusedexpr #use of expressions as statements #without side effects [no]ptrintconv # lossy conversions from pointers to #integers, and # vice versa [no]anyptrintconv #any conversions from pointers to integers [no]undef[macro] #use of undefined macros in #if/#elif #conditionals [no]filecaps #incorrect capitalization used in #include... [no]sysfilecaps #incorrect capitalization used in #include<...> [no]tokenpasting #token not formed by ## operator display|dump # display list of active warnings #
Linker
---------------------------------------------------------------------Command-Line Linker Options
-lr path
# global; disassemble object code and do not # link; implies '-nostdlib' # global; cased; add library search path; default # is to search current working directory and # then system directories (see '-defaults'); # search paths have global scope over the # command line and are searched in the order # given # global; like '-l', but add recursive library
302
Command-Line Tools
Arguments # search path # cased; add a library by searching access paths # for file named lib<file>.<ext> where <ext> # # # # # # # # # # # a typical library extension; added before system libraries (see '-defaults') global; same as -[no]stdlib; default continue importing or disassembling after errors in earlier files global; use system library access paths (specified by %MWLibraries%) and add system libraries (specified by %MWLibraryFiles%); default global; cased; disassemble and send output to file; do not link; implies '-nostdlib'
-l+file is
-S
---------------------------------------------------------------------ELF Linker Options ----------------------------------------------------------------------[no]dead[strip] # enable dead-stripping of unused code; default -force_active # specify a list of symbols as undefined; useful symbol[,...] # to force linking of static libraries # -keep[local] on|off # keep local symbols (such as relocations and # output segment names) generated during link; # default is on -m[ain] symbol # set main entry point for application or shared # library; use '-main ""' to specify no entry # point; for 'symbol', maximum length 63 chars; # default is 'FSTART_' -map [keyword[,...]] # generate link map file closure # calculate symbol closures unused # list unused symbols # -sortbyaddr # sort S-records by address; implies '-srec' -srec # generate an S-record file; ignored when # generating static libraries -sreceol keyword # set end-of-line separator for S-record file; # implies '-srec' mac # Macintosh ('\r') dos # DOS ('\r\n'); default unix # Unix ('\n') # -sreclength length # specify length of S-records (should be a
303
Command-Line Tools
Arguments # 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
-usebyteaddr -o file
---------------------------------------------------------------------DSP M56800 Project Options ----------------------------------------------------------------------application # global; generate an application; default -library # global; generate a static library ---------------------------------------------------------------------DSP M56800 CodeGen Options ----------------------------------------------------------------------ldata | -largedata # data space not limited to 64K ---------------------------------------------------------------------Linker C/C++ Support Options
----------------------------------------------------------------------Cpp_exceptions on|off # enable or disable C++ exceptions; # default is on -dialect | -lang keyword # specify source language c # treat source as C++ unless its # extension is # '.c', '.h', or '.pch'; default c++ # treat source as C++ always # ---------------------------------------------------------------------Debugging Control Options
----------------------------------------------------------------------g # global; cased; generate debugging information; # same as '-sym full' -sym keyword[,...] # global; specify debugging options off # do not generate debugging information; # default on # turn on debugging information full[path] # store full paths to source files # ----------------------------------------------------------------------
304
Command-Line Tools
Arguments Warning Options ----------------------------------------------------------------------w[arn[ings]] # global; warning options keyword[,...] # off # turn off all warnings on # turn on all warnings [no]cmdline # command-line parser warnings [no]err[or] | # treat warnings as errors [no]iserr[or] # display|dump # display list of active warnings # ---------------------------------------------------------------------ELF Disassembler Options ----------------------------------------------------------------------show keyword[,...] # specify disassembly options only|none # as in '-show none' or, e.g., # '-show only,code,data' all # show everything; default [no]code | [no]text # show disassembly of code sections; default [no]comments # show comment field in code; implies 'show # code'; default [no]extended # show extended mnemonics; implies 'show # code'; default [no]data # show data; with '-show verbose', show hex # dumps of sections; default [no]debug | [no]sym # show symbolics information; default [no]exceptions # show exception tables; implies '-show data'; # default [no]headers # show ELF headers; default [no]hex # show addresses and opcodes in code # disassembly; implies '-show code'; default [no]names # show symbol table; default [no]relocs # show resolved relocations in code and # relocation tables; default [no]source # show source in disassembly; implies 'show # code'; with '-show verbose', displays # entire source file in output, else shows # only four lines around each function; # default
305
Command-Line Tools
Arguments [no]xtables [no]verbose dump # applications; # # default of program segments in # show exception tables; default show verbose information, including hex
Assembler
---------------------------------------------------------------------Assembler Control Options ----------------------------------------------------------------------[no]case # identifiers are case-sensitive; default -[no]debug # generate debug information -[no]macro_expand # expand macro in listin output -[no]assert_nop # add nop to resolve pipeline dependency; default -[no]warn_nop # emit warning when there is a pipeline # dependency -[no]warn_stall # emit warning when there is a hardware stall -[no]legacy # allow legacy DSP56800 instructions(imply # data/prog 16) -[no]debug_workaround # Pad nop workaround debuggin issue in some # implementation; default -data keyword # data memory compatibility 16 # 16 bit; default 24 # 24 bit # -prog keyword # program memory compatibility 16 # 16 bit; default 19 # 19 bit 21 # 21 bit # ----------------------------------------------------------------------
306
14
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 code. This chapter explains how to use these libraries for DSP56800 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. This chapter contains the following sections: MSL for DSP56800 on page 307 Runtime Initialization on page 311
307
MSL C 56800.lib
This library provides standard C library support without standard I/O. A minimal "thin" printf is provided but other stdio is stripped out in order to maximize performance. The printf sends characters to the CodeWarrior console window via the debugger. Use this library when you need minimal printf support for debugging and saving space.
308
NOTE
Binary and text files are handled differently because DSP56800 char (character) is 16-bits and x86 host char is 8-bits. Text file I/O operations are 1-to-2 mapping. Binary file I/O operations are 1-to-1 mapping. Files are created with fopen on the host machine as shown in Table 14.2 on page 309. Table 14.2 Host File Creation Location file opened as
text binary
host elements
8-bit 16-bit
target elements
16-bit 16-bit
309
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. M56800 uses a 16bit-wide stack.
Heap
Heap is an area of memory reserved for temporary dynamic memory allocation and access. MSL uses this space to provide heap operations such as malloc. M56800 does not have an operating system (OS), but MSL effectively synthesizes some OS services such as heap operations.
BSS
BSS is memory space reserved for uninitialized data. The compiler will put all uninitialized data here. The stationery init code zeroes this area at startup. See the 56824_init.c (startup) code example code in this chapter for general information and the stationery init code files for specific target implementation details. NOTE Instead of accessing the original Stationery files themselves (in the Stationery folder), create a new project using Stationery (see Creating a Project) which will make copies of the specific target board files such as the LCF.
Address
The start address of the stack The size of the heap
310
Address
The start address of the heap The end address of the heap Start address of memory reserved for uninitialized variables End address of BSS
Runtime Initialization
The default init function is the bootstrap or glue code that sets up the DSP56800 environment before your code executes. This function is in the init file for each boardspecific stationery project. The routines defined in the init file performs other tasks such as clearing the hardware stack, creating an interrupt table, and retrieving the stack start and exception handler addresses. The default code in the init function also sets the addressing mode in the modifier register (M01) to 0xFFFF. The final task performed by the init function is to call the main() function. The starting point for a program is set in the Entry Point field in the M56800
/* 56803_init.c Metrowerks, a Freescale Company 56800/E Digital Signal Controllers: DSP56F80x/DSP56F82x Targeting Manual 311
#include "DSP56F803_init.h"
//
312
// set frame pointer to main stack top // set stack pointer too
// setup the PLL (phase locked loop) move core move move #pllcr_init,x:PLLCR // set lock detector on and choose //clock // set to max freq // set x0 with timeout value // timeout handles simulator case // loop until PLL is locked // or we reach timeout limit // decrement our timeout value // test for zero // if timed-out, proceed anyway
#plldb_init,x:PLLDB #wait_lock,x0
pll_test_lock:
decw x0 tstw x0 beq pll_timeout brclr #pllsr_init,x:PLLSR,pll_test_lock pll_timeout: // pll locked move #pllcr_proceed,x:PLLCR move x:PLLSR,x0 interrupts move x0,x:PLLSR
// set lock detector on, choose // PLL clock // clear pending clkgen
// setup exception handler and interrupt levels move M56803_int_Addr,r1 // address push r1 // establish exception handler bfset #$0100,sr // enable all levels of interrupts bfclr #$0200,sr // allow IPL 0 interrupts
// xrom-to-xram option move tstw beq move move -#_rom_to_ram,r0 r0 end_rom2ram #_data_size,r2 #_data_ROM_addr,r3 // check for option
313
// clear bss always move #0,x0 move #_bss_size,r2 move #_bss_addr,r1 do r2,end_bss_clear move x0,x:(r1)+ nop end_bss_clear: // // // // // set x0 to zero set bss size dest address -- bss data start do for r2 times stash zero at address
// call main() move #M56803_argc,y0 move #M56803_argv,r2 move #M56803_arge,r3 jsr main jsr fflush debug rts } The startup folder includes the following: Stack setup PLL setup Exception handler and interrupt setup BSS zeroing Static initialization Jump to main NOTE
The original general-purpose runtime init code (FSTART) remains in the M56800 support library to provide compatibility for older projects. The MSL runtime project is: CodeWarrior\56800
314
315
316
15
Troubleshooting
This chapter explains common problems encountered when using the CodeWarrior IDE for DSP56800, and their possible solutions.
Troubleshooting Tips
This chapter contains the following sections: The Debugger Crashes or Freezes When Stepping Through a REP Statement on page 318 "Cant Locate Program Entry On Start" or "Fstart.c Undefined" on page 318 When Opening a Recent Project, the CodeWarrior IDE Asks If My Target Needs To Be Rebuilt on page 318 "Timing values not found in FLASH configuration file. Please upgrade your configuration file. On-chip timing values will be used which may result in programming errors" IDE Closes Immediately After Opening on page 319 Errors When Assigning Physical Addresses With The Org Directive on page 319 on page 319The Debugger Reports a Plug-in Error on page 319 Windows Reports a Failed Service Startup on page 320 No Communication With The Target Board on page 320 Downloading Code to DSP Hardware Fails on page 321 The CodeWarrior IDE Crashes When Running My Code on page 321 The Debugger Acts Strangely on page 321 Problems With Notebook Computers on page 322 If you are having trouble with CodeWarrior Development Studio for Freescale 56800 and this section does not help you, e-mail technical support at: [email protected]
317
Troubleshooting
Troubleshooting Tips
When Opening a Recent Project, the CodeWarrior IDE Asks If My Target Needs To Be Rebuilt
If you open a recent project file and then select Project > Debug from the menu bar of the Freescale CodeWarrior window, the dialog box shown in Figure 15.1 on page 318 appears: Figure 15.1 Rebuild Alert
318
Troubleshooting
Troubleshooting Tips This dialog box informs you that the software determines if your object code needs to be rebuilt. If you have made no changes since the last build, the CodeWarrior IDE does not change your object file when you select the Build option.
"Timing values not found in FLASH configuration file. Please upgrade your configuration file. On-chip timing values will be used which may result in programming errors"
This indicates you have an old flash configuration file that does not include timing information. If you continue to use this file, it could result in programming errors and a shorter life for the flash memory. To upgrade your flash configuration file, replace the existing flash configuration file with the flash configuration file from the M56800 Support. The flash configuration file is located in the following directory: CodeWarrior\M56800 Support\initialization
319
Troubleshooting
Troubleshooting Tips Verify that power is being supplied to the DSP hardware.
If you see the above message box, check the following: Ensure that you have not selected a conflicting address for use with the DSP hardware. The Resources Manager can help you determine whether or not there is a conflict. Check input/output addresses according to the operating system you are using: Windows 98 1. To access the Resources Manager, open the Control Panel and click the Device Manager tab. 2. Click Properties to display the Computer Properties window. 3. Click the View Resources tab in the Computer Properties window. 4. Click the Input/Output radio button to view all active input/output addresses. Windows NT 1. To access the Resources Manager, select Start > Programs > Administrative Tools > Windows NT Diagnostics. 2. Click the Resources tab in the Windows NT Diagnostics window. 3. Click I/O Port at the bottom of the tab to view all currently active input/output addresses.
Troubleshooting
Troubleshooting Tips If you are using the Freescale ADS hardware with the ISA bus interface, ensure that you select the correct I/O address for the ISA card. If you have another device attempting to use this address, you must reconfigure that device to use another address or disable that device. Verify that all the hardware boards have power: A green LED lights up on both the ADS and EVM boards. A red LED and a yellow LED illuminate on the Domain Technologies SB-56K Emulator. Verify that all target settings are correct.
321
Troubleshooting
Troubleshooting Tips
How to make Parallel Port Command Converter work on Windows 2000 Machines
If you encounter problems connecting to your Windows 2000 machine using the parallel port command converter, check the following settings: 1. Verify LPT Port number matches the parallel port: a. Launch CCS. b. Select File > Configure. c. Ensure that the LPT port is set to parallel port and correct LPT number. d. Click Save. 2. Verify Enable legacy Plug and Play is enabled for the parallel port: a. Access the Device Manager. b. Access the LPT port settings window. c. Click the Properties button. d. In the Properties window, click the Enable Legacy Plug and Play box. 3. Verify the parallel port is set for fast bi-directional transfer: a. Access the BIOS settings. b. Set the parallel port for fast bi-directional transfers (EEP or ECP) instead of just bidirectional.
322
A
Porting Issues
This appendix explains issues relating to successfully porting code to the most current version of the CodeWarrior Development Studio for Freescale 56800/E Digital Signal Controllers. This appendix lists issues related to successfully porting sources from the Suite56TM toolset and differences that occur between the CodeWarrior IDE and the Suite56 tools. This appendix contains the following sections: Converting the DSP56800 Projects from Previous Versions on page 323 Removing illegal object_c on pragma directive Warning on page 324 Setting-up Debugging Connections on page 324 Using XDEF and XREF Directives Using the ORG Directive
323
Porting Issues
Removing illegal object_c on pragma directive Warning
324
Porting Issues
Using the ORG Directive You would need to change your ORG directive to: ORG P: and your linker command file would be changed as follows: MEMORY { .text (RWX) : ORIGIN = 0x1000, LENGTH = 0x0 .data (RW) : ORIGIN = 0x2000, LENGTH = 0x0 .text2(RWX) : ORIGIN = 0x20, LENGTH = 0x0 } SECTIONS { .location_specific_code : { . = 0x20; *(myISR_20.text) . = 0x30; *(myISR_30.text) } > .text2 .main_application : { *(.text) *(.rtlib.text) *(fp_engine.text) *(user.text) } > .text .main_application_data : { *(.data) *(fp_state.data) *(rtlib.data) *(rtlib.bss.lo) *(.bss) } > .data
325
Porting Issues
Using the ORG Directive
326
B
DSP56800x New Project Wizard
This appendix explains the high-level design of the new project wizard.
Overview
The DSP56800x New Project Wizard supports the DSP56800x processors listed in Table B.1 on page 327. Table B.1 Supported DSP56800x Processors for the New Project Wizard DSP56800
DSP56F801 (60 MHz) DSP56F801 (80 MHz) DSP56F802 DSP56F803 DSP56F805 DSP56F807 DSP56F826 DSP56F827
DSP56800E
DSP56852 DSP56853 DSP56854 DSP56855 DSP56857 DSP56858 MC56F8013 MC56F8014 MC56F8023 MC56F8025 MC56F8036 MC56F8037 MC56F8122 MC56F8123
327
Wizard rules for the DSP56800x New Project Wizard are described in these sub-sections: Page Rules on page 329 Resulting Target Rules on page 330 on page 331Rule Notes on page 331 Click on the following link for details about the DSP56800x New Project Wizard: DSP56800x New Project Wizard Graphical User Interface on page 332
328
Page Rules
The page rules governing the wizard page flow for the simulator and the different processors are shown in the Table B.2 on page 329, Table B.3 on page 329, Table B.4 on page 330, and Table B.5 on page 330. Table B.2 Page Rules for the Simulator, DSP56F801 (60 and 80 MHz), DSP56F802, MC56F801x, MC56F802x, MC56F803x, MC56F812x, and MC56F832x Target Selection Page
any simulator DSP56F801 60 MHz DSP56F801 80 MHz DSP56F802 MC56F801x MC56F802x MC56F803x MC56F812x MC56F832x
Next Page
Program Choice Page
Next Page
Finish Page
Table B.3 Page Rules for the DSP56F803, DSP56F805, DSP56F807, DSP56F826, and DSP56F827 Target Selection Page
DSP56F803 DSP56F805 DSP56807 DSP56F826 DSP56F827
Next Page
Program Choice Page
Next Page
External/Internal Memory Page
Next Page
Finish Page
329
Table B.4 Page Rules for the DSP56852, DSP56853, DSP56854, DSP56855, DSP56857, and DSP56858 Target Selection Page
DSP56852 DSP56853 DSP56854 DSP56855 DSP56857 DSP56858
Next Page
Program Choice Page
Next Page
Finish Page
Table B.5 Page Rules for the MC56F814x, MC56F815x, MC56F816x, MC56F833x, MC56F834x, MC56F835x, and MC56F836x Target Selection Page
MC56F814x MC56F815x MC56F816x MC56F833x MC56F834x MC56F835x MC56F836x
Next Page
Next Page
Next Page
Finish Page
330
Possible Targets
Target with Non-HostIO Library and Target with Host IO Library Small Data Model and Large Data Model External Memory and/or Internal Memory with pROM-toxRAM Copy External Memory and/or Internal Memory with pROM-toxRAM Copy (Small Data Model and Small Data Model with HSST) or (Large Data Model and Large Data Model with HSST) Small Data Model Internal Memory with pROM-to-xRAM Copy
DSP5682x
DSP5685x
MC56F801x MC56F802x MC56F803x MC56F812x MC56F832x MC56F814x MC56F815x MC56F816x MC56F833x MC56F834x MC56F835x MC56F836x
Small Data Model or Large Data Model Internal Memory with pROM-to xRAM Copy (Small Data Memory External and/or Small Data Memory Internal with pROM-to-xRAM Copy) or (Large Data Memory External and/or Large Data Memory Internal with pROM-to-xRAM Copy)
Rule Notes
Additional notes for the DSP56800x New Project Wizard rules are: The DSP56800x New Project Wizard uses the DSP56800x EABI Stationery for all projects. Anything that is in the DSP56800x EABI Stationery will be in the wizard-created projects depending on the wizard choices. The DSP56800x EABI Stationery has all possible targets, streamlined and tuned with the DSP56800x New Project Wizard in mind.
331
332
333
Target Pages
When invoked, the New Project Wizard first shows a dynamically created list of supported target families or simulators and processors. Each DSP56800x family is associated with a subset of supported processors (Figure B.3 on page 335, Figure B.4 on page 336, Figure B.5 on page 337, Figure B.6 on page 338, Figure B.7 on page 339, Figure B.8 on page 340, Figure B.9 on page 341, Figure B.10 on page 342, and Figure B.11 on page 343).
334
335
336
337
338
339
340
341
342
One target family and one target processor must be selected before continuing to the next wizard page. NOTE Depending on which processor you select, different screens will appear according to the Page Rules on page 329.
If you choose the simulator, then the DSP56800x New Project Wizard - Program Choice page appears.
343
When you click Next, the Wizard jumps to the appropriate page determined by the Page Rules on page 329.
344
When you click Next, the Wizard jumps to the appropriate page determined by the Page Rules on page 329.
345
When you click Next, the Wizard jumps to the appropriate page determined by the Page Rules on page 329.
Finish Page
When you click the Finish button on the Finish Page (Figure B.15 on page 347), the project creation process start. NOTE All target choices end on this page.
346
347
348
Index
Symbols
.elf file, loading 243
Numerics
56800 simulator 240
C
C/C++ warnings panel 7781 calling assembly functions from C code 159 calling conventions for DSP 143 Case Insensitive Identifiers checkbox 83 changing 154 Changing Target Settings 65 char size 138 code compiling 51 deadstripping unused 154 editing 52 navigation 55 code and data storage for DSP 149150 CodeWarrior compiler architecture 35 components 36 debugging for DSP 197 getting started 19 introduction 13 tools, listed 36 troubleshooting 317 tutorial 37, 3761 using the debugger 52 using the IDE 37 CodeWarrior IDE 14 installing 24 installing and registering 20 introduction 13 CodeWarrior IDE Target Settings Panels 67 command converter server 207, 214 commands Add Files 52 Bring Up To Date 34 Compile 34 Enable Debugger 36 M56800 Settings 52 349
A
__abs 166 Access Paths panel 68 access permission flags 264, 278 __add 167 Add Files command 52 add_hfm_unit flash debugger command 250 adding assembly language 157 addr 275 after 278 align 276 alignall 276 alignment 266 Allocating Memory and Heaps for DSP56800 309 Allow DO Instructions option 87 Allow Rep Instructions checkbox 87 Application option, of Project Type pop-up menu 71 asm keyword 156 assembly language 155 create output option 87 statements, adding 157 AT keyword for ROM location 271 Auto-clear previous breakpoint on new breakpoint release 94, 99
B
back-end compiler See compiler bean inspector window 105, 110, 112 bean selector window 104, 109110 bool size 138 bootstrap code 311 breakpoints 56, 217 Bring Up To Date command 34
Make 36 Preprocess 36 comments for linker command file 267 communications with target board, problems 320 Compile command 34 compiler architecture 35 back-end for DSP 137 intermediate representation (IR) 35 plug-in modules, explained 35 support for inline assembly 155 See also C Compilers Reference compiling 34 code 51 See also IDE User Guide compress 279 connection type 200 Console 307 Console and File I/O 307 converting CodeWarrior projects 323 core tools, tutorial 3761 CPU types overview window 119 Create Assembly Output checkbox 87 creating labels for DSP56800 Assembly 158 Custom Keywords settings panel 68 Cycle/Instruction Count 241
D
Data Visualization 255 data, deadstripping unused 154 deadstripping prevention 264, 267 deadstripping unused code and data 154 debug information, generating 50 debugger command converter server 207, 214 fill memory 228, 230 Kill command 61 load/save memory 225, 228 OnCE features 232 operating 214, 219 problems with behavior 321 save/restore registers 230232 setting preferences 52 350
setting up for Flash programming 251 system level connect 244, 245 toolbar 55 using 52 debugger protocol 200 Debugger Settings panel 68 debugging 36, 197 connecting to a loaded target 245 flash memory 249 per file 50 projects 53 supported remote connections 197205 target settings 207 watchpoint status 232 See also IDE User Guide Debugging a loaded target 245 defining an inline assembly function 157 definition BSS 310 heap 310 stack 310 development tools 36 dialog boxes fill memory 228, 230 load/save memory 225, 228 save/restore registers 230232 Directive XDEF 324 directories, installation 24 Disable Deadstripping checkbox 90 __div 178 __div_ls 179 DO instructions, allowing 87 Domain Technologies SB-56K installing 27 double size 139 downloading code, problems 321 DSP code and data storage 149150 installing hardware 24 linker 154 DSP hardware system requirements 19 DSP56800
calling conventions 139 fixed-point formats 139 floating-point formats 138 integer formats 137 stack frame 143
E
editing code 34 project contents 52 source files 52 See also IDE User Guide editor, of IDE 52 ELF Disassembler settings panel 83 Show Addresses and Object Code checkbox 85 Show Code Modules checkbox 85 Show Comments checkbox 85 Show Data Modules checkbox 85 Show Debug Info checkbox 86 Show Headers checkbox 84 Show Relocations checkbox 84 Show Source Code checkbox 85 Show Symbol and String Tables checkbox 84 Use Extended Mnemonics checkbox 85 Verbose Info checkbox 84 Enable Debugger command 36 enabling the debugger 50 Exporting and importing panel options to XML Files 66 expressions, in LCF 269 __extract_h 176 __extract_l 177
__fixed2short 172 fixed-point formats, for DSP 56800 139 fixed 139 long fixed 139 short fixed 139 fixed-point formats, for DSP 56800short fixed 139 flash configuration file format 99 flash debugger commands add_hfm_unit 250 set_hfm_base 250 set_hfm_config_base 250 set_hfm_erase_mode 250 set_hfm_verify_erase 251 set_hfm_verify_program 251 set_hfmclkd 249 flash memory debugging 249 Flash ROM debugger configuration 251 initializing variables in P or X memory 271 programming tips 253 ROM to RAM copy 271273 float size 138 floating-point formats, for DSP 56800 138 Force Active Symbols text box 92 force_active 264, 267, 277 format, flash configuration file 99 fractional arithmetic 163 equation for converting 163 Freescale Documentation 17 FSTART troubleshooting entry point 318 fstart 311
G
Generate ELF Symbol Table checkbox 91 Generate Link Map checkbox 89 Generate Listing File checkbox 83 Generate S-Record File checkbox 91 Generate Symbolic Info checkbox 88 generating debug info 50 GLOBAL directive 324 GLOBAL directive, assembly function definitions 160 351
F
F 268 failed service startup in Windows 320 File Mappings panel 68 fill memory dialog box 228, 230 fixed type 139 fixed__ 139 171 __fixed2long 171
Global Optimizations settings panel 68 global variables linker command file 268
H
hardware breakpoints watchpoints 232 heap size 273
I
IDE using 37 IDE, CodeWarrior 14 IDE, installing 24 IDE, installing and registering 20 implied fractional value 163 include 277 inline assembler for DSP 155175 inline assembly defining functions 157 function-level 156 instructions 157 statement-level 157 syntax 156 Inline Assembly Language, general notes 155 installation directories 24 installed beans overview window 120 installing SB-56K Emulator 27 installing and registering the CodeWarrior IDE 20 installing the CodeWarrior IDE 24 Instruction Scheduling checkbox 87 int size 138 __int2fixed 172 integer formats, for DSP56800 137 integral types, in LCF 268 intrinsic functions absolute/negate 166 __abs 166 _L_negate 167 __negate 166 addition/subtraction 167 352
__add 167 _L_add 169 _L_sub 169 __sub 168 control 170 __stop 170 conversion 170 __fixed2int 171 __fixed2long 171 __fixed2short 172 __int2fixed 172 __labs 173 __long2fixed 174 __short2fixed 174 copy 174 __memcpy 175 __strcpy 175 deposit/extract 176 __extract_h 176 __extract_l 177 _L_deposit_h 177 _L_deposit_l 178 division 178 __div 178 __div_ls 179 multiplication/MAC 179 _L_mac 183 _L_msu 184 _L_mult 184 __mac_r 180 __msu_r 181 __mult 181 __mult_r 182 normalization 185 __norm_l 186 __ norm_s 186 rounding 187 __round 187 shifting 188 _L_shl 190 _L_shr 191 _L_shr_r 192 __shl 188 __shr 189
__shr_r 190 multiplication/MAC _L_ mult_ls 185 introduction to CodeWarrior 13 introduction to the CodeWarrior IDE 13
J
JTAG chain, debug other chips 248 JTAG initialization file 247 JTAG initialization file with a generic device 248
K
keep_section 265, 267, 277 Kill command 61
L
_L_add 169 _L_deposit_h 177 _L_deposit_l 178 _L_mac 183 _L_msu 184 _L_mult 184 _L_mult_ls 185 _L_negate 167 _L_shl 190 _L_shr 191 _L_shr_r 192 labels, M56800 assembly 158 __labs 173 libraries MSL for DSP 307 support for DSP 307 using MSL 307 Library option, of Project Type pop-up menu 71 linear addressing 311 link order 154 linker for DSP 154 link order 154 settings 88 linker command files access permission flags 264, 278
addr 275 after 278 align 276 alignall 276 alignment 266 arithmetic operations 266 comments 267 compress 279 deadstripping prevention 267 expressions 269 file selection 270 force_active 277 function selection 270 heap size 273 include 277 integral types 268 keep_section 277 memory 263, 277279 memory attributes 264 object 270, 279 ref_include 279 sections 265, 280 sizeof 281 stack size 273 symbols 268 variables 268 writeb 282 writeh 282 writew 283 writing data 273 Linker pop-up menu 69 linking 36 See also IDE User Guide List Unused Objects checkbox 89 load/save memory dialog box 225, 228 loading .elf file 243 long double size 139 long fixed type 139 long size 138 __long2fixed 174 longfixed__ 139 _L_sub 169
353
M
M01 311 M56800 Assembler settings panel 8283 Case Insensitive Identifiers checkbox 83 Generate Listing File checkbox 83 Prefix File 83 M56800 Linker Disable Deadstripping checkbox 90 Force Active Symbols text box 92 Generate ELF Symbol Table checkbox 91 Generate Symbolic Info checkbox 88 List Unused Objects checkbox 89 Show Transitive Closure checkbox 90 Store Full Path Names checkbox 89 M56800 Linker option, in Linker pop-up menu 70 M56800 Linker settings panel 88 Generate Link Map checkbox 89 Generate S-Record File checkbox 91 Max Record Length field 91 S-Record EOL Character list menu 92 Suppress Warning Messages checkbox 91 M56800 Processor settings panel 8687 Allow DO Instructions 87 Allow Rep Instructions checkbox 87 Create Assembly Output checkbox 87 Instruction Scheduling checkbox 87 Make Strings Read-Only checkbox 87 M56800 Settings command 52 M56800 Target Settings 48, 49, 52 Use Flash Config File option 252 M56800 Target Settings panel 94 M56800 Target settings panel Output File Name 71 Project Type 71 M56800 Target settings panels 70 __mac_r 180 Make command 36 Make Strings Read-Only checkbox 87 makefiles 34 __memcpy 175 memory 277279 P 264 X 264 354
memory map window 117, 119 memory, viewing 219225 Metrowerks Standard Library (MSL) for DSP 307 using 307 modifier register 311 modulo addressing 311 __msu_r 181 __mult 181 __mult_r 182
N
navigating code 55 __negate 166 New Project window 44 New window 42 None option in Post-Linker pop-up menu 70 in Pre-Linker pop-up menu 70 non-volatile registers 140, 151 __norm_l 186 __norm_s 186 number formats, for DSP 137, 139
O
OBJECT 270 object 270, 279 OnCE debugger features 232 operating the debugger 214, 219 optimizing page 0 register assignment 151 ORG directive 160 memory space location 160 Output Directory field 70 overview, target settings 65
P
P memory 264 P memory, viewing 221225 page 0 register assignment 151 non-volatile registers 151 volatile registers 151 panels
C/C++ warnings 7781 remote debug options 99, 100 remote debugging 9294 peripherals usage inspector window 121 plug-in error 319 porting issues 323 Post-Linker option 70 Prefix File 83 Prefix File field 83 Pre-Linker pop-up menu 70 Preprocess command 36 preprocessing 36 See also IDE User Guide Processor Expert beans 103105 code generation 102103 menu 105109 overview 101109 page 103 tutorial 122136 Processor Expert interface 101136 Processor Expert windows 109122 bean inspector 110, 112 bean selector 109110 CPU types overview 119 installed beans overview 120 memory map 117, 119 peripherals usage inspector 121 resource meter 120 target CPU 112117 Project Files versus Makefiles 34 project stationery 41, 44 Project Type pop-up menu 71 Project window 45 projects debugging 53 editing contents of 52 stationery 41, 44 protocols, setting 53
references 17 Freescale Documentation 17 register details window 225, 242 register values 218, 219 registers display contents 56, 58, 60 function parameters 139 non-volatile 140 special-purpose 56, 58, 60 stack pointer 144 volatile 140 regservers.bat 319 remote debug options panel 99, 100 remote debugging panel 9294 rep instruction problems in debugger 318 REP instructions, allowing 87 resource meter window 120 Restoring Target Settings 67 ROM to RAM copy 271273 __round 187 runtime ROM to RAM copy 272 runtime initialization 311
S
Sample Initialization File 311 save/restore registers dialog box 230232 Saving new target settings stationery files 67 SB-56K Emulator, installing 27 SECTION mapping, in assembly language 160 sections 265, 280 segment location specifier 280 set_hflkd flash debugger command 249 set_hfm_base flash debugger command 250 set_hfm_config_base flash debugger command 250 set_hfm_erase_mode flash debugger command 250 set_hfm_verify_erase flash debugger command 251 set_hfm_verify_program flash debugger command 251 355
R
rebuild alert 318 REF_INCLUDE 267 ref_include 265, 267, 279
setting a build target 69 breakpoints 56 debugger preferences 52 settings panels Access Paths 68 Build Extras 68 C/C++ warnings 7781 Custom Keywords 68 Debugger Settings 68 ELF Disassembler 83 File Mappings 68 Global Optimizations 68 M56800 Assembler 8283 M56800 Linker 88 M56800 Processor 8687 M56800 Target 70 M56800 Target Settings 94 remote debug options 99, 100 remote debugging 9294 Source Trees 68 Settings window 47 __shl 188 short double size 138 short fixed type 139 short size 138 __short2fixed 174 Show Addresses and Object Code checkbox 85 Show Code Modules checkbox 85 Show Comments checkbox 85 Show Data Modules checkbox 85 Show Debug Info checkbox 86 Show Headers checkbox 84 Show Relocations checkbox 84 Show Source Code checkbox 85 Show Symbol and String Tables checkbox 84 Show Transitive Closure checkbox 90 __shr 189 __shr_r 190 signed char size 138 simulator 240 sizeof 281 source files editing 52
Source Trees settings panel 68 special-purpose registers 56, 58, 60 S-record 91 S-Record EOL Character list box 92 S-Record, Max Record Length field 91 stack frame, for DSP56800 143 stack pointer register 144 stack size 273 statement-level inline assembly 157 stationery saving new target settings 67 __stop 170 storage of code and data for DSP 149150 Store Full Path Names checkbox 89 __strcpy 175 __sub 168 Suite56 toolset 323 support, web page 35 Suppress Warning Messages checkbox 91 symbols, in LCF 268 syntax, inline assembly language 156 system level connect 244, 245 system requirements for DSP hardware 19
T
target CPU window 112117 Target Name field 69 target settings overview 65 Target Settings panel Linker 69 Output Directory field 70 Post-Linker 70 Pre-Linker 70 Target Name 69 Target Settings panels Access Paths 68 Build Extras 68 Custom Keywords 68 Debugger Settings 68 File Mappings 68 Global Optimizations 68 M56800 Linker 88
356
M56800 Processor 8687 M56800 Target Settings 94 M56800 Target settings 70 Source Trees 68 Target Settings window 47, 66 Troubleshooting Parallel Port Converter on Windows 2000 322 troubleshooting 317322 communications with target board 320 downloading code 321 entry point errors 318 FSTART 318 ORG and memory addresses 319 plug-in error 319 rebuild alert 318 rep instruction and breakpoints 318 tutorial, core tools 3761 tutorial, Processor Expert 122136
W
watchpoint status 232 watchpoints 217 web site 17 Windows failed service startup error 320 windows bean inspector 105, 110, 112 bean selector 104, 109110 CPU types overview 119 installed beans overview 120 memory map 117, 119 peripherals usage inspector 121 Processor Expert 109122 register details 225, 242 resource meter 120 target CPU 112117 writeb 273, 282 writeh 273, 282 writew 273, 283
U
unsigned char size 138 unsigned int size 138 unsigned long size 138 unsigned short size 138 unused code and data, deadstripping 154 Use Extended Mnemonics checkbox 85 Use Flash Config File checkbox 252 using the CodeWarrior debugger 52 the CodeWarrior IDE 37 using comments in M56800 assembly 159
X
X memory 264 X memory, viewing 219221 XDEF directive 324 XML files exporting and importing panel options 66 XREF directive 324
V
values, register 218, 219 variables, in LCF 268 Variables, Stationery Linker Command Files 310 Verbose Info checkbox 84 viewing memory 219225 volatile registers 140, 151 page 0 register assignment 151
357
358