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 gen
Trang 11.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 new
Eclipse-based IDE, e2studio enviornment, Build and run the project in e2studio using IAR Tool chain This lab will work through the Applilet configuration for system and peripherals setting and e2studio
configuration to edit, build the project
Lab Sections
1 Generate IAR Project using Applilet 2
2 Bring Applilet code to e2studio 9
3 Edit and Build the Project 14
4 Debug and Run the Program 16
5 Output File for Renesas Programmer 19
Lab Objectives
1 How to Generate RL78 code for IAR
platform using Applilet
2 Edit/Compile/build/debug the project in
e2studio
Skill Level
1 New to RL78/Applilet/e2studio 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 e2
studio /Applilet 3 tools pre-installed
• YRDKRL78-G14 Target board
• USB cable
• This lab sheet
Trang 22 Generate IAR Project using Applilet
Overview:
This lab section will step through the system and peripheral setting and generates the device driver code for 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: P41
Timer 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 options
below to configure project environment for R5F104PJ device
Trang 3Kind 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
Trang 4Step 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”
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 Other settings are handy for projects that need enhanced serial or timer
functionalities
Trang 5
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
The security ID is used to prevent unauthorized debugger connection By
default, this value is 20, 0's
Trang 6Step 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 operating
setting as UNUSED
Step 2.13 Look at but don’t 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
Step 2.14 Click Generate Code button, and note the messages below It should
report that the project was created successfully
Trang 7Step 2.15 Save the project, “File->Save”
Step 2.16 Go to OptionsGenerate Type and notice the default Code generator configuration setting
as “Merge files” In order to retain previous and incorporate new information, it is necessary
to use merge files This allows not to overwrite any user modified code entered in section
designated 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, which
shows the functions generated by the Applilet You can look at this later in HTML format if you 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” 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)
Trang 8Macro.html file
Step 2.18 Exit Applilet3, “File-> Exit”
Applilet can also generate report in CSV format apart from the html format
Question
1 Name the compiler options supported by the Applilet for code generation?
Trang 93 Bring Applilet code to e2
Overview:
studio
This section explains how to bring the Applilet code to e2studio workspace
Procedural Steps
Step 3.1 Start -> All Programs -> Renesas Electronics e2studio -> Renesas e2studio
Step 3.1 In the Workspace Launcher, select C:\Workspace or any other directory where you want to
create the project
Step 3.2 A window similar to the one will appear Close the “Welcome” window
Trang 10Step 3.3 Click “FileNew C Project”, a below window will open Enter the below information
and click Next
Project Name myProject
Project type IAR RL78 Executable
Toolchains IAR Toolchain for RL78
Step 3.4 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
Step 3.5 Select the RL78 device “R5F104PJ” and click the Finish button
Trang 11Step 3.6 A Project will be created “myProject”
Step 3.7 Now Applilet generated code for IAR compiler will be imported to e2studio's project file
Click FileImport Select “File System” under General category in the import window and click “Next”
Step 3.8 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
Trang 12Step 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
Trang 13
Question
2 Can you guess if it is possible to open the IAR project directly from e2studio
without importing source files?
Trang 144 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 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 */
Trang 15Step 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
Trang 165 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++ BuildSettingIAR RL78 XLINK linkerOutput” Change the format
from default “C SPY(ubrof)” to “ELF/Dwarf” and Format variant to “Renesas compatible
(-yspc)”
Trang 17Step 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 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 as
R5F104PJ
Trang 18Step 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
Trang 196 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 This section 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++ BuildSettingIAR RL78 XLINK linkerOutput” Change the output
format from default“C SPY(ubrof)” to “Motorola”
Step 6.3 Click on Build Artifact tab and replace the default Artifact extension from d87 to mot
Trang 20Step 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 the
output file myProject.mot
Question
3 What is the default output format for the IAR tool chain in e2studio?