8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
1/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 1 of 20
1.1.1.1 Using a Renesas Code Generation Tool for RL78 Devices
RL78
Description: This hands-on lab will step through how to generate the RL78 code for IAR compiler
using Renesas code generator tool, Applilet. Then bring the Applilet generated code to Renesas newEclipse-based IDE, e2studio enviornment, Build and run the project in e
2studio using IAR Tool chain. This
lab will work through the Applilet configuration for system and peripherals setting and e2
studioconfiguration to edit, build the project.
Lab Sections
1
Generate IAR Project using Applilet
...................................................... 22 Bring Applilet code to e2 studio ............................................................... 93 Edit and Build the Project .................................................................... 144 Debug and Run the Program ............................................................... 165 Output File for Renesas Programmer .................................................. 19
Lab Objectives 1. How to Generate RL78 code for IAR
platform using Applilet2. Edit/Compile/build/debug the project in
e2studio
Skill Level1. New to RL78/Applilet/e
2studio Tools
2. This is so easy anyone can do it
Time to Complete Lab 2 hours
Lab Materials Please verify you have the following materials at
your lab station.• Laptop PC with e
2studio /Applilet 3 tools pre-
installed
• YRDKRL78-G14 Target board
• USB cable
• This lab sheet
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
2/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 2 of 20
2 Generate IAR Project using Applilet
Overview:This lab section will step through the system and peripheral setting and generates the device driver codefor RL78 device. The project uses RL78G14 Family device, R5F104PJ
In this lab, we will create a project that blinks LED 15 every 100ms with timer interrupt.
I/O port: P41Timer Unit: Channel 0
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 optionsbelow to configure project environment for R5F104PJ device.
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
3/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 3 of 20
Kind of project = “Project forRL78/78K0R”
Using microcontroller = RL78/G14(ROM:256KB)->
R5F104PJ(100pin)
Using Build Tools = IARCompiler
Project name =‘myRL78Project
Place = C:\workspace
Click ‘OK to make projectframework.
Step 2.3 The next screen shows the Applilet Code Generator. The screen includes all the peripheralavailable in the device. You may recognize this from CubeSuite+ or from previous Appliletversions.
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
4/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 4 of 20
Step 2.4 The first thing to decide is how the Pin assignment is set. This setting can only be doneonce per project. For this project, set it to Default assignment by clicking “Fix settings”.
Step 2.5 Select “Clock setting” tabs and Review the Power and Clock settings. Leave all setting asdefault setting.
Step 2.6 Select the On-Chip Debug setting Tab and make these settings:
On-Chip Debugoperation setting:Used
Other settings are handy for projects that need enhanced serial or timerfunctionalities.
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
5/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 5 of 20
Step 2.7 Review “Confirming Reset Source” and “Function Safety” tab and leave the setting to itsdefault.
Step 2.8 Double Click on Port from Project tree window to open the port tab.Select Port4 tab, andset bit 1 as output, with level at 1. This is for driving the on-board LED15 (other pins shouldbe left as unused).
Step 2.9 The Interrupt, Serial, A/D Converter, D/A converter tabs are not used in this example, so wewill skip those.
Step 2.10 Next, Select Timer from the project tree. Select Channel 0 as interval timer.
The security ID is used to prevent unauthorized debugger connection. Bydefault, this value is 20, 0's.
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
6/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 6 of 20
Step 2.11 Select Channel 0 tabs. Set Interval value as 100ms.
Step 2.12 Select Watch Dog Timer tab from the project tree, and set the Watchdog Timer operatingsetting as UNUSED.
Step 2.13 Look at but don’t change the settings for Real Time Clock, Interval timer, Comparator, ClockOutput/Buzzer output, Data Transfer Controller, Event Link Controller, and Voltage Detector.We will leave these at their defaults.
Step 2.14 Click Generate Code button, and note the messages below. It shouldreport that the project was created successfully.
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
7/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 7 of 20
Step 2.15 Save the project, “File->Save”.
Step 2.16 Go to Options Generate Type and notice the default Code generator configuration settingas “Merge files” . In order to retain previous and incorporate new information, it is necessaryto use merge files. This allows not to overwrite any user modified code entered in sectiondesignated for the user area.
Step 2.17 Finally, the Applilet can generate a report on what it did. Go ahead and click the
File Output Report. The Applilet will generate two reports in the project directory-macro.html , shows the summary of the all peripheral settings and Function.html, whichshows the functions generated by the Applilet. You can look at this later in HTML format ifyou have time.
Function.html
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” f ile forallowing the user to customize use the function of the peripheral and add associatedapplication code (i.e. r_cg_timer.c and r_cg_timer_user.c)
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
8/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 8 of 20
Macro.html file
Step 2.18 Exit Applilet3, “File-> Exit”.
Applilet can also generate report in CSV format apart from the html format.
Question1. Name the compiler options supported by the Applilet for code
generation?
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
9/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 9 of 20
3 Bring Applilet code to e2
Overview:
studio
This section explains how to bring the Applilet code to e2
studio workspace.
Procedural Steps
Step 3.1 Start -> All Programs -> Renesas Electronics e2studio -> Renesas e
2studio.
Step 3.1 In the Workspace Launcher, select C:\Workspace or any other directory where you want tocreate the project.
Step 3.2 A window similar to the one will appear. Close the “Welcome” window.
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
10/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 10 of 20
Step 3.3 Click “File New C Project” , a below window will open. Enter the below informationand click Next.
Project Name myProject
Project type IAR RL78Executable
Toolchains IAR Toolchain forRL78
Step 3.4 In the next window browse the path for the IAR tool chain as “ C:\Program Files\IARSystems\Embedded Workbench 6.0_2” and click OK.
Step 3.5 Select the RL78 device “R5F104PJ” and click the Finish button.
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
11/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 11 of 20
Step 3.6 A Project will be created “myProject”.
Step 3.7 Now Applilet generated code for IAR compiler will be imported to e2
studio's project file.Click File Import. Select “File System” under General category in the import window andclick “Next”.
Step 3.8 There is a "From directory" textbox near the top, press the "Browse" button next to it inorder to go to the directory where you generated the code from the Applilet and select Appl il et3_src .
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
12/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 12 of 20
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 allthe source file and header files generated by the Applilet.
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
13/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 13 of 20
Question
2. Can you guess if it is possible to open the IAR project directly from e2studiowithout importing source files?
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
14/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 14 of 20
4 Edit and Build the Project
Overview:This section edit the source code for the target application and Build the imported project files.
Procedural Steps
Step 4.1 Before editing the source file, build the project “Project Build All” to make sure thereis no compilation error in the Applilet generated code. The Console window will show theresults of the build command.
Step 4.2 Open the cg_main.c file and add the “R_TAU0_Channel0_Start ();” in main(). Make surethe code is written under the user code area marked as below to avoid overwriting thecode when code is re-generated from Applilet.
/ * St art user code f or addi ng. Do not edi t comment generat ed here */ / * End user code. Do not edi t comment gener ated her e */
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
15/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 15 of 20
Step 4.3 Open r_cg_timer_user.c. Enter the highlighted code as below:
#pragma vector = INTTM00_vect __interrupt void MD_INTTM00(void){
/* Start user code. Do not edit comment generated here */
P4_bit.no1++;/* End user code. Do not edit comment generated here */
}
/* Start user code for adding. Do not edit comment generated here *//* End user code. Do not edit comment generated here */
Step 4.4 Build the project. Project->Build All.
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
16/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 16 of 20
5 Debug and Run the Program
Overview:This section describes how to launch the debugger and run the program on the target board.
Procedural Steps
Step 5.1 Right click on Project name “myProject” and click on Property tab.
Step 5.2 Click on “C/C++ Build
Setting
IAR RL78 XLINK linker
Output”. Change the formatfrom default “C SPY(ubrof )” to “ELF/Dwarf ” and Format variant to “ Renesas compatib le (-yspc)”.
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
17/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 17 of 20
Step 5.3 Connect the RDK board to PC via USB cable. Make sure RDK board has DIP switch SW5setting as below:
1: ON, 2:OFF, 3:ON, 4: ON
Step 5.4 Go to “Run Debug Configuration”. Double click on “Renesas GDB Hardware Debugging”.This will create a entry as myProject Debug . Click on “myProject Debug “under “Renesas
GDB Hardware Debugging”.
Step 5.5 Click on the Debugger tab and select the Debug hardware as E1(RL78) and Target device asR5F104PJ.
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
18/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 18 of 20
Step 5.6 Click “Debug” button to start the TK debugger.
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 Run the program. The program will break at Interval timer interrupt function.
Step 5.10 Remove the break point by double clicking on the breakpoint.
Step 5.11 Click Resume button to run the program and observe the LED15 on the RDK board.
Step 5.12 Click terminate button to stop the debugger.
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
19/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 19 of 20
6 Output File for Renesas Programmer
Overview:
In order for the target device to run in stand-alone mode, the application must be written to the flash. Thissection describes the procedure for how to generate an output file in Motorola hex format.
Procedural Steps
Step 6.1 Select the Build configuration from “Project-> Build Configurartion->set activeRelease
Step 6.2 Click on “C/C++ Build
Setting
IAR RL78 XLINK linker
Output”. Change the outputformat from default“C SPY(ubro f )” to “Motorola”.
Step 6.3 Click on Build Artifact tab and replace the default Artifact extension from d87 to mot.
8/20/2019 Using a Renesas Code Generation Tool for RL78 Devices_LabProcedures
20/20
LAB PROCEDURE
Using Renesas Code Generator Tool for RL78 Devices Page 20 of 20
Step 6.4 Build the project by “ProjectBuild All”.
Step 6.5 A folder name “Release “will be created and added in the project tree which includes theoutput file myProject.mot .
Question3. What is the default output format for the IAR tool chain in e2studio?