renesas technology america inc. m16c hew4 lab 2: m16c tools introduction m16c hew4 lab 2: m16c tools...

46
Renesas Technology America Inc. M16C HEW4 M16C HEW4 Lab 2: Lab 2: M16C Tools Introduction M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

Upload: christian-blair

Post on 25-Dec-2015

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

Renesas Technology America Inc.

M16C HEW4M16C HEW4 Lab 2: Lab 2:

M16C Tools IntroductionM16C Tools Introduction

(Version 5)

Last Updated: 27 July 2005

Page 2: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

2HEW4 M16C/Tiny Tutorial 1

27 July 2005

OverviewOverview

The following is a brief introduction on how to develop and debug

M16C programs using HEW4 (High- performance Embedded

Workshop) and other Renesas software and hardware tools. The Lab

is based on the M16C/Tiny family of Starter Kits. These kits include

SKP16C26A, SKP16C28 and SKP16C29-CL.

Page 3: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

3HEW4 M16C/Tiny Tutorial 1

27 July 2005

The HEW / ICD Development ProcessThe HEW / ICD Development Process

NC30 CompilerNC30 Compiler

Absolute file

“.x30”

Absolute file

“.x30”

Workspaceand Source windows

Workspaceand Source windows AS30 Assembler

AS30 Assembler

HEW Editor window

HEW Editor window

LN30 LinkerLN30 Linker

Project files

Options and Settings

HEW

Build command

DebugSymbols

DebugSymbols

MachineCode

MachineCode

HEW Debugger

Builder: Error reportingBuilder: Error reporting

.r30files

.c

.h

.a30

.inc

Correct Errors

UART1

RAM

Flash

Monitor Flash

User Flash

Monitor RAMUser RAM

M16C/Tiny MCU

3. HEW sends the machine code to the M16C/Tiny SKP during downloads and uses the symbols for source level debugging

1. Write programs using text editor

5. Correct errors& repeat process

Host PC

2. HEW automates compile & link

I/O C

on

nec

tor IC

D

USB

4. Debugging info sent back & forth

SIOSKP16C/TinyBoard

Page 4: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

4HEW4 M16C/Tiny Tutorial 1

27 July 2005

M16C/Tiny SKP ConnectivityM16C/Tiny SKP Connectivity

Page 5: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

5HEW4 M16C/Tiny Tutorial 1

27 July 2005

M16C/Tiny SKP Board FeaturesM16C/Tiny SKP Board FeaturesM16C/Tiny MCU’s

• 20MHz Operating Frequency at 3.0V – 5V, 10MHz Operating Frequency at 2.7V – 5V

• 32~96kB Flash ROM, 2kB x 2 Virtual EEPROM, and 2~8kB RAM

• Up to 71 GPIO with 4 Key-on Wakeup Inputs• Up to 8 Timers plus a Watchdog Timer• Up to 24-channel 10-bit ADC• 2 DMAC• Up to 5 Serial IO’s (SIO’s) (supports I2C and SPI)• Voltage and Oscillation Failure Detection • Clock sources: Main (Xin), Sub (XCin), Internal R/C (ring)

Onboard Features• LED’s (3 User, 1 Power)• Removable 2-line x 8-character LCD• Pushbutton Switches (3 User, 1 Reset)• Thermistor and potentiometer on two A/D inputs• I/O available on Expansion Ports

Page 6: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

6HEW4 M16C/Tiny Tutorial 1

27 July 2005

ICD (RTA-FoUSB-MON)ICD (RTA-FoUSB-MON)The ICD (In-Circuit Debugger) provides power and a USB interface to the Host PC

and communicates commands and data to and from the M16C/Tiny SKP board via a synchronous serial interface.

As a debugging tool (during program debug), the ICD + HEW downloads a small kernel (or ROM Monitor) program with the user program to the M16C/Tiny SKP Board . This kernel provides a communication interface between the M16C/Tiny MCU and the ICD + HEW Debugger application on MCU status. While the kernel uses some resources of the M16C/Tiny, the operation of the ICD is transparent to the user’s program.

As a programming tool, the ICD + Flash-over-USBTM(FoUSB) Programmer can be used to download user programs to the M16C/Tiny MCU on the SKP Board and many other Renesas’ flash MCU’s (the ICD will support other Renesas flash MCU’s by downloading an MCU Monitor Image (MMI) file for a particular MCU thru HEW or FoUSB Programmer).

The ICD can be used with user’s target hardware providing the proper interface (details in RTA-FoUSB-MON manual, see www.renesas.com/skp )

NOTE: The kernel is only downloaded with the user program when Debugging but NOT

when using the FoUSB Programmer.

Page 7: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

7HEW4 M16C/Tiny Tutorial 1

27 July 2005

Development ToolsDevelopment Tools

HEW4An Integrated Development Environment (IDE) that invokes all necessary software for building your project. Also communicates with the ROM Monitor Program (in flash on the MCU) for program debug

NC30, NC30WAC-compiler. Conforms to ANSI C standards. If not registered within 60days, limits code size to 64k bytes and no support.

AS30Relocatable AssemblerSupports structured assembly language and a wide variety of macro instructions. Included with NC30WA

Flash-over-USB ProgrammerFlash programming software for Renesas Flash MCU’s.

Page 8: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

8HEW4 M16C/Tiny Tutorial 1

27 July 2005

HEW IDE OverviewHEW IDE Overview

HEW is an acronym for High-performance Embedded Workshop.

When writing a microcontroller (or any computer) program, the program is usually split into multiple files to make it easier to read and understand.

While exactly how the files are organized is up to the programmer, typically, the code is split up in a logical manner into various files (e.g. math functions in one file, serial port code in another, etc).

After all the files in a project are compiled and assembled, a linker resolves the final address of the code within a single file. These steps can be tedious and repetitive. To make the process simple, we use an Integrated Development Environment (IDE) called HEW.

Page 9: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

9HEW4 M16C/Tiny Tutorial 1

27 July 2005

Lab 2 Hands on SectionLab 2 Hands on Section

In this lab you will:

• Open and build a project in HEW

• Launch a Debug session and:

• download your program into the SKP hardware,

• set breakpoints,

• Step through your code, and

• open various debug windows.

• Edit a project file, re-build, download, and run the program

Page 10: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

10HEW4 M16C/Tiny Tutorial 1

27 July 2005

Start HEWStart HEW

1. From the Windows Start menu, click onPrograms > Renesas > High-performance Embedded Workshop > High-performance Embedded Workshop

Page 11: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

11HEW4 M16C/Tiny Tutorial 1

27 July 2005

Open a HEW WorkspaceOpen a HEW Workspace

1. Select ‘Browse to another project workspace’ when the “Welcome!” dialog box appears.

2. Click <OK>

2

1

Page 12: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

12HEW4 M16C/Tiny Tutorial 1

27 July 2005

Open a HEW Workspace (cont.)Open a HEW Workspace (cont.)

3. In the “Open Workspace” dialog box, Look in the ‘C:\Renesas\SKP16C26A\ Sample_Code\Tutor1’ folder.

4. Click on the Tutor1.hws file to select it. (The .hws file extension stands for HEW workspace file.)

5. Click <Open>

Page 13: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

13HEW4 M16C/Tiny Tutorial 1

27 July 2005

Auto-RecoveryAuto-Recovery

Is this cool or what?

PS. Do not expect to see this screen. I only saw it because I did not shut-down my machine correctly.

Page 14: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

14HEW4 M16C/Tiny Tutorial 1

27 July 2005

The HEW WorkspaceThe HEW WorkspaceHEW should look like the figure below.

Output window

Editor windowWorkspacewindow

Toolbars

Menu bar(Pull down menus)

A file may, or may not, be open in the Editor Window!

Page 15: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

15HEW4 M16C/Tiny Tutorial 1

27 July 2005

Workspace WindowWorkspace WindowThe Workspace Window has three tab windows: Projects, Templates, and Navigation.

The Projects tab gives you the easiest way to open a file. Simply double click on the file and it will open in the Editor Window.

Files are grouped by type (C, Assembly). Additionally, you can keep the dependent files together, or place them under the file that depends upon them. (We will look at this on the next page.)

Page 16: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

16HEW4 M16C/Tiny Tutorial 1

27 July 2005

Workspace WindowWorkspace Window

Lets change how dependent files are displayed.

1. Right-click within the Projects window

2. Select “Configure View…”.

3. Enable “Show dependencies under each file”.

4. Click <OK>

Notice the .h files under main_tutor1.c?

Page 17: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

17HEW4 M16C/Tiny Tutorial 1

27 July 2005

M16C Linkage OrderM16C Linkage Order

The 1st code that the linker needs to see is the section information!

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 Tutor1 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_tutor1.inc, starting on

line 118.)

Page 18: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

18HEW4 M16C/Tiny Tutorial 1

27 July 2005

Link OrderLink Order(M16C Toolchain Version 5.30.02 and later)(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!

We are going to cover how to manually control the linkage order in Lab 3.

So lets go on to other issues…..

Page 19: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

19HEW4 M16C/Tiny Tutorial 1

27 July 2005

HEW TipHEW Tip

When you first start using HEW, right click in every window and

see what options are available to that window.

Play with every option. See what they do.

This method is usually faster than going to the Top Menu’s (Pull

Down Menu’s).

Page 20: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

20HEW4 M16C/Tiny Tutorial 1

27 July 2005

Lets look at the Right Click options in

the Editor Window.

1. Double click on the file main_tutor1.c

in the project window. (This will bring

the file up for editing in the Editor

Window.)

2. Right-click within the Editor Window

3. Select

4. Right-click within the Editor

Window. Notice some of the

options are not available.

Editor (Source) WindowEditor (Source) Window

Page 21: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

21HEW4 M16C/Tiny Tutorial 1

27 July 2005

HEW ToolbarsHEW Toolbars

Editor Toolbar2 Debug Toolbar1

Bookmarks Toolbar2

Standard Toolbar

Templates Toolbar2

Debug Run Toolbar1

Search Toolbar2

Version ControlToolbar2

HEW is a powerful development environment with a lot of features and functionality. For this lab, the focus will be on features (i.e. Standard Toolbar) that will help you understand the M16C development process using HEW.

Notes: 1. M16C is supported by the Debug toolbars only on HEW 4.x and above.2. See HEW user’s manual about these toolbars.

Page 22: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

22HEW4 M16C/Tiny Tutorial 1

27 July 2005

Standard ToolbarStandard ToolbarBuild File Current Debugger

Session2Current Configuration2

View Workspace2

Launch external Debugger

ViewOutput2

Build

Build All

Stop

Launch Slave HEW2

Build File – builds1 a specific fileBuild – builds files that were modified since last buildBuild All – builds the whole project regardless of whether there were

modifications or notStop – stops a running build processCurrent Configuration – build configuration (e.g. for debug, optimized, etc)Current Debugger Session – debug session configuration Launch Debugger – calls defined external debugger

Notes:1. A ‘build’ means running certain files (e.g. source files) under some tools (e.g. compiler, linker) to

produce an output file (i.e. X30 or MOT executable files for M16C)2. See HEW Users Manual for details

Page 23: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

23HEW4 M16C/Tiny Tutorial 1

27 July 2005

Build (re-build) Tutor1Build (re-build) Tutor1

Let’s re-build the Tutor1 project into an executable module. This will re-compile and link all the source files.

1. Click the ‘Build All’ icon.

If any of the source files are modified, clicking the ‘Build’ icon will result in compiling only the modified files. (This makes generating the executable module faster.)

Status, errors, messages, etc during a build process are displayed in the Output window...

(Always perform a ‘Build All’ when the configuration has changed.)

Build All(re-build)

Build

Page 24: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

24HEW4 M16C/Tiny Tutorial 1

27 July 2005

Output WindowOutput WindowThe major use of the Output window is to determine if any errors or warnings occurred during the build process.

The “0 Errors, 1 Warnings” OR “0 Errors, 0 Warnings” message will show up in this window when the build is finished.

Remember, we are using the Evaluation Version of the Toolchain so after 60 days, the output from the linker will be limited to 64K and you will get a Warning Message informing you of the same.

If errors had shown up during your build, you could have scrolled up to find the error message then double clicked on the message to bring up that line of code within the project.

or

Page 25: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

25HEW4 M16C/Tiny Tutorial 1

27 July 2005

HEW Debugging: OverviewHEW Debugging: OverviewHEW 4 integrates in-circuit Debugging. These features can be used to verify that the program we developed works exactly as we intended and when it does not, we can also use HEW to find out why.

Breakpoints can be set in HEW to stop the program at certain points and verify registers, variables in memory, etc. The number of breakpoints will vary from MCU to MCU. For M16C/26A, /28 and /29 the maximum number of breakpoints is 6.

HEW allows “step” execution in our program, which means the program executes on a per line basis (whether in source level or machine code level). Various windows in HEW allow us to see register values and memory locations

As the debugging features of HEW are fully integrated with the IDE, edit, compiling and debugging can be done in the same window.

Page 26: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

26HEW4 M16C/Tiny Tutorial 1

27 July 2005

HEW Debugger ExerciseHEW Debugger Exercise

In this part of the lab you will:

• Download and run a program on the M16C/Tiny SKP board

• General use of the Debugger including:

a) Stepping

b) Setting Breakpoints

• Modify the program, rebuild, and run the updated program

on the M16C/Tiny SKP board

Page 27: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

27HEW4 M16C/Tiny Tutorial 1

27 July 2005

Connect HardwareConnect HardwareSince you’ve just completed Lab 1, the SKP should be correctly connected to the Seminar Laptop. Just to verify that the hardware interface is ok, take a look at the blink rate of the yellow Status LED of the FoUSB. (Remember this from lab 1?)

If the Status (Yellow) LED is blinking once a second the USB driver for the FoUSB is loaded and working correctly, proceed to the next page.

BUT, if the Status LED is blinking three times a second, the FoUSB is not communicating with the Laptop. Disconnect the mini USB cable, wait a few seconds, and then plug it back in. If this does not work, please check Appendix. A Troubleshooting in the M16C/Tiny SKP user’s manual.

Page 28: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

28HEW4 M16C/Tiny Tutorial 1

27 July 2005

HEW debugging exampleHEW debugging example1. Launch a debugging session by pulling down the menu in the

“sessions” box and select M16C_R8C_FoUSB.

2. When the Init Window comes up, Click the “Run Mode” tab

2

Page 29: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

29HEW4 M16C/Tiny Tutorial 1

27 July 2005

RUN Mode (Just Some Notes)RUN Mode (Just Some Notes)Run Mode:

Set the mode in which you want the user program to run when executing Go or Come. With this debugger, the monitor program Periodically monitors the User Programs execution status to check whether the user program is halted by a break etc… This means the monitor program interrupts the CPU when executing the user program, and hence, the user program’s real-time capability is lost. To solve this problem, this debugger has two execution modes:

Sampling Mode:

The user program’s execution status is periodically monitored when executing Go or Come. (You will see updates to the variables in the HEW debugger while the user program is executing.)

Free Run Mode:

The user program’s execution status is NOT monitored while executing Go or Come. Use this mode for Real-Time capability!

Page 30: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

30HEW4 M16C/Tiny Tutorial 1

27 July 2005

Debug Init Window (cont.)Debug Init Window (cont.)

1. Verify “SamplingMode” is

selected.

2. Verify Sampling Period is set to

1000 m sec (Sample once a

second)

3. Click on <OK>

1

2

3

Page 31: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

31HEW4 M16C/Tiny Tutorial 1

27 July 2005

HEW Debug SessionHEW Debug Session

Edit window has not changed, but more buttons are available in the toolbar.

Open ‘Init’ window

Reset CPU

Go (run)

Reset go

Go to cursor

Step in:(execute 1 line of code)

Step overStep out

Stop run

Go to cursor

Display PC

Go free

Open Windows:Registers

C Watch

Asm Watch

Breakpoints

MemoryI/O

StatusRamMonitor

Page 32: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

32HEW4 M16C/Tiny Tutorial 1

27 July 2005

Download the executable fileDownload the executable file(with debugging information into the M16C/Tiny SKP Board)(with debugging information into the M16C/Tiny SKP Board)

1. In the project window,

right click on Tutor.x30 file

2. Select ‘Download Module’…

Note: When you download code,

the program counter is

automatically reset to the

address the reset vector

points to.

Page 33: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

33HEW4 M16C/Tiny Tutorial 1

27 July 2005

Download the executable file (Cont.)Download the executable file (Cont.)

After the download, three columns areadded to the Editor Window.

• Put a breakpoint on line 68. (Double click here. Where the Red Dot is.)

• Add a few breakpoints at other points in the code.

NOTE: You can only put a breakpoint where code exists. (Code exists when you see information in the Address Column.)

Also, if you double click on a breakpoint (red dot), it will disable the breakpoint.

Double clicking here changes pass count (# of times the

program will go through this breakpoint before stopping)

Address Column

View options:

Source

Mix

Disassembly

Page 34: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

34HEW4 M16C/Tiny Tutorial 1

27 July 2005

HEW Advanced Breakpoint Options HEW Advanced Breakpoint Options

1. Click on the S/W Breakpoints icon.

Notice Breakpoint information can be saved and loaded between sessions!

2. Click <Delete All>

a) Click <OK> (to delete all breakpoints)

3. Click <Close>

Page 35: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

35HEW4 M16C/Tiny Tutorial 1

27 July 2005

Running Downloaded ProgramRunning Downloaded Program

1. Click on the ‘Reset Go’ icon to run the program.

Note: The ‘STOP’ icon turns red.

On the board, the LED’s D1, D2, and D3 blink sequentially.

2. Turn the analog potentiometer clockwise to increase the LED blink rate.

3. Turn the potentiometer counter-clockwise to decrease the LED blink rate.

4. Click on the ‘Stop’ icon to halt program execution.

5. Click on the ‘Register’ icon to open the register view.(You may have to adjust the size of this window bydragging it.)

4 5

Page 36: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

36HEW4 M16C/Tiny Tutorial 1

27 July 2005

Program ‘Stepping’Program ‘Stepping’

1. Click on the ‘Step in’ icon several times.

2. Look in the ‘Register Window’. Register values that are changed turn red.

Page 37: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

37HEW4 M16C/Tiny Tutorial 1

27 July 2005

RAM Monitor WindowRAM Monitor Window

1. Click on the ‘RAM Monitor’ icon.(Icon with color in it!)

2. Inside the RAM Monitor Window, click on the ‘Base’ icon.

3. Verify that the Start address is set to 400.

4. Click <OK>.

Page 38: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

38HEW4 M16C/Tiny Tutorial 1

27 July 2005

RAM Monitor WindowRAM Monitor Window

The RAM Monitor displays the current value of the memory area shown in the window. Since we set the Run Mode to “Sampling Mode”, the monitor periodically samples the data viewed in the RAM monitor window and HEW updates the window with the sampled data.

2. Click on the ‘Go’ icon and watch as RAM data is updated.

Notice that when data is updated, the color is changed to Red.

Had we set the Run Mode to “Free Run”, the data inside the RAM Monitor Window would not be updated while the program is running. (Only after you pressed the STOP icon would HEW update the contents.)

3. Click the ‘STOP’ icon.

Page 39: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

39HEW4 M16C/Tiny Tutorial 1

27 July 2005

Memory WindowMemory Window

1. Click on the ‘Memory’ icon.

2. If the “Display Address” Dialog box

appears, enter:

a) Display Address = 400

b) Scroll Start Address: Leave at 0

c) Scroll end Address: Leave at 0FFFFF

d) Click <OK>

The ‘Memory Window’ displays the location and contents of memory.

The main difference between the ‘Memory Window’ and the ‘RAM

Monitor Window’ is the Memory Window DOES NOT update the data

during program execution. You MUST stop the program, then HEW will

update the contents. (Notice the different icons at the top of each

Window.)

Page 40: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

40HEW4 M16C/Tiny Tutorial 1

27 July 2005

C Watch WindowC Watch Window

1. Go back to the ‘Editor Window’ and

find line 91 in the file main_tutor1.c.

2. Left click on the variable ‘disp_cont’

(this makes sure your cursor is on

the right spot for step 3).

3. Right click on the variable ‘disp_cont’

and in the pop up menu select

‘Add C Watch’.

4. The Watch Window will appear. (You may have to adjust the size to

see useful information in this Window.) There are a lot of great

options in this window. Take the time to look around! (Local, File,

Global variables are also displayed here.)

Page 41: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

41HEW4 M16C/Tiny Tutorial 1

27 July 2005

I/O WindowI/O Window

1. Click on the ‘I/O’ icon.

2. If, when the I/O Window is opened it contains

useful information, skip to the next page, otherwise

you will need to define the micro that you

are dealing with.

A) Right click in the I/O Window.

B) Select “Load I/O File…”

C) Select “Browse”

D) Select “M16C26a.io”

E) Click on <Open>

F) Click on <OK> I/O Window when the micro is not defined!

Page 42: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

42HEW4 M16C/Tiny Tutorial 1

27 July 2005

I/O WindowI/O Window

The I/O Window allows you to

easily view peripheral register

contents and monitor the

status of your I/O port pins

without setting up complicated

watch variables or learning

where the address is for each

peripheral register. Also, the

I/O structures are grouped

together like A/D converter, or

Timer A1.

Page 43: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

43HEW4 M16C/Tiny Tutorial 1

27 July 2005

Modifying the ProgramModifying the Program1. Return to the file main_tutor1.c in the

Editor Window.2. Scroll down until and find the function

‘ta1_irq’ (line 83).

Note: You can also find a function by clicking the ‘Navigation’ tab in the project window and double click on the function name. (HEW shortens the names in the tabs if the window is too small. You may only see ‘Navi’.)

3. Change line 87 to read: “ta1 = (0x3FF – ad0);”

4. Save the revised file.5. Build the project.

Page 44: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

44HEW4 M16C/Tiny Tutorial 1

27 July 2005

Load (re-load) Modified ProgramLoad (re-load) Modified ProgramThe HEW debugger will automatically detect that the program has been

recompiled and ask if you wish to download again.

1. Click <Yes>

2. Click on the ‘Reset Go’ icon to run the new program.

3. Turn the analog potentiometer clockwise to decrease the LED blink

rate. (This is the opposite of before.)

4. Turn the potentiometer counter-clockwise to increase the LED blink

rate.

5. Click on the ‘Stop’ icon to halt program execution.

Page 45: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

45HEW4 M16C/Tiny Tutorial 1

27 July 2005

Save the SessionSave the Session

To stop a debug session but leave HEW open (i.e. edit only), re-open the default session.

1. Click on the Session pull down menu and change it to “DefaultSession”.

Page 46: Renesas Technology America Inc. M16C HEW4 Lab 2: M16C Tools Introduction M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

46HEW4 M16C/Tiny Tutorial 1

27 July 2005

End of Lab 2End of Lab 2

This is the end of lab 2.

If you finished early and time permits, try using the ‘GO to Cursor’ and ‘Display PC’ buttons…