Renesas M16C, М26A User Manual

REG10J0041-0400
Renesas Starter Kit for M16C/26A
Tutorial Manual
RENESAS 16-BIT SINGLE-CHIP MICROCOMPUTER
M16C FAMILY / M16C/Tiny SERIES
Rev.4.00 Renesas Technology Europe Ltd. Revision date: Oct.22,2007 www.renesas.com
Table of Contents
Chapter 1. Preface..................................................................................................................................................1
Chapter 2. Introduction............................................................................................................................................2
Chapter 3. Tutorial Project W orkspace ...................................................................................................................3
Chapter 4. Project Workspace................................................................................................................................4
4.1. Introduction...................................................................................................................................................4
4.2. Creating a new Project Workspace..............................................................................................................4
4.3. Build Configurations and Debug Sessions...................................................................................................5
4.3.1. Build Configuration ................................................................................................................................5
4.3.2. Debug Session.......................................................................................................................................5
Chapter 5. Building the Tutorial Project ..................................................................................................................6
5.1. Building Code...............................................................................................................................................6
5.2. Connecting the debugger.............................................................................................................................7
5.3. Connecting to the target with the E8a..........................................................................................................7
Chapter 6. Downloading and Running the Tutorial.................................................................................................9
Chapter 7. Project Files.........................................................................................................................................14
7.1. Standard Project Files ................................................................................................................................14
7.1.1. Initialisation code (resetprg.c / resetprg.h) ..........................................................................................14
7.1.2. Board initialisation code (hwsetup.c / hwsetup.h)................................................................................15
7.1.3. Main tutorial code (main.c / main.h).....................................................................................................16
Chapter 8. Additional Information..........................................................................................................................17

Chapter 1. Preface

Cautions
This document may be, wholly or partially, subject to change without notice. All rights reserved. Duplication of this document, either in whole or part is prohibited without the written permission of Renesas
Technology Europe Limited.
Trademarks
All brand or product names used in this manual are trademarks or registered trademarks of their respective companies or organisations.
Copyright
© Renesas Technology Europe Ltd. 2007. All rights reserved. © Renesas Solutions Corporation. 2007. All rights reserved. © Renesas Technology Corporation. 2007. All rights reserved.
Renesas Europe Website: http://eu.renesas.com/ Renesas Global Website: http://renesas.com/
Glossary
CPU Central Processing Unit E8a E8a On-chip debugger module LCD Liquid Crystal Display LED Light Emitting Diode
MCU Microcontroller PC Program Counter PCB Printed Circuit Board RSK Renesas Starter Kit
1

Chapter 2. Introduction

This manual is designed to answer, in tutorial form, the most common questions asked about using a Renesas Starter Kit: The tutorials help explain the following:
How do I compile, link, download, and run a simple program on the Renesas Starter Kit?
How do I build an embedded application?
How do I use Renesas’ tools?
The project generator will create a tutorial project with two selectable build configurations
‘Debug’ is a project built with the debugger support included.
‘Release’ build demonstrating code suitable for release in a product.
Files referred to in this manual are installed using the project generator as you work through the tutorials. The tutorial exam ples in this manual assume that installation procedures described in the Renesas Starter Kit Quick Start Guide have been completed. Please refer to the Quick Start Guide for details of preparing the configuration.
NOTE: These tutorials are designed to show you how to use the Renesas Starter Kit and are not intended as a comprehensive introduction to the High-performance Embedded Workshop debugger, the compiler tool-chains or the E8a Emulator – please consult the relevant user manuals for more in-depth information.
2
Chapter 3. Tutorial Project Workspace
The workspace includes all of the files for two build configurations. The tutorial code is common to both the Debug and the Release build configurations. The tutorial is designed to show how code can be written, debugged then downloaded in a ‘Release’ situation. The build configuration menu in High-performance Embedded Workshop allows the project to be configured such that certain files may be excluded from each of the build configurations. This allows the inclusion of the debug monitor within the Debug build, and its exclusion in the Release build. Contents of common C files are controlled with defines set up in the build configuration options and #ifdef statements within the same files. Maintaining only one set of project files means that projects are more controllable.
3

Chapter 4. Project Workspace

4.1. Introduction

High-performance Embedded Workshop is an integrated development tool that allows the user to write, compile, program and debug a software project on any of the Renesas Microcontrollers. High-performance Embedded Workshop will have been installed during the installation of the software support for the Renesas Starter Kit product. This manual will describe the stages required to create and debug the supplied tutorial code.

4.2. Creating a new Project Workspace

To look at the program, start High performance Embedded Workshop from the Windows Start Menu. Open a new tutorial workspace from the [File -> New Workspace…] menu or select ‘Create a new project workspace’ when presented with
the ‘Welcome!’ dialog.
The example above shows the New Project Workspace dialog with the RSKM16C26A selected.
Select the ‘M16C’ CPU family and ‘RenesasM16C Standard’ Tool-chain.
Select the ‘E8A_RSKM16C26A’ Project type for the Renesas Starter Kit from the project list.
Enter a name for the workspace, all your files will be stored under a directory with this name.
The project name field will be pre-filled to match the workspace name above; this name may be changed.
Note: High-performance Embedded Workshop allows you to add multiple projects to a workspace. You may add the sample code projects later so you may wish to choose a suitable name for the Tutorial project now.
Click <OK> to start the Renesas Starter Kit Project Generator wizard.
4
The next dialog presents the three types of example projects available.
1. Tutorial: This is the one of interest at this time; the code will be explained later in this manual.
2. Sample code: this provides examples for using various peripherals. If you select this and click <Next> it will open a new dialog allowing the selection of many code examples for the peripheral modules of the device.
3. Application: where the debugger is configured but there is no program code. This project is suitable for the user to add code without having to configure the debugger.
Select “Tutorial” as the type of project to generate and then click “Next”.
Click “Finish” to create the project
The project generator wizard will display a confirmation dialog. Press ‘OK’ to create the project and insert the necessary files. A tree showing all the files in this project will appear in High-performance Embedded Workshop.
To view the file ‘main.c’, double click on the file in the Workspace window. A new window will open showing the code.

4.3. Build Configurations and Debug Sessions

The workspace that has been created contains two build configurations and two debug sessions. The Build Configuration allows the same project to be built but with different compiler options. The options available to the user are described fully in the High-performance Embedded Workshop Users Manual.

4.3.1. Build Configuration

The build configurations are selected from the left hand drop down list on the tool bar. The options available are Debug and Release. The debug build is configured for use with the debugger. The Release build is configured for final ROM-able code.
A common difference between the two builds may be the optimisation settings. With Optimisation turned on the Debugger may seem to execute code in an unexpected order. To assist in debugging it is often helpful to turn off optimisation on the code being debugged.
Select the ‘Debug Build’ Configuration.

4.3.2. Debug Session

The debug sessions are selected from the right hand drop down list on the tool bar. The options vary between Renesas Starter Kit however one will always start Debug and include the type of debug interface. The alternate selection will be ‘DefaultSession’. The purpose of the debug sessions is to allow the use of different debugger tools or different debugger settings on the same project.
Select the ‘SessionM16C_E8a_SYSTEM’
debug session.
5
Loading...
+ 14 hidden pages