1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Using Virtual EEPROM and Flash API for Renesas MCUs_LabProcedures

27 965 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 27
Dung lượng 1,58 MB

Nội dung

Step 1.7 With the program running in normal 32 MHz mode record the current on the multimeter... 2 Generate IAR Project using Applilet: This lab section will show how to use Applilet to

Trang 1

RL78 Ultra Low Power LAB – CL07I

Description: This lab will demonstrate low power modes of the RL78 and show how important pin

setups are to achieve the best power performance The lab will also demonstrate how the Applilet code generator simplifies getting started with the RL78

Lab Sections

1 Running the Pre-Programmed Application: 2

2 Generate IAR Project using Applilet 4

3 Edit/Build IAR Project 8

4 Download and Debug IAR Project 183

5 Configuring Unused Pins 15

6 Flash Programming and Low Power 17

Lab Objectives

1 Demonstrate the low power modes of the

RL78

2 Generate IAR project using Applilet

3 Edit/Compile/build/debug the project in

IAR IDE

Skill Level

1 New to RL78/ IAR Tools

Time to Complete Lab

1 hour

Lab Materials

Please verify you have the following materials at your lab station

• Laptop PC with IAR/Applilet tools pre-installed

• IAR Kickstart V1.20.1 KS

• Applilet3 for RL78/G14 V1.01.01

• Renesas Flash Programmer V1.03

• YRPBRL78G14 target board

• USB cable

• Multimeter

Trang 2

1 Running the Pre-Programmed Application:

This lab section is designed to highlight the features which come as the default program with the RL78 demo board This is a quick overview, there is much more information in the Quickstart Guide for the kit

Step 1.1 Remove the jumper on CN4 on the Demo Board and place a multimeter configured to

measure milliamps across those terminals Set the multimeter to 20 mA range

Step 1.2 Make sure that jumpers are placed on CN6, CN7, CN8 and CN11, positions 2-3,

labeled “Virtual UART”

Step 1.3 To start the demonstrations ensure that the USB stick is connected to the laptop PC via

USB cable

Step 1.4 The Demonstrations are controlled by the YRPBRL78G14 GUI which can be started

from the “Start -> All Programs -> Renesas Electronics Tools -> YRPBRL78G14 -> YRPBRL78G14-Demo” menu or from the icon on the desktop

Trang 3

Step 1.5 The GUI should now be connected and running Diode D2 should now be blinking and

the graphs and data values on the GUI start page should now be updating with the

USB stick parameters as shown below

The demo allows you to investigate many of the unique features of the RL78 These include:

a Real Time Clock configuration and settings - Note that this tab allows you to synch the RTC to the PC clock and set alarms and interval interrupts using the RTC

b Memory demo including RAM and Data Flash (EEPROM)

c Self Test – Highlights the self-test features of the RL78 and memory protection

features

You can click the various tabs and you will see the demos that are available

Step 1.6 We will concentrate on the Low Power demo Select this tab

Step 1.7 With the program running in normal 32 MHz mode record the current on the

multimeter

mA

Trang 4

Step 1.8 Now select the “Halt” button and record the multimeter current

2 Generate IAR Project using Applilet:

This lab section will show how to use Applilet to quickly create a project Then we will place the MCU into various low power operating modes The project uses RL78G14 Family device, R5F104LE We will create a simple project that blinks LED (D2) every 1s with RTC interrupt

Procedural Steps

Step 2.1 Close the demo program and disconnect the USB cable

Step 2.2 Move the four jumpers (CN6, CN7, CN8, CN11) in the middle of the board to position

1-2 which enables the OCD

Step 2.3 Open Applilet by clicking the desktop shortcut or from the menu : Start -> All

Programs -> Applilet -> Applilet3 for RL78G14 -> V1.01.01-> Applilet3 for

RL78G14 V1.01.01

Step 2.4 From Applilet, select “File>new” This will open “New Project” window

Step 2.5 Enter the options below to configure project environment for R5F104LE device The

device in the RL78 Stick is the R5F104LE:

Ensure that ‘Kind of project’ “Project for RL78/78K0R”

Halt mode stops the clock to the CPU core but maintains clocks to the peripherals which are enabled

Stop mode stops the clocks to the CPU and peripherals but can allow the WDT and RTC to be functional Low Voltage Detect (LVD) is

also enabled

Trang 5

Scroll down the “Using microcontroller” device list to find the 64k Flash version

Click on RL78/G14(ROM:64KB),select device :“R5F100LE(64pin)”

Specify “Using Build Tools ‘IAR Compiler’

Specify ‘Project name’ ‘MyRL78G14Project’

Specify ‘Place’ ‘C:\RL78_Projects’

Step 2.6 Click OK to create the new project

Step 2.7 The next screen shows the Applilet Code Generator You may recognize this from

CubeSuite or from previous Applilet versions Note: If this is not what your screen looks like, then you are using a different version of Applilet

Trang 6

Step 2.8 For this project, leave the boxes unchecked and click on “Fix Settings.” Other

settings are handy for projects that need enhanced serial or timer functionalities

The project opens for you to begin at the System Settings The first thing to decide is how the pin assignment is set This setting can only be done once per project The default is PIOR = 0x00, where PIOR = Port IO Re-direction register

Trang 7

Step 2.9 Select the “Clock setting” tab Select the settings as shown in the below picture (all

are default except we check the SubClock Operation box):

Operation Mode Setting High speed main mode 2.7 ≤VDD≤5.5

Main system clock (fMAIN) setting High-speed OCO

High Speed OCO clock setting: 64MHz (TAU timer is 64MHZ, CPU is 32MHZ)

High-Speed System Clock setting Unchecked

Subsystem clock (fSUB setting) Operation checked

XT1 Oscillation: Checked

XT1 oscillator Oscillation mode setting: Ultra Low power consumption

Subsytem Clock in Stop Mode Stops supply (except real-time counter and interval timer)

RTC operation clock: 32.768 (fSub)

CPU and peripheral clock : 32000 (flH)

Trang 8

Step 2.10 Select the On-Chip Debug Tab Select these settings:

On-Chip Debug: “Used”

RRM function setting ‘Used’ (default) or ‘Unused’ – either setting is OK

Use Security ID Checked

Security ID 0x00000000000000000000

Erase Flash Memory Data Checked

Security ID Authentication Erase flash memory data

Step 2.11 Reset Source and Safety functions can be left as default

Step 2.12 Select the Port tab from project tree, select Port7, and set bit 7 as output, with level at

1 This is for driving the on-board LED (other pins should be left as unused):

Note: “Unused” just means the Port pin is not yet reserved for General Purpose

Input/Output use, so alternate peripheral function can be can be specified However,

all Unused pins will default to INPUT mode on MCU Power-On RESET, except for

P130 which is output only If a peripheral input or output function is utilized, the Port

pin will show a RED circle with Exclamation point next to the “In” and “Out”

buttons, but the “Unused” button is still selected

Trang 9

Step 2.13 The Interrupt, Serial, A/D and Timer tabs are not used in this example, so we will skip

those

Step 2.14 Select the WDT (Watch Dog Timer) tab, and set the WDT as UNUSED

Step 2.15 Select the RTC (Real Time Clock) tab Set it as USED, enable the Interrupt setting,

and set the Constant Period Interrupt function (INTRTC), set at “Once per 1 s” for a once-per-second interrupt, priority at low

Step 2.16 Save this project

Step 2.17 Click the Generate Code button on the toolbar or using the menu File>>Generate

Source Code It should report that the project was created successfully:

Step 2.18 Minimize Applilet; you do not have to close it

Trang 10

3 Edit/Build IAR Project

This section explains how to open an IAR project, edit/modify the source code for the target

application and IAR tools setting for the target board

Procedural Steps

Step 3.1 Launch IAR from the desktop icon or Start -> All Programs -> IAR Systems->IAR

Embedded Workbench for Renesas RL78 1.20.3 Kickstart-> IAR Embedded

Workbench You should be using V1.20.3, which can be installed from the RL78G14 RDK install disk

Step 3.2 Click File>Open>Workspace and browse to the directory where you created the IAR

project using Applilet (C:\RL78_Projects\MyRL78G14Project)

Step 3.3 Click on “MyRL78G14Project.eww” file This will load the IAR project file generated

by Applilet

Step 3.4 If IAR displays a message stating that the project file is an old format, click “Yes” to

convert it into the new format

Step 3.5 Your screen should look like this:

Trang 11

Step 3.6 Expand the applilet_src folder by clicking on the “+” symbol to the left of the folder

Your screen should now show the files below

Step 3.7 Open the r_cg_port.c file by double-clicking on it You can see that the

R_PORT_Create function contains the following code which sets up port 7 as an

output with a logic level 1 which we selected using Applilet

Notice that there is a red asterisk next to each of the source files that we have added –

this indicates that the code will be compiled at the next build either because the source is new or

has changed since the last build After compilation, the asterisks will disappear until we make a

change to the code

Notice that there is r_cg_port.c and a r_cg_port_user.c The r_cg_port.c is the setup code for the ports based on selections made using Applilet and the r_cg_port_user.c is a framework file for the user to input their own code Notice a similar structure exists for each peripheral which was setup using Applilet

}

Trang 12

The first thing we will do is modify the program to blink the LED using the RTC ISR

Step 3.8 Open the r_cg_rtc.c file

Click the “f( )” in the lower left corner of the editor window to see the functions in the file We will need to enable the counter in our program and we will also need to provide an ISR

Step 3.9 Double-click “r_main.c” to open it in the editor window

Step 3.10 Add the code below that is shown with the comment “//add this line” to main()

void main(void)

{

/* Start user code Do not edit comment generated here */

R_RTC_Start(); // add this line

while (1U)

{

; }

/* End user code Do not edit comment generated here */

Step 3.11 Now we will add the code to the ISR The interrupt is already setup with a callback

function Open the r_cg_rtc_user.c file

Trang 13

Step 3.12 In the “r_rtc_callback_constperiod” function add the code shown in the lines with //

add this line

void r_rtc_callback_constperiod(void)

{

/* Start user code Do not edit comment generated here */

volatile unsigned int i; // add this line

P7_bit.no7 = 0; // add this line

for (i=0;i<0xffff;i++); // add this line

P7_bit.no7 = 1; // add this line

/* End user code Do not edit comment generated here */

}

Step 3.13 Make the project by clicking the Make icon on the toolbar or pressing F7 The

project should build with no error

Step 3.14 Right click on project name and select “Option.” You will see a window like the one

shown below

Trang 14

Step 3.15 Under Category, select “Debugger” On this screen you will notice that the default

debug target is the simulator

Step 3.16 Now select Category as “Debugger” Select “Driver” as “TK”

Step 3.17 Click OK to save all the changes we have made to the Project Options

4 Download and Debug IAR Project

Overview:

In this section of the lab, we will download our project into the target board and run it as well as explore some of the different low power options

Procedural Steps

Step 4.1 Re-connect the USB cable to the YRPBRL78G14 board

Step 4.2 Click the Download/Debug button on the toolbar If a window appears that

indicates the TK tool must be setup click OK to go to the emulator setup You do not need to change any information on that window just click OK

Step 4.3 Click “Debug-> Go” or press F5 to RUN the program You will see the LED D2 on

the demo board will blink briefly every second

Congratulations! You have a working project running on the RL78 MCU

Trang 15

Step 4.4 With the program running in normal 32 MHz mode record the current on the

/* End user code Do not edit comment generated here */

Step 4.8 Click the Download/Debug button on the toolbar to rebuild the program and

download it

Step 4.9 Click “Debug-> Go” or press F5 to RUN the program and record the current

mA

Side Note: You may observe the Multimeter current drain measurement jumping around a bit as

the MCU is alternating between the 2 different modes at a 1 second rate (between Halt and

RUN mode, with the LED flashing) The exact mA value is not important, as we will look for a trend You just may want to be consistent in your measurement method; either use the lowest

current seen, or the average between lowest/highest readings, or the most frequently seen value Whatever measurement method you use, try to stick with it - to see lowered current drain trends -

Notice the decrease in current required though the LED is still blinking

Rather than wasting energy “spinning” in a “while(1) loop the MCU is placed in Halt mode until the RTC interrupt wakes it up The task is then completed and the MCU is placed back in a low power state

Trang 16

with the goal of achieving the lowest MCU power consumption while still performing the desired function (blinking the LED!)

We will now place the device into Stop mode

Step 4.10 Click “Debug-> Break” or use the icon on the toolbar to Stop executing the code Step 4.11 Click “Debug-> Stop Debugging”

Step 4.12 Open r_main.c and add the following line of code (notice there are two underscores

/* End user code Do not edit comment generated here */

Step 4.13 Click the Download/Debug button on the toolbar this will rebuild the program

and download it

Step 4.14 Click “Debug-> Go” or press F5 to RUN the program and record the current

mA

Step 4.15 Click “Debug -> Stop Debugging” to discontinue debugging Remove the USB cable

Notice the current is lower, however, it is not nearly as low as we showed in the demo One reason for this is the wasted current from floating pins We will modify the

starting configuration to improve this If you look at the schematic for the RPB demo board in the Appendix you will notice most of the pins are not connected We are

going to configure these as output pins so they will not “float”

Trang 17

5 Configuring Unused Pins

One nice feature of Applilet is you can modify a project and update the code Applilet will not change any code you added that is within the line shown below

/* Start user code Do not edit comment generated here */

/* End user code Do not edit comment generated here */

There are also options to allow Applilet to overwrite or merge code

Step 5.1 Minimize your IAR project and return to the Applilet project that should still be open Step 5.2 Under OPTIONS>>Generate Type make sure “Merge file” is selected

Step 5.3 Select the “Port” tabs to configure the following ports

Port 0 – all pins as outputs

Port 1 – Pins 0, 1, 2, 3, 5, 6 and 7 as outputs

P1-4 input

Port 2 – Pins 0, 1, 3-7 as outputs

P2-2 input (R5 potentiometer)

Port 3 – Pin 0 as output

Pin 1 as input (SW2 Pushbutton)

Port 4 – Pins 1, 2 and 3 as outputs

Pin 0 not used (notice Applilet warns there would be a conflict on Pin 0)

Ports 5, 6, and 14 - all output

Port 7 – Pins 0, 1, 2, 3, 4, 5, 7 as outputs

Pin 6 as input (SW1 Pushbutton)

Port 12 - Pin 0 as output

Pin 1,2 as input

Pins 3, 4: Not used

Port 13 - Pin 0 as output

Pin 7: not used

Ngày đăng: 22/06/2015, 14:17

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w