Step 1.2 Open e2studio by using the Shortcut on the Desktop: Step 1.3 When it gives you the option of choosing a Workspace directory, choose: C:\Workspace Step 1.4 Once e2studio is open
Trang 1Renesas e 2
RL78 Family Eclipse Labs
studio Getting Started
Description: e2studio introduction
Lab Sections
1 Setup 2
2 Hello World with GDB Simulator 6
3 Working with the RDKRL78G14 8
4 e2studio Views 11
5 e2studio Project Archives 12
Lab Objectives
1 Project Generator (RL78)
2 Hello World Creation
3 Renesas GDB Simulator
4 The RDK78G14 board and Hardware Debug
Skill Level
1 This is so easy anyone can do it
Time to Complete Lab
90 Minutes
Lab Materials
Please verify you have the following materials at your lab station
• Renesas e2
studio (1.1.0.25 or later)
• GNU RL78 12.02 Compiler or later
• This Handout
• RDKRL78G14 Board and USB Cable
Trang 21 Setup
Overview:
Getting Started
Procedural Steps
Step 1.1 On the RDK, ensure the switch SW5 is set to debug mode (ON, OFF, ON, ON)
Step 1.2 Open e2studio by using the Shortcut on the Desktop:
Step 1.3 When it gives you the option of choosing a Workspace directory, choose:
C:\Workspace
Step 1.4 Once e2studio is open at the Welcome page, click on the Workbench Arrow
Trang 3Step 1.5 Click File > New and create a new C Project
Step 1.6 Give it a name and select the GNURL78 Toolchain
Step 1.7 Select the most recent version of GNU Toolchain, choose E1(RL78) for the debugger and
choose RL78-G14 and R5F104PJ Click Next
Trang 4Step 1.8 Default Additional CPU option Click Next
Step 1.9 Use the default settings for basic optimization and library options Click Finish and Ok
remaining dialog box(s)
Trang 5Step 1.10 Your Workspace should now look like this
Trang 62 Hello World with GDB Simulator
Overview:
Get your blank project to do something useful
Procedural Steps
Step 2.1 Your Workspace should now look like this:
Expand out lab1 in the Project Explorer and look under the “src” directory for lab1.c – open it by double clicking
Feel free to have a look around at the other files and directories; they were created with the standard
project generator
Step 2.2 Launch the New Source File wizard (File > New > Source File) to create a new C source file
from the default template, name it incr.c in the src folder and add the following function to your new file:
unsigned int incr(unsigned int i) {
return i + 1;
}
Step 2.3 Launch the New Header File wizard (File > New > Header File) to create a new C header file
named incr.h in the src folder and add the following function prototype:
unsigned int incr(unsigned int i);
Trang 7Step 2.4 Edit the existing project file named lab1.c and replace all the existing code to introduce a local
unsigned integer variable, increment it in a loop using incr():
#include "incr.h"
int main(void) {
unsigned int n = 0;
while (1) {
n = incr(n);
} return 0;
}
Step 2.5 Build (Project > Build All)
Step 2.6 Highlight the Project in the Project Explorer window by clicking on it
Step 2.7 Click Run > Debug As > Renesas GDB Simulator Debug to connect to the Simulator
Step 2.8 Agree to the Perspective Switch – this is an important part of how to view screens in Eclipse
Step 2.9 If everything went well, you should be able to click the Restart button and then Step
through your code watching the local variables in the watch window as they come into scope
in each function
Step 2.10 Use the Resume (Not Run!) , Pause Step Into and Restart buttons to get a feel
for basic debugging
Step 2.11 When you are finished use the Terminate button to end the session
Trang 83 Working with the RDKRL78G14
Overview:
Work with e2studio to modify a project
Procedural Steps
Step 3.1 Switch back to the C/C++ perspective (Window > Open Perspective > C/C++)
Step 3.2 Right Click lab1 and Close Project This way it won’t build everytime you “Build All” as Build All
builds all open projects in the Workspace
Step 3.3 Create a new C project using the same settings as before, name it anything you like (lab 2
might make sense)
Step 3.4 Open the C source file with the main function
Step 3.5 Create a flashing LED with a delay using this code or your own interpretation
#include "iodefine.h"
int main( void)
{
// TODO: add application code here
PM6_bit.no5 = 0x00; // make output without using #define
while(j<200){
do {
i++;
} while (i<10000);
i =0;
j++;
} LED01 = ~LED01; // toggle LED
j=0;
i=0;
}
}
Step 3.6 Build
Trang 9Step 3.7 Click the arrow next to the Bug on the toolbar and select “Debug Configurations”
Then click the Debugger Tab and change the setting for Erase Flash ROM when Starting” to YES – This ensures that any demo code still on the MCU won’t get in the way of connecting to the debugger
Step 3.8 Click Debug and connect to the RDK G14 board
Step 3.9 Once in Debug mode click Restart and use the Resume , Pause buttons as before to
check your code is operating correctly
Trang 10Step 3.10 Modify which LEDs are flashing and their frequency (you choose how):
P42 GLED1 (P42) to R88-680 and LED4; Output 1 P43/SCK01/SCL01 GLED2 (P43) to R90-680 and LED6; Output 1 P44/SI01/SDA01 GLED3 (P44) to R92-680 and LED8; Output 1 P45/SO01 GLED4 (P45) to R94-680 and LED10; Output 1 P62/SSI00/SCLA1 RLED1 (P62) to R87-680 and LED3; Output 1 P63/SDAA1 RLED2 (P63) to R89-680 and LED5; Output 1 P64/TI10/TO10 RLED3 (P64) to R91-680 and LED7; Output 1 P65/TI11/TO11 RLED4 (P65) to R93-680 and LED9; Output 1 P66/TI12/TO12 RLED5 (P66) to R95-680 and LED11; Output 1 P67/TI13/TO13 RLED6 (P67) to R97-680 and LED13; Output 1
Step 3.11 Check your code changes using the Renesas GDB Hardware Debug
Trang 114 e2
Overview:
studio Views
Using e2studio to debug
Procedural Steps
Step 4.1 Using the working application you created in the previous lab, set a breakpoint by
double-clicking in the blue gutter to the left of the next line of code AFTER an LED toggle
Step 4.2 Click on the Breakpoints tab in the top right window (If no tab exists, click Window > Show
View > Breakpoints
Step 4.3 Note that your breakpoint was added to the list and can be enabled and disabled in the
Breakpoints View
Step 4.4 Now click the IO Registers tab (again if it is not up there, click Window > Show View > IO
Registers
Step 4.5 Search for the P6 port and observe the values as you run to your breakpoint
Step 4.6 Drag P6 onto the Selected Registers Tab You can view a subset of specific registers this way
Drag and Drop is one of the key features of the e2studio environment
Trang 125 e2
Overview:
studio Project Archives
How to archive send and import projects
Procedural Steps
Step 5.1 Switch to the C/C++ perspective and highlight the active project in the Project Explorer
window
Step 5.2 Right click on the project and select Export
Step 5.3 Expand General and choose Archive File
Trang 13Step 5.4 Click Next and create a zip file using the “To archive file” dialog that you can email or store for
later use
Step 5.5 Click Finish
Step 5.6 Close e2
Step 5.7 Reopen e
studio
2
studio, click Browse in the Workspace dialog to create a new workspace folder – this path is relative to my PC, you can choose some path that is convenient under
C:\Workspace:
Trang 14Step 5.8 Once it’s open, Right Click in the blank Project Explorer area and choose Import
Step 5.9 Important: Choose “Existing Project into Workspace” (not Archive File) and pull in the zip file
you created earlier in the lab
Trang 15Step 5.10 Click Finish
Step 5.11 Select E1(RL78) and choose the R5F104PJ device
Step 5.12 Check the project operates in correctly
Step 5.13 END