Using A Renesas Code Generation Tool For RL78 Devices - LabProcedures
Using A Renesas Code Generation Tool For RL78 Devices - LabProcedures
Lab Objectives
1. How to Generate RL78 code for IAR
platform using Applilet
2. Edit/Compile/build/debug the project in
2
e studio
Skill Level
2
1. New to RL78/Applilet/e studio Tools
2. This is so easy anyone can do it
Lab Materials
Please verify you have the following materials at
your lab station.
2
Laptop PC with e studio /Applilet 3 tools preinstalled
YRDKRL78-G14 Target board
USB cable
This lab sheet
Lab Sections
1
2
3
4
5
Page 1 of 20
LAB PROCEDURE
Procedural Steps
Step 2.1
Open Applilet Start -> All Programs -> Applilet -> Applilet3 for RL78_G14 -> V1.01.01.
Step 2.2
From Applilet3, select File>New. This will open New Project window. Enter the options
below to configure project environment for R5F104PJ device.
Page 2 of 20
LAB PROCEDURE
Kind of project = Project for
RL78/78K0R
Using microcontroller =
RL78/G14(ROM:256KB)->
R5F104PJ(100pin)
Using Build Tools = IAR
Compiler
Project name =myRL78Project
Place = C:\workspace
Click OK to make project
framework.
Step 2.3
The next screen shows the Applilet Code Generator. The screen includes all the peripheral
available in the device. You may recognize this from CubeSuite+ or from previous Applilet
versions.
Page 3 of 20
LAB PROCEDURE
Step 2.4
The first thing to decide is how the Pin assignment is set. This setting can only be done
once per project. For this project, set it to Default assignment by clicking Fix settings.
Other settings are handy for projects that need enhanced serial or timer
functionalities.
Step 2.5
Select Clock setting tabs and Review the Power and Clock settings. Leave all setting as
default setting.
Step 2.6
Select the On-Chip Debug setting Tab and make these settings:
On-Chip Debug
operation setting:
Used
Page 4 of 20
LAB PROCEDURE
Step 2.7
Review Confirming Reset Source and Function Safety tab and leave the setting to its
default.
Step 2.8
Double Click on Port from Project tree window to open the port tab.Select Port4 tab, and
set bit 1 as output, with level at 1. This is for driving the on-board LED15 (other pins should
be left as unused).
Step 2.9
The Interrupt, Serial, A/D Converter, D/A converter tabs are not used in this example, so we
will skip those.
Step 2.10 Next, Select Timer from the project tree. Select Channel 0 as interval timer.
Page 5 of 20
LAB PROCEDURE
Step 2.12 Select Watch Dog Timer tab from the project tree, and set the Watchdog Timer operating
setting as UNUSED.
Step 2.13 Look at but dont change the settings for Real Time Clock, Interval timer, Comparator, Clock
Output/Buzzer output, Data Transfer Controller, Event Link Controller, and Voltage Detector.
We will leave these at their defaults.
Page 6 of 20
LAB PROCEDURE
The Code Generator produces all the primary setup code for each peripheral chosen in
the design. It generates a source file for the primary configuration settings and a user file for
allowing the user to customize use the function of the peripheral and add associated
application code (i.e. r_cg_timer.c and r_cg_timer_user.c)
Page 7 of 20
LAB PROCEDURE
Macro.html file
Applilet can also generate report in CSV format apart from the html format.
Step 2.18 Exit Applilet3, File-> Exit.
Question
1. Name the compiler options supported by the Applilet for code
generation?
Page 8 of 20
LAB PROCEDURE
This section explains how to bring the Applilet code to e studio workspace.
Procedural Steps
Step 3.1
Step 3.1
Step 3.2
Start -> All Programs -> Renesas Electronics e studio -> Renesas e studio.
In the Workspace Launcher, select C:\Workspace or any other directory where you want to
create the project.
A window similar to the one will appear. Close the Welcome window.
Page 9 of 20
LAB PROCEDURE
Step 3.3
Click FileNew C Project, a below window will open. Enter the below information
and click Next.
Step 3.4
Step 3.5
In the next window browse the path for the IAR tool chain as C:\Program Files\IAR
Systems\Embedded Workbench 6.0_2 and click OK.
Select the RL78 device R5F104PJ and click the Finish button.
Page 10 of 20
LAB PROCEDURE
Step 3.6
Step 3.7
Step 3.8
Now Applilet generated code for IAR compiler will be imported to e studio's project file.
Click FileImport. Select File System under General category in the import window and
click Next.
There is a "From directory" textbox near the top, press the "Browse" button next to it in
order to go to the directory where you generated the code from the Applilet and select
Applilet3_src .
Page 11 of 20
LAB PROCEDURE
Step 3.9
Put a check mark on applilet3 _src as shown below to select all files under this folder.
Under options, put a check mark on Create complete folder structure and Click
Finish.
Step 3.10
You will see a new folder added in the project explorer window applilet3_src including all
the source file and header files generated by the Applilet.
Page 12 of 20
LAB PROCEDURE
Question
2
2. Can you guess if it is possible to open the IAR project directly from e studio
without importing source files?
Page 13 of 20
LAB PROCEDURE
Procedural Steps
Step 4.1
Before editing the source file, build the project Project Build All to make sure there
is no compilation error in the Applilet generated code. The Console window will show the
results of the build command.
Step 4.2
Open the cg_main.c file and add the R_TAU0_Channel0_Start(); in main(). Make sure
the code is written under the user code area marked as below to avoid overwriting the
code when code is re-generated from Applilet.
/* Start user code for adding. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
Page 14 of 20
LAB PROCEDURE
Step 4.3
Step 4.4
Page 15 of 20
LAB PROCEDURE
Procedural Steps
Step 5.1
Step 5.2
Page 16 of 20
LAB PROCEDURE
Step 5.3
Connect the RDK board to PC via USB cable. Make sure RDK board has DIP switch SW5
setting as below:
1: ON, 2:OFF, 3:ON, 4: ON
Step 5.4
Step 5.5
Click on the Debugger tab and select the Debug hardware as E1(RL78) and Target device as
R5F104PJ.
Page 17 of 20
LAB PROCEDURE
Step 5.6
Step 5.7
Click yes, to confirm the perspective switch from C/C++ to Renesas Debug perspective.
Step 5.8
Go to r_cg_timer_user.c, line 59 (Approx) and put a break in the following line of code.
Step 5.9
Step 5.10
Run the program. The program will break at Interval timer interrupt function.
Remove the break point by double clicking on the breakpoint.
to run the program and observe the LED15 on the RDK board.
Page 18 of 20
LAB PROCEDURE
Procedural Steps
Step 6.1
Step 6.2
Step 6.3
Click on Build Artifact tab and replace the default Artifact extension from d87 to mot.
Page 19 of 20
LAB PROCEDURE
Step 6.4
Step 6.5
A folder name Release will be created and added in the project tree which includes the
output file myProject.mot.
Question
3. What is the default output format for the IAR tool chain in e2studio?
Page 20 of 20