Presentation is loading. Please wait.

Presentation is loading. Please wait.

Renesas Technology America Inc. 1 M16C Seminars Lab 3 Creating Projects Using HEW4 14 March 2005 M16C Seminars Lab 3 Creating Projects Using HEW4 Last.

Similar presentations


Presentation on theme: "Renesas Technology America Inc. 1 M16C Seminars Lab 3 Creating Projects Using HEW4 14 March 2005 M16C Seminars Lab 3 Creating Projects Using HEW4 Last."— Presentation transcript:

1 Renesas Technology America Inc. 1 M16C Seminars Lab 3 Creating Projects Using HEW4 14 March 2005 M16C Seminars Lab 3 Creating Projects Using HEW4 Last Updated:14 March 2005

2 14 March 2005 2 HEW4 M16C/Tiny Tutorial 2Overview In this lab, you will create new projects for the M16C using two different methods. The first method uses the SKP project generator, that will create an empty project. The second method will provide step by step instructions on creating a project with existing source files. Specific examples are shown throughout this tutorial using the SKP16C26A. The SKP16C28 and SKP16C29-CL are similar in all respects.

3 14 March 2005 3 HEW4 M16C/Tiny Tutorial 2 Starting HEW 1.From the Windows Start menu, click on Programs > Renesas > High-performance Embedded Workshop > High-performance Embedded Workshop

4 14 March 2005 4 HEW4 M16C/Tiny Tutorial 2 Creating a New Project using the SKP Project Generator 1.Select ‘Create a new project workspace’ when the “Welcome!” dialog box appears. 2.Click 2 1

5 14 March 2005 5 HEW4 M16C/Tiny Tutorial 2 Creating a New Project with the SKP project generator 1.Verify the Tool Chain is “Renesas M16C Standard” 2.Verify the CPU family is “M16C”. 3.Select the Project type “M16C/26A Starter kit Plus”. 4.Enter “Tutor2_pg” for the Workspace Name. 5.Click 1 2 3 4 5

6 14 March 2005 6 HEW4 M16C/Tiny Tutorial 2 Creating a New Project with the SKP project generator (Cont.) 1.Select “Empty Project”. 2.Click 3.Click Note: The other project selections (Verify SKP and Sample Code) allow you to test the SKP and evaluate the MCU peripherals and features using pre-built sample code. 1 2

7 14 March 2005 7 HEW4 M16C/Tiny Tutorial 2 SKP Project Generator - Summary The following is a summary of what happens when creating a new project using the SKP project generator Empty Project: 1.The following files are created in the workspace or project directory (in this example, under C:\Workspace\Tutor2_pg\Tutor2_pg):  A copy of the user startup code (ncrt0_26Askp.a30 and sect30_26askp.inc).  A.c file (main_26askp_template.c) that contains the main function.  Copies of the SKP header files (sfr26A.h, skp_bsp.h, and skp_lcd.h)  A copy of the sfr_26a_labels.a30 file so SFR labels are visible in the debugger. 2.Creates a debug session for using the FoUSB ICD. 3.Links the startup files first as shown in the “Linking the startup files first” slides. 4.Adds the phase to generate a hex file when building the project as shown in the slide “Generate a hex file for the Programmer”.

8 14 March 2005 8 HEW4 M16C/Tiny Tutorial 2 Creating a New Project Environment The SKP project generator greatly simplifies the creation of a new project. BUT, the only way you will understand this is if you have to build a project from scratch. (Wow. Better you then me…) Ok, my boss made me give you a little help, we are going to give you the original source files. The following slides will walk you through the project creation process: Create a new workspace from scratch Add source files Setup the software development environment including the linker, build, debugger, and programming configuration

9 14 March 2005 9 HEW4 M16C/Tiny Tutorial 2 Creating a New Project (Page 1 of 9) 1.From the pull down menu, select “File -> New Workspace”. 2.Verify the Tool Chain is “Renesas M16C Standard” 3.Verify the CPU family to “M16C”. 4.Select the Project type “Application”. 5.Click on Browse to and surf to C:\Renesas\SKP16C26A\Sample _Code 6.Enter “Tutor2” for the Workspace Name. 7.Click 2 3 5 6 7 4

10 14 March 2005 10 HEW4 M16C/Tiny Tutorial 2 Creating a New Project (Page 2 of 9) 1.Verify the Toolchain Version is “5.30.02”. 2.Change the CPU Series to “M16C/Tiny”. 3.Click 1 2 3

11 14 March 2005 11 HEW4 M16C/Tiny Tutorial 2 Creating a New Project (Page 3 of 9) 1.Change the Target type to “M16C/Tiny”. 2.Change the Startup file type to “USER” 3.Click 1 2 3

12 14 March 2005 12 HEW4 M16C/Tiny Tutorial 2 Creating a New Project (Page 4 of 9) 1.Unselect ‘Use Heap Memory’ 2.Where asked about generating a main() function, change to ‘None’ (we will be giving you a main() function). 3.Select ‘Use FoUSB’ 4.Click 1 2 3 4

13 14 March 2005 13 HEW4 M16C/Tiny Tutorial 2 Creating a New Project (Page 5 of 9) The stack settings are grayed out because the USER startup file was selected on page 3 of 8. If DEFAULT startup file had been selected, these settings would have been available. 1.Click 1

14 14 March 2005 14 HEW4 M16C/Tiny Tutorial 2 Creating a New Project (Page 6 of 9) 1.Select the Target ‘M16C_R8C_FoUSB/UART’ 2.Click 1 2

15 14 March 2005 15 HEW4 M16C/Tiny Tutorial 2 Creating a New Project (Page 7 of 9) 1.Click 1

16 14 March 2005 16 HEW4 M16C/Tiny Tutorial 2 Creating a New Project (Page 8 of 9) We already have the source files and selected USER startup files (see Creating a New Project Pages 3 and 4), so there are no source files that will be generated. 1.Click Did anyone notice we went from x/6 to x/7 in the titles? 1

17 14 March 2005 17 HEW4 M16C/Tiny Tutorial 2 Creating a New Project (Page 9 of 9) A project summary is displayed to indicate a successful creation of the new project, tutor2. 1.Click

18 14 March 2005 18 HEW4 M16C/Tiny Tutorial 2HEW After creating the project, HEW will look similar to the figure below.

19 14 March 2005 19 HEW4 M16C/Tiny Tutorial 2 Default and User (SKP) Startup Files Default startup files (ncrt0.a30 and sect30.inc) are included with HEW. Typically the user will need to edit these files depending on which MCU you are using. Customized startup files are included with the SKP’s. For the /26A SKP the files are called ncrt0_26askp.a30 and sect30_26askp.inc. In many cases users can use these startup files for their target applications with no modification. If you did not purchase a starter kit, but wish to obtain these files, visit our SKP website at: www.renesas.com/skpwww.renesas.com/skp

20 14 March 2005 20 HEW4 M16C/Tiny Tutorial 2 Adding Source Files (Page 1 of 2) 1.From the ‘Project’ Pull Down Menu select ‘Add Files…’. 2.Change the Look in directory to: ‘C:\Renesas\SKP16C26A\ Sample_Code\Tutor2_src’. 3.Select the two files ‘main_tutor2.c’ and ‘ncrt0_26askp_tutor2.a30’. 4.Click on ‘Add’. 2 3 4

21 14 March 2005 21 HEW4 M16C/Tiny Tutorial 2 Adding Source Files (Page 2 of 2) After adding the source files, HEW’s workspace will look like this. If your workspace looks slightly different, configure the view to make it the same. (Right click in the project Window to get this option.) Displaying the source file dependencies this way makes it easier to verify if the header files are included before building a project.

22 14 March 2005 22 HEW4 M16C/Tiny Tutorial 2 M16C Linkage Order After checking dependencies, HEW4 must be setup to link the startup files first. The startup files contain information on memory addresses and sections which the linker uses to place the code at the correct addresses. Note if the startup file is named “Ncrt0.a30”, HEW4 will automatically link it first. If you configure the Project Window to show the files in time order, you will see the files in the order that they will be sent to the linker. If you go through the Tutor2 code in the order it will be linked, the first code that is linked defines the section information. (You will find it in the include file, sect30_26askp_tutor2.inc, starting on line 118.)

23 14 March 2005 23 HEW4 M16C/Tiny Tutorial 2 Link Order (M16C Toolchain Version 5.30.02 and later) By default, HEW links the Project files in alphabetical order. BUT, when using M16C toolchain version 5.30.02 and HEW 4.0 (or latter), you have the ability to manually control the link order! To manually control the link order, select “Build -> Linkage Order”

24 14 March 2005 24 HEW4 M16C/Tiny Tutorial 2 Linking the Startup File First 1.Check the box ‘Use custom linkage order’ 2.Select the file ‘ncrt0_26askp_tutor2.r30’ 3.Click ‘Move to top’ This configuration is done, lets copy it to the rest of the configurations 4.Click 5.Use the up and down arrows to select another configuration (these are just below the down arrow that you can see) 6.Click 7.Repeat for the remaining configurations. 8.Close the Linkage Order Window 1 2 3 4

25 14 March 2005 25 HEW4 M16C/Tiny Tutorial 2 Defining an Include Directory For this SKP, files that are common to all the sample code are kept in a directory named “\Common” under “\Sample_Code”. An example is the register definition file “sfr.h” that is included for all the projects, yet never needs to be modified. Because of this, we need to setup HEW so it knows where to look for these files during compile time. 1.From the ‘Build’ pull down menu, select ‘Renesas M16C Standard Toolchain’ 2.Change the Configuration to “All Configurations” 3.Click 4.Set the Relative to: option to ‘Custom directory’ and the Directory: to ‘C:\Renesas\SKP16C26A\ Sample_Code\Common’ 5.Click 6.Click 2 3 4 5

26 14 March 2005 26 HEW4 M16C/Tiny Tutorial 2 Building (compile & link) the Program 1.Click on the ‘Build’ icon. 2.Look in the Build tab of the Output Window. 3.If there are No Errors or Warnings, skip to page 30. 4.If there are Warnings, look at the note on the next page. 5.If there are Errors, you did something wrong. You will need to trace back your steps to see where you went wrong.

27 14 March 2005 27 HEW4 M16C/Tiny Tutorial 2 If You Get Warnings If you only got 1 Warning, verify that it was associated with the linker limiting the output to 64K (> 60 days). If this is the case, go to the next page: If you get more than 1 Warnings when you compile, you probably did not define the link order correctly. Go back to page 26 and define the linkage order.

28 14 March 2005 28 HEW4 M16C/Tiny Tutorial 2Optimization By default all optimization is turned off. Lets compare code size when optimization is turned off, to when it is on. Scroll up in the Build Tab of the Output window and find the code size. Non-optimized code size = ________________Bytes Now lets turn on optimization. From the ‘Build’ menu, select ‘Renesas M16C Standard tool chain’

29 14 March 2005 29 HEW4 M16C/Tiny Tutorial 2Optimization 1.Select ‘All configurations’ 2.Select ‘Tutor2’ Files 3.Change the Category to ‘Optimize’ 4.Enable Optimization Level: ‘[-O3]’ 5.Enable ‘Size or Speed:’ 6.Click 1 2 3 4 5 6

30 14 March 2005 30 HEW4 M16C/Tiny Tutorial 2Optimization Re-Build the now that optimization is on. Scroll up in the Build Tab of the Output window and find the code size. Optimized code size = ________________Bytes NOTE: The NC30 compiler also includes an advance optimization utility, ‘utl30.exe’ (see the NC30 manual).

31 14 March 2005 31 HEW4 M16C/Tiny Tutorial 2 Generate a hex file for the Programmer After building a program, a file with an.x30 extension is generated. For this example, ‘tutor2.x30’ is generated. This file contains information for the debugger and are downloaded using HEW. However, device programmers, including the E8 and FoUSB programmers, use hex files in Motorola or Intel format. Lets setup HEW to automatically generate a.mot file during a build. With the feature enabled, a hex (.mot) file is created when building the project. Look for a Tutor2.mot file in the C:\Renesas\SKP16C26A\Sample_Code\Tutor2\ Tutor2\Debug’ folder. 1.From the ‘Build Menu’, select ‘Build Phases’ 2.Make sure the ‘M16C Load Module Converter’ is enabled. 3.Click

32 14 March 2005 32 HEW4 M16C/Tiny Tutorial 2 End of Lab 3


Download ppt "Renesas Technology America Inc. 1 M16C Seminars Lab 3 Creating Projects Using HEW4 14 March 2005 M16C Seminars Lab 3 Creating Projects Using HEW4 Last."

Similar presentations


Ads by Google