To all our customers Regarding the change of names mentioned in the document, such as Hitachi Electric and Hitachi XX, to Renesas Technology Corp. The semiconductor operations of Mitsubishi Electric and Hitachi were transferred to Renesas Technology Corporation on April 1st 2003. These operations include microcomputer, logic, analog and discrete devices, and memory chips other than DRAMs (flash memory, SRAMs etc.) Accordingly, although Hitachi, Hitachi, Ltd., Hitachi Semiconductors, and other Hitachi brand names are mentioned in the document, these names have in fact all been changed to Renesas Technology Corp. Thank you for your understanding. Except for our corporate trademark, logo and corporate statement, no changes whatsoever have been made to the contents of the document, and these changes do not constitute any alteration to the contents of the document itself. Renesas Technology Home Page: http://www.renesas.com Renesas Technology Corp. Customer Support Dept. April 1, 2003 Cautions Keep safety first in your circuit designs! 1. Renesas Technology Corporation puts the maximum effort into making semiconductor products better and more reliable, but there is always the possibility that trouble may occur with them. Trouble with semiconductors may lead to personal injury, fire or property damage. Remember to give due consideration to safety when making your circuit designs, with appropriate measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of nonflammable material or (iii) prevention against any malfunction or mishap. Notes regarding these materials 1. These materials are intended as a reference to assist our customers in the selection of the Renesas Technology Corporation product best suited to the customer's application; they do not convey any license under any intellectual property rights, or any other rights, belonging to Renesas Technology Corporation or a third party. 2. Renesas Technology Corporation assumes no responsibility for any damage, or infringement of any third-party's rights, originating in the use of any product data, diagrams, charts, programs, algorithms, or circuit application examples contained in these materials. 3. All information contained in these materials, including product data, diagrams, charts, programs and algorithms represents information on products at the time of publication of these materials, and are subject to change by Renesas Technology Corporation without notice due to product improvements or other reasons. It is therefore recommended that customers contact Renesas Technology Corporation or an authorized Renesas Technology Corporation product distributor for the latest product information before purchasing a product listed herein. The information described here may contain technical inaccuracies or typographical errors. Renesas Technology Corporation assumes no responsibility for any damage, liability, or other loss rising from these inaccuracies or errors. Please also pay attention to information published by Renesas Technology Corporation by various means, including the Renesas Technology Corporation Semiconductor home page (http://www.renesas.com). 4. When using any or all of the information contained in these materials, including product data, diagrams, charts, programs, and algorithms, please be sure to evaluate all information as a total system before making a final decision on the applicability of the information and products. Renesas Technology Corporation assumes no responsibility for any damage, liability or other loss resulting from the information contained herein. 5. Renesas Technology Corporation semiconductors are not designed or manufactured for use in a device or system that is used under circumstances in which human life is potentially at stake. Please contact Renesas Technology Corporation or an authorized Renesas Technology Corporation product distributor when considering the use of a product contained herein for any specific purposes, such as apparatus or systems for transportation, vehicular, medical, aerospace, nuclear, or undersea repeater use. 6. The prior written approval of Renesas Technology Corporation is necessary to reprint or reproduce in whole or in part these materials. 7. If these products or technologies are subject to the Japanese export control restrictions, they must be exported under a license from the Japanese government and cannot be imported into a country other than the approved destination. Any diversion or reexport contrary to the export control laws and regulations of Japan and/or the country of destination is prohibited. 8. Please contact Renesas Technology Corporation for further details on these materials or the products contained therein. Hitachi Microcomputer Development Environment System H8S, H8/300 Series High-performance Embedded Workshop, Hitachi Debugging Interface Tutorial ADE-702-231 Rev. 1.0 12/05/00 Hitachi, Ltd. Cautions 1. Hitachi neither warrants nor grants licenses of any rights of Hitachi’s or any third party’s patent, copyright, trademark, or other intellectual property rights for information contained in this document. Hitachi bears no responsibility for problems that may arise with third party’s rights, including intellectual property rights, in connection with use of the information contained in this document. 2. Products and product specifications may be subject to change without notice. Confirm that you have received the latest product standards or specifications before final design, purchase or use. 3. Hitachi makes every attempt to ensure that its products are of high quality and reliability. However, contact Hitachi’s sales office before using the product in an application that demands especially high quality and reliability or where its failure or malfunction may directly threaten human life or cause risk of bodily injury, such as aerospace, aeronautics, nuclear power, combustion control, transportation, traffic, safety equipment or medical equipment for life support. 4. Design your application so that the product is used within the ranges guaranteed by Hitachi particularly for maximum rating, operating supply voltage range, heat radiation characteristics, installation conditions and other characteristics. Hitachi bears no responsibility for failure or damage when used beyond the guaranteed ranges. Even within the guaranteed ranges, consider normally foreseeable failure rates or failure modes in semiconductor devices and employ systemic measures such as fail-safes, so that the equipment incorporating Hitachi product does not cause bodily injury, fire or other consequential damage due to operation of the Hitachi product. 5. This product is not designed to be radiation resistant. 6. No one is permitted to reproduce or duplicate, in any form, the whole or part of this document without written approval from Hitachi. 7. Contact Hitachi’s sales office for any questions regarding this document or Hitachi semiconductor products. Trademarks: Microsoft®, Windows®, Windows® 95, Windows® 98, Windows NT®, and Windows® 2000 are registered trademarks of Microsoft Corporation in the United States and/or in other countries. IBM PC is the name of a computer administered by International Business Machines Corporation. ELF/DWARF is the name of an object format developed by the Tool Interface Standards Committee. All products or brand names used in the tutorial are trademarks or registered trademarks of their respective companies. Read First: 1. Hitachi, Ltd. (including its subsidiaries, hereafter collectively referred to as Hitachi) pursues a policy of continuing improvement in design, performance, and safety of the system. Hitachi reserves the right to change, wholly or partially, the specifications, design, user's manual, and other documentation at any time without notice. 2. This tutorial and this system are copyrighted and all rights are reserved by Hitachi. No part of this user's manual, all or part, may be reproduced or duplicated in any form, in hard-copy or machine-readable form, by any means available without Hitachi's prior written consent. 3. Hitachi assumes no responsibility for any intellectual property claims or other problems that may result from applications based on the examples described herein. Preface This tutorial will introduce you to the basic usage of the Hitachi Embedded Workshop (hereafter referred to as HEW) and the Hitachi Debugging Interface (hereafter referred to as HDI). The HEW tutorial describes a series of usage such as how to invoke HEW, how to create and modify a project, how to build a program, and how to invoke HDI from HEW. The HDI tutorial describes how to debug a sample program using the Simulator/Debugger. For the details of each component of HEW and HDI, refer to the following manuals. • Hitachi Embedded Workshop User’s Manual • H8S, H8/300 Series C/C++ Compiler, Assembler, Optimizing linkage editor User’s Manual • H8S, H8/300 Series Simulator/Debugger User’s Manual For details on the H8S, H8/300 Series CPU, refer to a programming manual or a hardware manual of the corresponding CPU. This tutorial is written assuming that all the tools included in the H8S,H8/300 Series C/C++ compiler Package are installed. Document Conventions This manual uses the following typographic conventions: Table 1 Typographic Conventions CONVENTION MEANING [Menu->Menu Option] Text with ‘->’ is used to indicate menu options (for example, [File>Save As...] ). Contents Section 1 HEW Tutorial 1.1 1.2 1.3 1.4 1.5 1.6 Invoking the HEW.............................................................................................................1 Creating a Project ..............................................................................................................3 1.2.1 Selecting a CPU ...................................................................................................4 1.2.2 Setting Options Unique to the CPU......................................................................6 1.2.3 Setting the Generating Files .................................................................................8 1.2.4 Setting the Standard Library ................................................................................11 1.2.5 Setting Stack Area................................................................................................12 1.2.6 Setting the Vector.................................................................................................14 1.2.7 Modifying Generated File Name..........................................................................17 1.2.8 Confirming Settings .............................................................................................18 Modifying the Project........................................................................................................21 1.3.1 Editing and Creating a Source Program File ........................................................21 1.3.2 Adding / Removing a File To / From a Project ....................................................23 1.3.3 File Groups Used in a Project...............................................................................26 1.3.4 Customizing the Workspace Window ..................................................................28 Building a Project..............................................................................................................29 1.4.1 Build Overview ....................................................................................................29 1.4.2 Setting Options.....................................................................................................30 1.4.3 Customizing the Configuration ............................................................................31 1.4.4 Excluding a Project File from Build.....................................................................32 1.4.5 Correcting Errors in a Build .................................................................................33 HDI Interface.....................................................................................................................34 1.5.1 Launching HDI.....................................................................................................34 1.5.2 Demonstration Project..........................................................................................37 Exiting From the HEW......................................................................................................38 Section 2 2.1 HDI Tutorial Using the HDI with the Simulator/Debugger ....................................................................39 2.1.1 Introduction ..........................................................................................................39 2.1.2 Running HDI........................................................................................................39 2.1.3 Selecting the Target..............................................................................................39 2.1.4 Mapping the Memory Resource ...........................................................................41 2.1.5 Downloading the Tutorial Program......................................................................43 2.1.6 Displaying the Source Program............................................................................44 2.1.7 Setting a PC Breakpoint .......................................................................................46 2.1.8 Setting Trace Information Acquisition Conditions ..............................................46 2.1.9 Setting Performance Analysis ..............................................................................47 2.1.10 Setting the Stack Pointer ......................................................................................48 Rev. 1.0, 12/00, page i of ii 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.17 2.1.18 2.1.19 2.1.20 Executing the Program.........................................................................................49 Using the Trace Buffer.........................................................................................51 Trace Search ........................................................................................................52 Reviewing Breakpoints ........................................................................................53 Viewing Memory .................................................................................................53 Watching Variables..............................................................................................54 Stepping Through a Program ...............................................................................57 Displaying Local Variables..................................................................................62 Reviewing the Performance Analysis ..................................................................63 Saving the Session ...............................................................................................64 Rev. 1.0, 12/00, page ii of ii Section 1 HEW Tutorial 1.1 Invoking the HEW After the installation of the HEW, the installer creates a folder whose name is “Hitachi Embedded Workshop” in the “Program” folder of the “Start” menu of the Windows®. In the “Hitachi Embedded Workshop” folder, short cuts of the HEW support files will be registered (figure 1.1). The contents of the “Start” menu and its submenus differ depending on your installation. Figure 1.1 Invoking the HEW from the “Start” Menu Rev. 1.0, 12/00, page 1 of 64 If you click “Hitachi Embedded Workshop” from the menu, the HEW will be invoked and the “Welcome!” dialog box (figure 1.2) will be displayed. You can open the project promptly without the “Welcome!” dialog if you change the setting via [Tools->Options]. For details of this setting, refer to chapter 6, “Customizing the Environment”, of the Hitachi Embedded Workshop User’s Manual. Figure 1.2 Welcome! Dialog Box If you use the HEW for the first time or if you want to work on a new project, select the [Create a new project workspace] radio button and click [OK]. If you want to work on an existing project, select the [Open a recent project workspace] or [Browse to another project workspace] radio button and click [OK]. In this tutorial, select the [Create a new project workspace] radio button and click [OK]. Rev. 1.0, 12/00, page 2 of 64 1.2 Creating a Project When you have selected the [Create a new project workspace] radio button, then clicking [OK] in the “Welcome!” dialog box will launch the “New Project Workspace” dialog box (figure 1.3), which is used to create a new workspace and project. You can also launch the “New Project Workspace” dialog box by selecting [File -> New Workspace…] after you have launched HEW. In this dialog box, you will specify a workspace name (when newly creating a workspace name, the project name will be the same as the workspace), CPU family, project type, and so on. For details of the project type, refer to table 1.1. In this tutorial, enter “tutorial” as a workspace name in the [Name] field, and select “Application” in the [Project type] list. If you have entered “tutorial” in the [Name] field, then the [Directory] field will show “c:\tutorial” and a project will be generated under this directory. If you want to change the directory used for the new workspace, click the [Browse…] button and specify a directory, or enter a directory path manually in the [Directory] field. Figure 1.3 New Project Workspace Dialog Box Rev. 1.0, 12/00, page 3 of 64 Table 1.1 Project Type Project Type Description Application Projects to develop programs including initial routine files written in C/C++ or assembly language. Assembly Application Projects to develop programs including initial routine files written in assembly language. Demonstration Projects to develop demonstration programs written in C/C++ or assembly language. Empty Application Projects to develop programs (But are not generated files. They are used to set only the options of the tool.) Library Projects to develop library files (But are not generated files. They are used to set only the options of the tool.) 1.2.1 Selecting a CPU When you click [OK] in the “New Project Workspace” dialog box, the project generator will be invoked and will launch the Step 1 dialog box (CPU selection) (figure 1.4). In this dialog box, select the type of target CPU for which you wish to develop programs. In this tutorial, select “2600” in the [CPU Series] list and “2655” in the [CPU Type] list. Click the [Next >] button after selecting a CPU type from the [CPU Type] list. This will launch the Step 2 dialog box (Setting the options unique to the CPU). Rev. 1.0, 12/00, page 4 of 64 Figure 1.4 Selecting the CPU in the Project Generator (Step 1) CPU types shown in the [CPU Type:] list are classified into the CPU series shown in the [CPU Series:] list. When you select a CPU type from the [CPU Series:], the project generator will set a CPU type option for the standard library generator, C/C++ compiler, and assembler. Depending on what you select in [CPU Series:] and [CPU Type:], different types of files will be generated by the Project Generator. Select the type of target CPU for which you wish to develop programs. If you cannot find the CPU you want in the list, then select one close to its hardware specifications or select “Other.” • Click [Next >] to get the project generator to launch the next dialog box. • If you click [< Back], the project generator will return to the previous dialog box. • If you click [Finish], the project generator will open the Summary dialog box. • If you click [Cancel], the project generator will return to the “New Project Workspace” dialog box. • [< Back], [Next >], [Finish], and [Cancel] all function in the same say in the Project Generator. Rev. 1.0, 12/00, page 5 of 64 1.2.2 Setting Options Unique to the CPU When you click [Next >] in the Step 1 dialog box, the Project Generator will launch the dialog box shown in figure 1.5. In this dialog box, you can set options unique to the CPU and that can be used commonly through all the project files. In the tutorial, select Advanced for the [Operating Mode:] and click [Next >]. The Project Generator will launch the Step 3 dialog box (Setting the Generation File). Figure 1.5 Setting Options Unique to the CPU in the Project Generator (Step 2) You may set the following options by the Step 1 and 2 dialog boxes. If you want to change the settings of the options after you have generated a project, you must modify the option setting dialog box in the tools below ([Options -> ] in HEW). Rev. 1.0, 12/00, page 6 of 64 • C/C++ Compiler (Same for Standard Library Generator) CPU/operating mode Optimization by speed (only for standard library generator) Parameter storage register specification Double to float conversion Register allocation of structured parameters and return values Register allocation of 4-byte parameters and return values (only CPU:300) Exception processing function Runtime type information • Assembler CPU • Optimizing Linkage Editor Output format (determined by the project type) You cannot modify options that are not supported by the Project Generator for the CPU series you selected in the Step 1 dialog box. In this tutorial, since you selected 2600 for CPU Series, [Pass 4byte parameter / return value via register] will be grayed out, meaning that you cannot set them. If you selected Library for the project type, there are no other settings you have to make. Therefore, just click [Finish]. If you selected Demonstration for the project type, click [Next >] to launch Step 6, which is shown in section 1.2.7, Modifying Generated File Name. If you selected Demonstration, the Project Generator will launch the Step 3 dialog box. Rev. 1.0, 12/00, page 7 of 64 1.2.3 Setting the Generating Files When you click [Next >] in the Step 2 dialog box, the Project Generator will launch the dialog box shown in figure 1.6. Figure 1.6 File Generation Using the Project Generator (Step 3) In this dialog box, you must decide the kind of file to create. In this tutorial, select [Use I/O Library] and click [Next >]. The project generator will launch the Step 4 dialog box (Setting the Standard Library). If you select checkbox [Use I/O Library], you can use the standard I/O library. When you have selected Application for the project type, [Number of I/O Streams:] can also be set. When modifying [Number of I/O Streams:] after you have created the project, modify the numeric of lowsrc.h in the following area. #define IOSTREAM 3 Rev. 1.0, 12/00, page 8 of 64 If you select checkbox [Use Heap Memory], you can use function sbrk() for controlling the heap area. Then you can use [Heap Size:] to set the size of the heap area to control as follows. H’ABCDE: Hexadecimal 0xABCDE: Hexadecimal 1234: Decimal If you want to modify [Heap Size] after you have generated a project, you must modify the number in the following line of “sbrk.h”. #define HEAPSIZE 0x400 You can select the way to generate the main function in [Generate main() Function]. • When you have selected Application for the project type, you can select from the following the type of main function to generate: C source file C++ source file None • When you have selected Assembly Application for the project type, you can select from the following the type of the main function to generate: Assembly source file None If you select checkbox [I/O Register Definition Files], the Project Generator generates an I/O register definition file written in C language. Then you can set [Generate Hardware Setup Function]. When you have selected Assembly Application for the project type, you cannot use [Use Heap Memory] and [I/O Register Definition Files]. Different types of files will be created by the Project Generator depending on what you set in the this dialog box and what you select for the project type. If you select a checkbox in tables 1.2 and 1.3, the Project Generator will create the corresponding files. Rev. 1.0, 12/00, page 9 of 64 Table 1.2 The Relationship between the Dialog Box Settings and the Generated Files (Application Project) Control Stage Generated File [Use I/O Library] Selected lowlvl.src lowsrc.c [Number of I/O Streams:] Numeric lowsrc.h [Use Heap Memory] Selected sbrk.c [Heap Size:] Enter a value sbrk.h [Generate main() Function] C source file C++ source file None tutorial.c tutorial.cpp When Project Generator creates a file, the project name becomes the file name. [I/O Register Definition Files] Selected iodefine.h [Generate Hardware Setup Function] None Assembly source file C/C++ source file hwsetup.src hwsetup.c (or cpp) (same file extension as the main function file) Table 1.3 The Relationship between the Dialog Box Settings and the Generated Files (Assembly Application Project) Control Stage Generated File [Use I/O Library] Selected lowlvl.src [Number of I/O Streams:] Nothing can be entered [Use Heap Memory] Cannot be selected [Heap Size:] Nothing can be entered [Generate main() Function] Assembly source file None tutorial.src When Project Generator creates a file, the project name becomes the file name. [I/O Register Definition Files] Cannot be selected [Generate Hardware Setup Function] Cannot be selected Note: To use the main (_main) function that has already been generated, you must not select [Generate main() Function], and add the corresponding file to the project to generate a project. To use another function that has already been generated, you must modify the function calling section in the resetprg.src. Rev. 1.0, 12/00, page 10 of 64 1.2.4 Setting the Standard Library When you click [Next >] in the Step 3 dialog box, the Project Generator will display the dialog box shown in figure 1.7. Figure 1.7 Setting Standard Library in Project Generator (Step 4) In this dialog box, you can set the standard library to use in the Project Generator. When you build a project, the Project Generator will create the standard library according to the items you have selected in [Library]. If you want to modify the settings after you have created the project, modify the library through the option setting dialog box (select [Options -> H8S, H8/300 Library Generator…] in HEW) of the standard library generator. In this tutorial, do not set anything and click [Next >]. The Project Generator will display the Step 5 dialog box (setting stack area). Rev. 1.0, 12/00, page 11 of 64 1.2.5 Setting Stack Area When you click [Next >] in the Step 4 dialog box, the Project Generator will display the dialog box shown in figure 1.8. Figure 1.8 Setting Stack Area in Project Generator (Step 5) In this dialog box, you can set the stack area. In this tutorial, do not set anything and click [Next >]. The Project Generator will display the Step 6 dialog box (setting vector definition). You can enter a value in hexadecimal or decimal in [Stack Pointer Address:] and [Stack Size:]. Enter a value as follows: H’ABCDE: Hexadecimal 0xABCDE: Hexadecimal 1234: Decimal Rev. 1.0, 12/00, page 12 of 64 If you enter a value in [Stack Size:], it will be set in stacksct.h (when you have selected Assembly Application for the project type: stacksct.src). If you enter a value in [Stack Pointer Address:] and [Stack Size:], the Project Generator will determine the start address of the stack section by using the start option of the optimizing linkage editor. The start address of the stack section will be determined as follows: Stack section name: S (when you have selected Assembly Application for the project type: Stack) Start section address = value of [Stack Pointer Address:] – value of [Stack Size:] To modify the stack size after you have created the project, modify the stack area size of stacksct.h (or stacksct.src) and modify the start address of the start section by using the start option in the option dialog box (select [Options -> Optlinker…] in HEW) of the optimizing linkage editor. stacksct.h #pragma stacksize 0x200 stacksct.src .section Stack,STACK .export _PowerON_Reset_SP .export _Manual_Reset_SP StackEND: .res.b _PowerON_Reset_SP: .equ $ _Manual_Reset_SP: .equ $ H'200 -----> Stack area size .end Rev. 1.0, 12/00, page 13 of 64 1.2.6 Setting the Vector When you click [Next >] in the Step 5 dialog box, the Project Generator will display the dialog box shown in figure 1.9. Figure 1.9 Setting Vector in Project Generator (Step 6) In this dialog box, you can set the vector. In this tutorial, do not set anything and click [Next >]. The Project Generator will display the Step 7 dialog box (confirming generated files). When you select [Vector Definition Files], the Project Generator will create interrupt programs such as reset program. When you have selected Assembly Application for the project type, you can modify the reset vector by [Vector Handlers:]. The [Handler] column in [Vector Handlers:] shows the handler program name, and the [Vector] column explains the vector. When you are going to use a handler program that you have created by yourself, enter the program name after you have selected the handler program by clicking it in the dialog box. Rev. 1.0, 12/00, page 14 of 64 If you modify the handler name of [Vector Handlers:], the Project Generator will not create reset program file (resetprg.src). If you select [Vector Definition Files], the Project Generator will create the following files: Application project intprg.c (interrupt program) resetprg.c (reset program) Assembly Application project vecttbl.src (vector table) intprg.src (interrupt program) vect.inc (definition for interrupt program reference) resetprg.src (reset program) To edit the interrupt program or modify other programs after you have created the project, modify the source file according to the following procedure: • Editing the interrupt program of Application project The reset program is written in C language in file resetprg.c. You can add processes to the file as required. The file includes only easy initial settings such as section initialization. The interrupt program is written in C language in file intprg.c. Both files include only the program names, so you must write the necessary processes. • Changing the interrupt program of Application project into another program To change the interrupt programs into other programs, you must delete the unnecessary functions from the reset program and interrupt programs and add new functions to be used as an interrupt function. • Editing the interrupt program of the Assembly Application project The reset program is written in assembly language in file resetprg.src. You can add processes to the file as required. The file includes only easy initial settings such as section initialization and stack register settings. The interrupt program is written in assembly language in file intprg.src. Both files include only the program names, so you must write the necessary processes. • Changing the interrupt program of the Assembly Application project into another program To modify the interrupt programs, you must modify the labels (assembly module name) that corresponds to the target interrupt to be modified. Those labels are in vect.inc and vecttbl.src. Furthermore, you must delete the same module from the interrupt module file (intprg.src) and add a new module (or file including module) to be used as an interrupt program. Rev. 1.0, 12/00, page 15 of 64 Example: To modify vector 7 program (_INT_NMI) to _USER_NMI vect.inc . . ;7 NMI .global _INT_NMI ---> changed to .global _USER_NMI . . vecttbl.src . . ;7 NMI .data.l _INT_NMI ---> changed to .data.l _USER_NMI . . intprg.src . . ;7 NMI _INT_NMI . . Rev. 1.0, 12/00, page 16 of 64 ---> delete _INT_NMI and add a file that ---> _USER_NMI was written to, in the ---> project. 1.2.7 Modifying Generated File Name When you click [Next >] in the Step 6 dialog box, the Project Generator will display the dialog box shown in figure 1.10. Figure 1.10 Confirming Generated File Name in Project Generator (Step 7) This dialog box will be the last one in the New Project wizard. It will display all of the files that have been created by the Project Generator. The [File Name] column in the list shows the file names, the [Extension] column shows the extensions, and the [Description] column explains the files. The file names can be modified. To change the file names, enter the new name after selecting the file name. In this tutorial, do not set anything and click [Next >]. The Project Generator will display the Summary dialog box. Note: When the extension in [Extension] is .h or .inc, this shows that the file is an include file. To modify the names of these files, you must modify the include statements included in these files. Rev. 1.0, 12/00, page 17 of 64 1.2.8 Confirming Settings When you click [Finish] in the Step 7 dialog box, the Project Generator will display the dialog box shown in figure 1.11. Figure 1.11 Summary Dialog Box in Project Generator [Project Summary:] displays the settings that have been made. Confirm the contents and click [OK]. To modify the settings, click [Cancel]. The Project Generator will output the displayed contents as text files (Readme.txt). When the Project Generator does not output anything, uncheck the check box [Generate Readme.txt as a summary file in the project directory]. When you click [OK], the Project Generator will create the project. Rev. 1.0, 12/00, page 18 of 64 HEW opens the projects in which files generated by the project generator are installed. The start window of HEW is divided into windows such as the work space window, which shows the contents of the project (left side of the window), output window, which shows the results of build and string literal detection among files (bottom part of the window), and editor window, which is used to edit the text file (right side of the window). For details on modifying the state of HEW window or the functions of windows including the editor window, refer to Hitachi Embedded Workshop User’s Manual. Figure 1.12 HEW Window Configuration Rev. 1.0, 12/00, page 19 of 64 When the Project Generator creates a project, the Project Generator sets basic options for the tools to perform a build such as the standard library generator, C/C++ compiler, assembler, and optimizing linkage editor. Therefore, it is possible to perform build by selecting [Build->Build] immediately after creating a project. See figure 1.13. You can also perform a build by using the following button on the toolbar. These basic options are defined as the default for each tool, so you do not have to set them except for the options that must be set for each file after it has been added to the project. Figure 1.13 Rev. 1.0, 12/00, page 20 of 64 Window of Build 1.3 Modifying the Project When you create a project using the project generator, basic program such as reset routine and initialization routine of RAM area will already be given in the project. This tutorial describes how to modify a file and how to add a file to the project. 1.3.1 Editing and Creating a Source Program File To open and edit a file in the project, double click the file in the [Projects] tab of the “Workspace” window. In this tutorial, double click “tutorial.c” (figure 1.14). Figure 1.14 Opening a Project File Rev. 1.0, 12/00, page 21 of 64 Then you can edit the file opened. If you edit the file, an asterisk (*) will be added to the file path shown on the title bar of the HEW (figure 1.15). If you save the file, the asterisk will disappear. Figure 1.15 Editing a Project File If you want to open an existing text file with the editor of the HEW, select [File->Open]. If you want to edit a new text file with the editor, select [File->New]. In this tutorial, select [File->New], input the three lines shown below, select [File->Save As…] and save the file as “newprog.c”. void NewProgram(void) { } Rev. 1.0, 12/00, page 22 of 64 1.3.2 Adding / Removing a File To / From a Project This section describes how to add a file to a project and how to delete a file from a project. In this tutorial, add the file, “newprog.c” created in the previous section to the project as follows. Select [Project->Add Files…], then the “Add File(s)” dialog box (figure 1.16) will be launched. Select a file, “newprog.c” in this example, to be added and click the [Add] button. Thus “newprog.c” will be added to the project. Figure 1.16 Adding a File To a Project Rev. 1.0, 12/00, page 23 of 64 The added file will be displayed on the [Projects] tab of the “Workspace” window as shown in figure 1.17. Figure 1.17 Rev. 1.0, 12/00, page 24 of 64 Project With a File Added Next, how to delete a file from a project will be shown. Select [Project->Remove File…], then the “Remove Project Files” dialog box (figure 1.18) will be displayed. Select one or more project files on this dialog box and click the [Remove] button. Then the selcted file(s) will disappear from the list of the dialog box. Clicking [OK] actually removes the file(s) from the project. Clicking [Cancel] instead will nullify the removal. You have another way to delete a file from a project. Select the file in the [Projects] tab of the “Workspace” window and press the [Delete] key. Then the file will be deleted from the project. In this way, you cannot cancel the deletion although you can cancel it on the [Remove Project Files] dialog box. If you want to exclude a file from a build temporarily instead of removing the file from the project, refer to section 1.4.4, “Excluding a Project File”. Figure 1.18 Remove Project Files Dialog Box Rev. 1.0, 12/00, page 25 of 64 1.3.3 File Groups Used in a Project In this section, a file group to which a file added to a project belongs is described. For example, the project generator adds a file described in C programming language or assembly language to the project. A file with a file extension “.c” belongs to the “C source file” group, and a file with a file extension “.src” belongs to the “Assembly source file” group. The HEW identifies a group to which a file belongs by checking the file extension. Select [Project->File Extensions…], then the “File Extensions” dialog box (figure 1.19) will be displayed. File extensions used in the project are shown on this dialog box. Every file extension belongs to a file group. A file group can be associated to a tool in a build process. If you want to use your own file extension in the project, define a new file extension by clicking the [Add…] button. The following icon displayed in the [Extension] column of the “File Extensions” dialog box can show a tool which opens the file. If the icon of a file extension is the same as the icon shown below, a file with that file extension can be opened by the editor of the HEW. Figure 1.19 File Extensions Dialog Box (Initial Screen) Click the [Add…] button on the “File Extensions” dialog box, then the “Define File Extension” dialog box (figure 1.20) will be launched. Enter a new file extension in the [File extension] field and specify the [File group] group box. If you want to add an extension to an existing file group, Rev. 1.0, 12/00, page 26 of 64 select the [Existing group] radio button and select a file group from the drop-down list. If you want to create a new file group, select the [New group] radio button and enter the name of the file group in the edit field. In this tutorial, enter “asm” in the [File extension] field, select “Assembly source file” from the drop-down list and click [OK]. Then a file with the extension, “*.asm”, will be treated as a file in the “Assembly source file” group (figure 1.21). Figure 1.20 Figure 1.21 Define File Extension Dialog Box File Extension Dialog Box (After Adding an File Extension) Rev. 1.0, 12/00, page 27 of 64 1.3.4 Customizing the Workspace Window Click the right mouse button on the [Projects] tab of the “Workspace” window, then a pop-up menu will be displayed. Select [Configure View…] on this menu, then “Configure View” dialog box (figure 1.22) will be launched. On this dialog box, you can specify whether the file dependencies are shown for each file or not, whether a file is shown in a file group folder (figure 1.23) or not, and so on, can be selected. Figure 1.22 Figure 1.23 Rev. 1.0, 12/00, page 28 of 64 Configure View Dialog Box Configuration of the Workspace Window 1.4 Building a Project 1.4.1 Build Overview The HEW provides two ways in building a project. One is “Build All”, which applies a series of tools like a compiler, an assembler and a linker to all the source program files. The other is “Build”, which applies a tool only to a source program file updated after the last build. (The update means not only the update of a source program file, but also an update of a file included by the source program file and an update of an option applied to the source program file.) The “Build” corresponds to [Build->Build] and the “Build All” corresponds to [Build->Build All]. If you want to compile or assemble a single source program file, select the file on the [Projects] tab of the “Workspace” window and select [Build->Build File]. CAUTION ON BUILD 1. Depending of the setting of the editor window, a file being edited might be saved on executing a build. So close a file which you do not want to be saved beforehand. For details of customizing the editor, refer to the Hitachi Embedded Workshop User’s Manual. 2. Do not save a file used in a project during the build because doing so might disturb the build process. Rev. 1.0, 12/00, page 29 of 64 1.4.2 Setting Options In this section, overview of the option setting is described. When the project generator generates a project, the minimum options required for a build are already specified. If you want to modify the options, however, select [Options-> <Tool name>] and set options on the option dialog box of each tool. Figure 1.24 shows the option dialog box of a C/C++ compiler. On the left hand side of the dialog box is a file list, and on the right hand side are option controls divided into some tabs. If you select a file in the file list, you can specify options only to the selected file. If you select a file group folder in the file list, you can specify the same option to all the files in the file group. To specify the same options to specific files, select the files while pushing the [Ctrl] key or the [Shift] key. If you select “Default Options” in a file group folder, you can specify initial options for the file group. The HEW automatically adds the options specified to the “Default Options” to a file of the corresponding file group of the corresponding file extension of the file. For example, if you add a file with an extension “C” (“*.C”) to the project, the settings of the “Default Options” of the “C source file” group will be added to the file automatically. For the details of the options refer to the manual of the corresponding tool. Figure 1.24 Rev. 1.0, 12/00, page 30 of 64 Option Dialog Box of C/C++ Compiler 1.4.3 Customizing the Configuration In the previous section, how to set options to a project file is described. In this section, how to create more than one suite of option settings for a build will be described. A suite of option settings for a build is called a configuration. The project generator creates two configurations, [Debug] and [Release]. Difference between them is only the setting of the debug option. To switch the current configuration to another, launch the “Build Configurations” dialog box (figure 1.25) by selecting [Options-> Build Configurations…], select a configuration from the “Current configuration” drop-down list, and click [OK]. You can also change the current configuration by selecting one from the drop-down list on the toolbar. On the “Build Configurations” dialog box, you can create a new configuration or delete a configuration. For details, refer to chapter 2, “Build Basics”, of the Hitachi Embedded Workshop User’s Manual. Figure 1.25 Build Configurations Dialog Box Rev. 1.0, 12/00, page 31 of 64 1.4.4 Excluding a Project File from Build In this section, how to exclude a project file from build will be described. Excluding a project file from build does not delete the file from a project, but exclude a project file from build in configuration by configuration basis. Select a file on the “Projects” tab of the “Workspace” window, click the right mouse button, and select [Exclude Build <file>] on the pop-up menu. Then a red cross will be added to the icon of this file as shown in figure 1.26. This file will be excluded from a build. To include an excluded file into build, select the file on the “Projects” tab of the “Workspace” window, click the right mouse button, and select [Include Build <file>] on the pop-up menu. Figure 1.26 Rev. 1.0, 12/00, page 32 of 64 Excluding a Project File from Build 1.4.5 Correcting Errors in a Build In this section, how to jump to a line of a file which caused an error in compiling or assembling will be described. Figure 1.27 shows an example in which a compiler detected a syntax error in a source program file. When you build a project, messages, including error messages, from a tool in a build will be displayed on the “Output” window. If you double click the line of the error message on the [Build] tab of the “Output” window, the file which caused the error will be opened and the cursor will be placed on the line which caused the error. (The cursor might not be placed on the line which caused the error if you have already edited the file.) Figure 1.27 Correcting the Line which Caused an Error Rev. 1.0, 12/00, page 33 of 64 1.5 HDI Interface 1.5.1 Launching HDI The HEW can launch the HDI (Version 4.0 or greater). To register the HDI in the HEW, open the [Debugger] tab (figure 1.28) of the “Tools Customize” dialog box which is launched by selecting [Tools->Customize…]. Specify the path of the HDI.EXE in the [HDI location (V4.0 or greater)] field. In the [Session file] field, specify the path of the session file to be loaded. How to generate a session file is shown in the H8S,H8/300 Series Simulator/Debugger User’s Manual. If you set the two fields, the toolbar button shown below will be activated. Thus clicking the button will launch the HDI and it will load the session file. If you specify the path of the load module file on the [Download module] field, the HDI will be focused immediately after the load module file is updated by the HEW. Figure 1.28 Rev. 1.0, 12/00, page 34 of 64 Tools Customize Dialog Box, Debugger Tab If you double click a line on the source window (figure 1.29) of the HDI, the corresponding file will be opened by the HEW and the cursor will be placed on the same line as you have double clicked. Figure 1.30 shows the HEW after the line of “void main(void)” of “tutorial.c” is double clicked on the source window of the HDI. Figure 1.29 Source Window of the HDI Rev. 1.0, 12/00, page 35 of 64 Figure 1.30 The Editor Windows of the HEW Opened by the HDI Rev. 1.0, 12/00, page 36 of 64 1.5.2 Demonstration Project If, when creating a project, you choose Demonstration as the project type in the New Project Workspace (figure 1.3), you can create a sample project that has a Simulated I/O function of the HDI Simulator/Debugger. This project uses the standard printf output function to display the status of program execution and data on function main. After you have set the debugging environment via the HDI, you must set the system configuration before using the Simulated I/O function by using the System Configuration Dialog Box (open this dialog box by selecting [Setup -> Configure Platform…]). Select the [Enable] checkbox for the System Call Address in this dialog box and enter the value of SIM_IO, as defined in lowlvl.src by HEW, as the address. The address may vary according to the type of CPU. SIM_IO: .EQU H'0000 (In this case, 0 is entered as the address.) If you open the Simulated I/O Window in the HDI (open this window by selecting [View -> Simulated I/O]) and run the demonstration program, you can debug the program by using the Simulated I/O function. For details, refer to the H8S,H8/300 Series Simulator/Debugger User’s Manual. Figure 1.31 HDI System Configuration Dialog Box Rev. 1.0, 12/00, page 37 of 64 1.6 Exiting From the HEW Selecting [File->Exit] will close the HEW. Depending on the setting, the message box (figure 1.32) which asks you whether to save the workspace or not will be launched. Not only the setting like this regarding exiting from the HEW but also setting regarding initiation of the HEW can be specified via [Tools->Options…]. For details, refer to the Hitachi Embedded Workshop User’s Manual. The HDI and the other tools launched from the HEW will not be closed when the HEW is closed. Close the tools by yourself. Figure 1.32 Confirmation Dialog Box for Saving Workspace on Exiting from the HEW Rev. 1.0, 12/00, page 38 of 64 Section 2 HDI Tutorial 2.1 Using the HDI with the Simulator/Debugger The following describes a sample program debugging session, designed to introduce the main features of the simulator/debugger used in conjunction with the Hitachi Debugging Interface (HDI) software. 2.1.1 Introduction This sample program is based on a C program that sorts ten random data items first in ascending order, then in descending order. The sample program performs the following actions: • With the main function, random data to be sorted is generated. • With the sort function, an array is input, within which the random data generated by the main function is stored, and the data is sorted in ascending order. • With the change function, the array generated by the sort function is input, and the data is sorted in descending order. The sample program is provided on the installation disk as file sort.c. A compiled version of the tutorial is provided in file sort.abs. 2.1.2 Running HDI Run the HDI interface software independently and not from the Hitachi Embedded Workstation (HEW) since the sample program is used to explain the functions of the HDI. To run the HDI interface software, double-click the [HDI for Simulator] icon. Figure 2.1 2.1.3 Icon of HDI for Simulator Selecting the Target The HDI can be extended to support multiple target platforms. If your system is set up for more than one platform, you will be prompted to choose a platform for the current session. Rev. 1.0, 12/00, page 39 of 64 Figure 2.2 Select Session Dialog Box For this tutorial, select H8S/2600A Simulator and click the [OK] button to continue. Note that you can change the target platform at any time by choosing [New Session…] from the [File] menu. If you have only one platform installed, this menu option will not be available. When the simulator/debugger has been successfully set up, the Hitachi Debugging Interface window will be displayed, with the message "Link up" in the status bar. Figure 2.3 shows the key functions of the window: Figure 2.3 Rev. 1.0, 12/00, page 40 of 64 Hitachi Debugging Interface Window The key functions of Hitachi Debugging Interface are described in the following sections. Menu bar: Give you access to the HDI commands for using the HDI debugger. Toolbar: Provides convenient buttons as shortcuts for the most frequently used HDI commands. Tool buttons from the same menu are displayed in the same block. The tool buttons can be moved within the toolbar by clicking dragging them. Whether to display the tool buttons can be selected by using the [Toolbar] option in the [Customize] submenu in the [Setup] menu. Source window: Displays the source of the program being debugged. Status bar: Displays the status of the simulator/debugger, and progress information about downloading. Help button: Activates context sensitive help about any feature of the HDI user interface. 2.1.4 Mapping the Memory Resource The next step is to map the memory resource used to operate an application being developed. • Choose [Configure Map...] from the [Memory] menu to display the current memory mapping. Figure 2.4 Memory Map Dialog Box • Clicking the [Add] button displays the System Memory Resource Modify dialog box. Rev. 1.0, 12/00, page 41 of 64 Figure 2.5 Rev. 1.0, 12/00, page 42 of 64 System Memory Resource Modify Dialog Box In the [Access type] box, you can specify one of the following three access types: Read: Only read enabled Write: Only write enabled Read/Write: Read and write enabled For this tutorial, map the memory area of addresses ranging from H'00000000 to H'00003FFF as a read/write enabled area. • Edit the [Start address] and [End address] fields to H'00000000 and H'00003FFF, respectively, set the [Access type] as [Read/Write], and click the [OK] button. The Memory Map dialog box will now show the modified ranges. • Click the [Close] button to close the dialog box. 2.1.5 Downloading the Tutorial Program • To open the Load Program dialog box, choose [Load Program...] from the [File] menu. Figure 2.6 Load Program Dialog Box • In [File name], enter the path for the directory where file sort.abs is stored, or click the [Browse...] button to open the Open dialog box and select the file sort.abs and click the [Open] button. Rev. 1.0, 12/00, page 43 of 64 Figure 2.7 Open Dialog Box (Load Program...) • Click the [Open] button in the Load Program dialog box. When the file has been loaded, the following dialog box displays information about the memory areas that have been filled with the program code. Figure 2.8 HDI Dialog Box • Click the [OK] button to continue. 2.1.6 Displaying the Source Program The HDI allows you to debug a program at the source level, so that you can see a listing of the C program alongside the machine code as you debug. To do this, read the C source file that corresponds to the object file. • Choose [Source...] from the [View] menu. • You will be prompted for the C source file that corresponds to the object file you have loaded. Rev. 1.0, 12/00, page 44 of 64 Figure 2.9 Open Dialog Box (Source...) • Select sort.c and click the [Open] button to display the Source window. Figure 2.10 Source Window (Displaying the Source Program) Rev. 1.0, 12/00, page 45 of 64 • If necessary, choose the [Font] option from the [Customise] submenu on the [Setup] menu to choose a font and size suitable for your computer. Initially the Source window shows the start of the main program, but you can use the scroll bar to scroll through the program to see the other statements. 2.1.7 Setting a PC Breakpoint The Source window provides a very simple way of setting a breakpoint at any point in a program. For example, to set a breakpoint at the sort function call: • Double-click the [BP] column on the line containing the sort function call. Figure 2.11 Source Window (Setting the Breakpoint) The mark • will be displayed on the line containing the sort function to show that a PC breakpoint is set at that address. 2.1.8 Setting Trace Information Acquisition Conditions • Choose [Trace] from the [View] menu to open the Trace window. Click the right mouse button on the Trace window and choose [Acquisition] from the pop-up menu. The following Trace Acquisition dialog box is displayed. Rev. 1.0, 12/00, page 46 of 64 Figure 2.12 Trace Acquisition Dialog Box • Set [Trace start/Stop] to [Enable] in the Trace Acquisition dialog box, and click the [OK] button to make the trace information acquisition effective. 2.1.9 Setting Performance Analysis • Choose [Performance Analysis] from the [View] menu to open the Performance Analysis window. Click the right mouse button on the Performance Analysis window and choose [Add Range...] from the pop-up menu. • The following Performance Option dialog box will be displayed. Figure 2.13 Performance Option Dialog Box • Set [Function Name] as sort in the Performance Option dialog box, and click the [OK] button. In the Performance Analysis window, sort(long*) is then set in [Function]. Rev. 1.0, 12/00, page 47 of 64 Figure 2.14 Performance Analysis Window (Setting) • Click the right mouse button on the Performance Analysis window and choose [Analysis Enabled] from the pop-up menu to activate the performance analysis information acquisition. • Click [X] in the title bar to close the window. 2.1.10 Setting the Stack Pointer Set the stack pointer to run the program. • Choose [Registers] from the [View] menu to open the Registers window. • Double-click the [Value] column of [ER7] in the Registers window to modify the value of the stack pointer ER7. The following dialog box enables the value to be modified. Figure 2.15 Register Dialog Box • Set H'4000 for the value of the stack pointer in this sample program, and click the [OK] button. Rev. 1.0, 12/00, page 48 of 64 2.1.11 Executing the Program • To run the program, choose [Go] from the [Run] menu, or click the [Go] button on the toolbar. Figure 2.16 Go Button The program will be executed up to the breakpoint you inserted, and a statement will be highlighted in the Source window to show that the program has halted, with the message Break=PC Breakpoint in the status bar. Figure 2.17 Source Window (Break Status) Rev. 1.0, 12/00, page 49 of 64 When you start the HDI by clicking the Launch Debugger button in the HEW (see section 1.5, HDI Interface), you can display and edit the source file displayed on the source window through the HEW text editor by double-clicking the [Source] column in the Source window. In the tutorial sample program, this can be done by compiling and linking sample program sort.c. You can see the cause of termination in the System Status window. • Choose the [Status] button from the [View] menu to open the System Status window. Then choose the [Platform] sheet in the System Status window. Figure 2.18 System Status Window This shows the following execution results: (1) The cause of the break was a PC Breakpoint. (2) Execution started from the instruction execution reset. (3) The number of instructions executed by the GO command was 719. (4) The number of cycles executed from the pipeline reset was 7,311. Rev. 1.0, 12/00, page 50 of 64 You can also see the value of the registers in the Registers window. • Choose [Registers] from the [View] menu. Figure 2.19 Registers Window You can see the value of each register at the program stop. 2.1.12 Using the Trace Buffer The trace buffer allows us to look back over previous execution cycles to see what accesses took place. • Open the Trace window by choosing [Trace] from the [View] menu. Scroll up the window so that you can see the first few cycles. • If necessary, choose the [Font] option from the [Customise] submenu on the [Setup] menu to choose a font and size suitable for your computer. Figure 2.20 Trace Window (Displaying Trace Information) Rev. 1.0, 12/00, page 51 of 64 You can see that execution started at address 0, the start of the main function. 2.1.13 Trace Search Click the right mouse button on the Trace window and choose [Find...] from the pop-up menu to open the Trace Search dialog box. Figure 2.21 Trace Search Dialog Box A trace search is executed by specifying the search item [Item] and search contents [Value] then clicking the [OK] button. When the corresponding trace information is found, the first line of the information is highlighted. When continuing trace search with the same contents, click the right mouse button on the Trace window and choose [Find Next] from the pop-up menu. The next corresponding line is highlighted. Figure 2.22 Rev. 1.0, 12/00, page 52 of 64 Trace Window (Search Results) 2.1.14 Reviewing Breakpoints You can see a list of all the breakpoints set in the program in the Breakpoints window. • Choose [Breakpoints] from the [View] menu. Figure 2.23 Breakpoints Window The Breakpoints window also allows you to enable and disable breakpoints, define new breakpoints, and delete breakpoints. • Close the Breakpoints window. 2.1.15 Viewing Memory You can view the contents of a memory block in the Memory window. For example, to view the memory corresponding to array main in word size: • Choose [Memory…] from the [View] menu, enter main in the [Address] field, and set [Format] as Word. Figure 2.24 Open Memory Window Dialog Box • Click the [OK] button to open the Word Memory window showing the specified area of memory. Rev. 1.0, 12/00, page 53 of 64 Figure 2.25 2.1.16 Word Memory Window Watching Variables You can view the contents of variables in the Watch window. For example, set a watch on the long-type array “a” declared at the beginning of the program, by using the following procedure: • Position the cursor to the left of “a” in the Source window. • Click the right mouse button on the Source window and choose [Instant Watch...] from the pop-up menu. The following dialog box will be displayed. Figure 2.26 Instant Watch Dialog Box • Click [Add Watch] to add a variable to the Watch window. Rev. 1.0, 12/00, page 54 of 64 Figure 2.27 Watch Window (Displaying the Array) You can also add a variable to the Watch window by specifying its name. Rev. 1.0, 12/00, page 55 of 64 • Click the right mouse button on the Watch window and choose [Add Watch...] from the popup menu. The following dialog box will appear. Figure 2.28 Add Watch Dialog Box • Type variable max and click the [OK] button. The Watch window will now also show the int-type variable max. Figure 2.29 Watch Window (Displaying the Variable) You can double-click the + symbol to the left of array “a” in the Watch window to expand the variable and show the individual elements in the array. Figure 2.30 Rev. 1.0, 12/00, page 56 of 64 Watch Window (Displaying Array Elements) 2.1.17 Stepping Through a Program The simulator/debugger provides a range of step menu commands that allow efficient program debugging. Table 1.1 Step Menu Commands Menu Command Description Step In Executes every statement, including statements within functions. Step Over Executes a function call in a single step. Step Out Steps out of a function, and stops at the statement following that called the function in the program. Step… Steps repeatedly at a specified rate. To demonstrate program stepping, confirm that the sort function statement at address H’00000062 has been executed. Figure 2.31 Source Window (Stepping) Clicking the [◊] button in the title bar of the Watch window automatically places the Watch window next to the Source window as shown in Figure 2.31. Rev. 1.0, 12/00, page 57 of 64 Executing [Step In]: The [Step In] command steps through the called function and stops at the first statement of the called function. • To step through the sort function, choose [Step In] command from the [Run] menu, or click the [Step In] button in the toolbar. Figure 2.32 Figure 2.33 Step In Button Source Window (Step In) • The highlighted line moves to the first statement of the sort function in the Source window. Executing [Step Out]: The [Step Out] command steps out of the called function and stops at the next statement in the calling program. • To step out of the sort function, choose the [Step Out] command from the [Run] menu, or click the [Step Out] button in the toolbar. Figure 2.34 Rev. 1.0, 12/00, page 58 of 64 Step Out Button Figure 2.35 Source Window (Step Out) • The data of variable “a” displayed in the Watch window is sorted in ascending order. In the Watch window, the values of the modified variables are shown in red. Rev. 1.0, 12/00, page 59 of 64 • To execute two steps, use [Step In]. Figure 2.36 Source Window (Step Out −> Step In) • The value of max displayed in the Watch window is modified to the maximum data value. Executing [Step Over]: The [Step Over] command executes a function call as a single step and stops at the next statement in the main program. • To demonstrate [Step Over] command, execute two steps to reach the change function statement. Rev. 1.0, 12/00, page 60 of 64 Figure 2.37 Source Window (Before Step Over Execution) Rev. 1.0, 12/00, page 61 of 64 • To step through all statements in the change function at a time, choose [Step Over] command from the [Run] menu, or click the [Step Over] button in the toolbar. Figure 2.38 Figure 2.39 Step Over Button Source Window (Step Over) When the last statement of the change function is executed, the data of variable “a”, which is displayed in the Watch window, is sorted in descending order. 2.1.18 Displaying Local Variables You can display local variables in a function using the Locals window. For example, we will examine the local variables in the main function, which declares five local variables: a, j, i, min, and max. • Open the Locals window by choosing [Locals] from the [View] menu. Initially, the Locals window is empty because local variables have not yet been declared. • Choose [Step In] from the [Run] menu to execute a single step. The Locals window will now show the local variables and their values. Rev. 1.0, 12/00, page 62 of 64 Figure 2.40 Locals Window • Double-click the + symbol in front of array “a” in the Locals window to show the individual elements of array “a”. • Refer to the elements of array “a” before and after the execution of the sort function, and confirm that random data is sorted in ascending or descending order. 2.1.19 Reviewing the Performance Analysis You can see the performance analysis results of functions in the Performance Analysis window. • Choose [Performance Analysis] from the [View] menu. Figure 2.41 Performance Analysis Window (Viewing) In this window, [Cycle] shows the total number of execution cycles required for the sort function, and [%] shows the ratio of execution cycle count required for the function to the execution cycle count required for the whole program. The Performance Analysis window allows you to enable and disable the performance analysis, define new functions for performance analysis, and delete functions. • Close the Performance Analysis window. Rev. 1.0, 12/00, page 63 of 64 2.1.20 Saving the Session Before exiting, it is a good practice to save your session, so that you can resume with the same conditions in your next debugging session. • Choose [Save Session] from the [File] menu. • Choose [Exit] from the [File] menu to exit from the HDI. Rev. 1.0, 12/00, page 64 of 64 H8S, H8/300 Series High-performance Embedded Workshop, Hitachi Debugging Interface Tutorial Publication Date: 1st Edition, December 2000 Published by: Electronic Devices Sales & Marketing Group Semiconductor & Integrated Circuits Hitachi, Ltd. Edited by: Technical Documentation Group Hitachi Kodaira Semiconductor Co., Ltd. Copyright © Hitachi, Ltd., 2000. All rights reserved. Printed in Japan.