Renesas RX71M User manual

All information contained in these materials, including products and product specifications, represents
information on the product at the time of publication and is subject to change by Renesas Electronics
Corporation without notice. Please review the latest information published by Renesas Electronics
Corporation through various means, including the Renesas Electronics Corporation website
(http://www.renesas.com).
RX71M Group
Renesas Starter Kit+ Code G
enerator Tutorial Manual
For e
2
studio
Rev. 1.00 Jan 2015
32
RENESAS MCU
RX
Family / RX700 Series
32
User’s Manual

Notice
1. Descriptions of circuits, software and other related information in this document are provided only to illustrate the
operation of semiconductor products and application examples. You are fully responsible for the incorporation of these
circuits, software, and information in the design of your equipment. Renesas Electronics assumes no responsibility for
any losses incurred by you or third parties arising from the use of these circuits, software, or information.
2. Renesas Electronics has used reasonable care in preparing the information included in this document, but Renesas
Electronics does not warrant that such information is error free. Renesas Electronics assumes no liability whatsoever
for any damages incurred by you resulting from errors in or omissions from the information included herein.
3. Renesas Electronics does not assume any liability for infringement of patents, copyrights, or other intellectual property
rights of third parties by or arising from the use of Renesas Electronics products or technical information described in
this document. No license, express, implied or otherwise, is granted hereby under any patents, copyrights or other
intellectual property rights of Renesas Electronics or others.
4. You should not alter, modify, copy, or otherwise misappropriate any Renesas Electronics product, whether in whole or
in part. Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from such
alteration, modification, copy or otherwise misappropriation of Renesas Electronics product.
5. Renesas Electronics products are classified according to the following two quality grades: “Standard” and “High
Quality”. The recommended applications for each Renesas Electronics product depends on the product’s quality grade,
as indicated below.
“Standard”: Computers; office equipment; communications equipment; test and measurement equipment; audio
and visual equipment; home electronic appliances; machine tools; personal electronic equipment; and industrial
robots etc.
“High Quality”: Transportation equipment (automobiles, trains, ships, etc.); traffic control systems; anti-disaster
systems; anticrime systems; and safety equipment etc.
Renesas Electronics products are neither intended nor authorized for use in products or systems that may pose a
direct threat to human life or bodily injury (artificial life support devices or systems, surgical implantations etc.), or may
cause serious property damages (nuclear reactor control systems, military equipment etc.). You must check the quality
grade of each Renesas Electronics product before using it in a particular application. You may not use any Renesas
Electronics product for any application for which it is not intended. Renesas Electronics shall not be in any way liable
for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for
which the product is not intended by Renesas Electronics.
6. You should use the Renesas Electronics products described in this document within the range specified by Renesas
Electronics, especially with respect to the maximum rating, operating supply voltage range, movement power voltage
range, heat radiation characteristics, installation and other product characteristics. Renesas Electronics shall have no
liability for malfunctions or damages arising out of the use of Renesas Electronics products beyond such specified
ranges.
7. Although Renesas Electronics endeavors to improve the quality and reliability of its products, semiconductor products
have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use
conditions. Further, Renesas Electronics products are not subject to radiation resistance design. Please be sure to
implement safety measures to guard them against the possibility of physical injury, and injury or damage caused by fire
in the event of the failure of a Renesas Electronics product, such as safety design for hardware and software including
but not limited to redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or
any other appropriate measures. Because the evaluation of microcomputer software alone is very difficult, please
evaluate the safety of the final products or systems manufactured by you.
8. Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental
compatibility of each Renesas Electronics product. Please use Renesas Electronics products in compliance with all
applicable laws and regulations that regulate the inclusion or use of controlled substances, including without limitation,
the EU RoHS Directive. Renesas Electronics assumes no liability for damages or losses occurring as a result of your
noncompliance with applicable laws and regulations.
9. Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose
manufacture, use, or sale is prohibited under any applicable domestic or foreign laws or regulations. You should not
use Renesas Electronics products or technology described in this document for any purpose relating to military
applications or use by the military, including but not limited to the development of weapons of mass destruction. When
exporting the Renesas Electronics products or technology described in this document, you should comply with the
applicable export control laws and regulations and follow the procedures required by such laws and regulations.
10. It is the responsibility of the buyer or distributor of Renesas Electronics products, who distributes, disposes of, or
otherwise places the product with a third party, to notify such third party in advance of the contents and conditions set
forth in this document, Renesas Electronics assumes no responsibility for any losses incurred by you or third parties as
a result of unauthorized use of Renesas Electronics products.
11. This document may not be reproduced or duplicated in any form, in whole or in part, without prior written consent of
Renesas Electronics.
12. Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this
document or Renesas Electronics products, or if you have any other inquiries.
(Note 1) “Renesas Electronics” as used in this document means Renesas Electronics Corporation and also includes its
majority owned subsidiaries.
(Note 2) “Renesas Electronics product(s)” means any product developed or manufactured by or for Renesas Electronics.
(2012.4)

Disclaimer
By using this Renesas Starter Kit+(RSK+), the user accepts the following terms:
The RSK
+
is not guaranteed to be error free, and the entire risk as to the results and performance of the RSK
+
is
assumed by the User. The RSK+is provided by Renesas on an “as is” basis without warranty of any kind whether
express or implied, including but not limited to the implied warranties of satisfactory quality, fitness for a particular
purpose, title and non-infringement of intellectual property rights with regard to the RSK+. Renesas expressly
disclaims all such warranties. Renesas or its affiliates shall in no event be liable for any loss of profit, loss of data,
loss of contract, loss of business, damage to reputation or goodwill, any economic loss, any reprogramming or recall
costs (whether the foregoing losses are direct or indirect) nor shall Renesas or its affiliates be liable for any other
direct or indirect special, incidental or consequential damages arising out of or in relation to the use of this RSK+,
even if Renesas or its affiliates have been advised of the possibility of such damages.
Precautions
The following precautions should be observed when operating any RSK+product:
This Renesas Starter Kit+
is only intended for use in a laboratory environment under ambient temperature and
humidity conditions. A safe separation distance should be used between this and any sensitive equipment. Its use
outside the laboratory, classroom, study area or similar such area invalidates conformity with the protection
requirements of the Electromagnetic Compatibility Directive and could lead to prosecution.
The product generates, uses, and can radiate radio frequency energy and may cause harmful interference to radio
communications. However, there is no guarantee that interference will not occur in a particular installation. If this
equipment causes harmful interference to radio or television reception, which can be determined by turning the
equipment off or on, you are encouraged to try to correct the interference by one or more of the following measures;
•ensure attached cables do not lie across the equipment
•reorient the receiving antenna
•increase the distance between the equipment and the receiver
•connect the equipment into an outlet on a circuit different from that which the receiver is connected
•power down the equipment when not in use
•consult the dealer or an experienced radio/TV technician for help NOTE: It is recommended that wherever
possible shielded interface cables are used.
The product is potentially susceptible to certain EMC phenomena. To mitigate against them it is recommended that the
following measures be undertaken;
•The user is advised that mobile phones should not be used within 10m of the product when in use.
•The user is advised to take ESD precautions when handling the equipment.
The Renesas Starter Kit does not represent an ideal reference design for an end product and does not fulfil the
regulatory standards for an end product.

How to Use This Manual
1. Purpose and Target Readers
This manual is designed to provide the user with an understanding of how to use Application Leading Tool
(Code Generator) for RX together with the e2studio IDE to create a working project for the RSK+platform. It is
intended for users designing sample code on the RSK+platform, using the many different incorporated
peripheral devices.
The manual comprises of step-by-step instructions to generate code and import it into e2studio, but does not
intend to be a complete guide to software development on the RSK+platform. Further details regarding
operating the RX71M microcontroller may be found in the Hardware Manual and within the provided sample
code.
Particular attention should be paid to the precautionary notes when using the manual. These notes occur within the body
of the text, at the end of each section, and in the Usage Notes section.
The revision history summarizes the locations of revisions and additions. It does not list all revisions. Refer to the text of
the manual for details.
The following documents apply to the RX71M Group. Make sure to refer to the latest versions of these
documents. The newest versions of the documents listed may be obtained from the Renesas Electronics Web
site.
Document Type Description Document Title Document No.
User’s Manual Describes the technical details of the RSK+
hardware. RSK+RX71M User’s
Manual R20UT3217EG
Tutorial Provides a guide to setting up RSK+environment,
running sample code and debugging programs. RSK+RX71M
Tutorial Manual R20UT3222EG
Quick Start Guide Provides simple instructions to setup the RSK+and
run the first sample. RSK+RX71M Quick
Start Guide R20UT3223EG
Code Generator
Tutorial Provides a guide to code generation in the e
2
studio
IDE. RSK+RX71M Code
Generator Tutorial
Manual
R20UT3224EG
Schematics Full detail circuit schematics of the RSK+. RSK+RX71M
Schematics R20UT3216EG
Hardware Manual Provides technical details of the RX71M
microcontroller. RX71M Group
Hardware Manual R01UH0493 EJ

2. List of Abbreviations and Acronyms
Abbreviation
Full Form
ADC
Analog-to-Digital Converter
API
Application Programming Interface
bps
Bits per second
CMT
Compare Match Timer
COM COMmunications port referring to PC serial port
CPU
Central Processing Unit
DVD
Digital Versatile Disc
E1
Renesas On-chip Debugging Emulator
GUI
Graphical User Interface
IDE
Integrated Development Environment
IRQ
Interrupt Request
LCD
Liquid Crystal Display
LED
Light Emitting Diode
LSB
Least Significant Bit
LVD
Low Voltage Detect
MCU
Micro-controller Unit
MSB
Most Significant Bit
PC
Personal Computer
PmodTM
This is a Digilent Pmod™ Compatible connector. PmodTM is registered to Digilent Inc.
Digilent-Pmod_Interface_Specification
PLL
Phase-locked Loop
RAM
Random Access Memory
ROM
Read Only Memory
RSK+
Renesas Starter Kit+
RTC
Realtime Clock
SAU
Serial Array Unit
SCI
Serial Communications Interface
SPI
Serial Peripheral Interface
TAU
Timer Array Unit
TFT
Thin Film Transistor
TPU
Timer Pulse Unit
UART
Universal Asynchronous Receiver/Transmitter
USB
Universal Serial Bus
WDT
Watchdog timer
All trademarks and registered trademarks are the property of their respective owners.

Table of Contents
1. Overview............................................................................................................................7
1.1 Purpose......................................................................................................................................................7
1.2 Features.....................................................................................................................................................7
2. Introduction........................................................................................................................8
3. Project Creation with e2studio...........................................................................................9
3.1 Introduction ................................................................................................................................................9
3.2 Creating the Project...................................................................................................................................9
4. Code Generation Using the e2studio plug in...................................................................14
4.1 Introduction ..............................................................................................................................................14
4.2 Code Generator Tour ...............................................................................................................................14
4.3 Code Generation......................................................................................................................................17
4.4 Building the Project..................................................................................................................................30
5. User Code Integration......................................................................................................31
5.1 LCD Code Integration..............................................................................................................................31
5.2 Additional include paths...........................................................................................................................34
5.3 Switch Code Integration...........................................................................................................................35
5.4 Debug Code Integration...........................................................................................................................41
5.5 UART Code Integration............................................................................................................................41
5.6 LED Code Integration ..............................................................................................................................45
6. Debugging the Project.....................................................................................................47
7. Additional Information......................................................................................................49

RSK+RX71M R20UT3224EG0100
Rev. 1.00
RENESAS STARTER KIT+ Jan 23, 2015
R20UT3224EG0100 Rev. 1.00 Page 7 of 53
Jan 23, 2015
1. Overview
1.1 Purpose
This RSK+ is an evaluation tool for Renesas microcontrollers. This manual describes how to the e2studio IDE
code generator plug in to create a working project for the RSK+ platform.
1.2 Features
This RSK+provides an evaluation of the following features:
•Project Creation with e2studio.
•Code Generation using the code generator plug in.
•User circuitry such as switches, LEDs and a potentiometer.
The RSK+ board contains all the circuitry required for microcontroller operation.

RSK+RX71M 2. Introduction
R20UT3224EG0100 Rev. 1.00 Page 8 of 53
Jan 23, 2015
2. Introduction
This manual is designed to answer, in tutorial form, how to use the code generator plug in for the RX family
together with the e2studio IDE to create a working project for the RSK+ platform. The tutorials help explain the
following:
•Project generation using the e2studio
•Detailed use of the code generator plug in for e2studio
•Integration with custom code
•Building the project e2studio
The project generator will create a tutorial project with two selectable build configurations:
•‘HardwareDebug’ is a project built with the debugger support included. Optimisation is set to zero.
•‘Release’ is a project with optimised compile options, producing code suitable for release in a product.
Some of the illustrative screenshots in this document will show text in the form RXxxx. These are general
screenshots and are applicable across the whole RX family. In this case, simply substitute RXxxx for RX71M
These tutorials are designed to show you how to use the RSK+and are not intended as a comprehensive introduction to
the e2studio debugger, compiler toolchains or the E1 emulator. Please refer to the relevant user manuals for more in-
depth information.

RSK+RX71M 3. Project Creation with e2studio
R20UT3224EG0100 Rev. 1.00 Page 9 of 53
Jan 23, 2015
3. Project Creation with e2studio
3.1 Introduction
In this section the user will be guided through the steps required to create a new C project for the RX71M
MCU, ready to generate peripheral driver code using Code Generator. This project generation step is
necessary to create the MCU-specific source, project and debug files.
3.2 Creating the Project
Start e2studio and select a suitable location for the project workspace
•Start e2studio and select a suitable
location for the project workspace.
•In the Welcome page, click ‘Go to the
workbench’.
•Create a new C project by right-
clicking in the Project Explorer pave
and selecting ‘New -> C Project’ as
shown. Alternatively, use the menu
item ‘File -> New -> C Project’.

RSK+RX71M 3. Project Creation with e2studio
R20UT3224EG0100 Rev. 1.00 Page 10 of 53
Jan 23, 2015
•Enter the project name ‘CG_Tutorial’.
In ‘Project type:’ choose ‘Sample
Project’. In ‘Toolchains’ choose
‘Renesas RXC Toolchain’. Click ‘Next’.
•In the ‘Target Specific Settings’ dialog,
select the options as shown in the
screenshot opposite.
•The R5F571MLCxFC MCU is found
under RX700 -> RX71M -> RX71M -
176 pin.
•Click ‘Next’.

RSK+RX71M 3. Project Creation with e2studio
R20UT3224EG0100 Rev. 1.00 Page 12 of 53
Jan 23, 2015
•In the ‘Global Options Settings’ leave
everything at default values.
•Click ‘Next’.
•In the ‘Standard Header Files’ dialog,
select C99 for ‘Library Configuration’.
Untick ‘new(EC++)’ and leave all
others at defaults.
•Click ‘Next’.

RSK+RX71M 4. Code Generation Using the e2studio plug in
R20UT3224EG0100 Rev. 1.00 Page 14 of 53
Jan 23, 2015
4.Code Generation Using the e2studio plug in
4.1 Introduction
Code Generator is an e2studio plug in GUI tool for generating template ‘C’ source code for the RX71M. When
using Code Generator, the user is able to configure various MCU features and operating parameters using
intuitive GUI controls, thereby bypassing the need in most cases to refer to sections of the Hardware Manual.
Once the user has configured the project, the ‘Generate Code’ function is used to generate three code
modules for each specific MCU feature selected. These code modules are name ‘r_cg_xxx.h’, ‘r_cg_xxx.c’,
and ‘r_cg_xxx_user.c’, where ‘xxx’ is a three letter acronym for the relevant MCU feature, for example ‘adc’.
Within these code modules, the user is then free to add custom code to meet their specific requirement.
Custom code should be added, whenever possible, in between the following comment delimiters:
/* Start user code for adding. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
Code Generator will locate these comment delimiters, and preserve any custom code inside the delimiters on
subsequent code generation operations. This is useful if, after adding custom code, the user needs to re-visit
Code Generator to change any MCU operating parameters.
By following the steps detailed in this Tutorial, the user will generate a e2studio project called CG_Tutorial.
The fully completed Tutorial project is contained on the DVD and may be imported into e2studio by following
the steps in the Quick Start Guide. This Tutorial is intended as a learning exercise for users who wish to use
the Code Generator to generate their own custom projects for e2studio.
The CG_Tutorial project uses interrupts for switch inputs, the ADC module, the Compare Match Timer (CMT),
the Serial Communications Interface (SCI) and uses these modules to perform A/D conversion and display the
results via the Virtual COM port to a terminal program and also on the LCD display on the RSK+.
Following a tour of the key user interface features of Code Generator in §4.2, the reader is guided through
each of the peripheral function configuration dialogs in §4.3. In §5, the reader is familiarised with the structure
of the template code, as well as how to add their own code to the user code areas provided by the code
generator.
The Code Generator installer is contained on the DVD. This installer must be run before proceeding to the
next section.
4.2 Code Generator Tour
In this section a brief tour of Code Generator is presented. For further details of the Code Generator
paradigm and reference, refer to the Application Leading Tool Common Operations manual
(r20ut2663ej0100_Code Generator.pdf). Application Leading Tool is the stand-alone version of Code
Generator and this manual is applicable to the Code Generator.
From the e2studio menus, select ‘Window -> Open Perspective -> Other. In the ‘Open Perspective’ dialog
shown in Figure 4-1, select ‘Code Generator’ and click ‘OK’.

RSK+RX71M 4. Code Generation Using the e2studio plug in
R20UT3224EG0100 Rev. 1.00 Page 15 of 53
Jan 23, 2015
Figure 4-1 Open Perspective Dialog
In the Project Explorer pane, expand the ‘Code Generator’ and ‘Peripheral Functions’ node. The Code
Generator initial view is displayed as illustrated in Figure 4-2.
Figure 4-2 Initial View

RSK+RX71M 4. Code Generation Using the e2studio plug in
R20UT3224EG0100 Rev. 1.00 Page 16 of 53
Jan 23, 2015
Code Generator provides GUI features for configuration of MCU sub systems. Once the user has configured
all required MCU sub systems and peripherals, the user can click the ‘Generate Code’ button, resulting in a
fully configured e2studio project that builds and runs without error.
Navigation to the MCU peripheral configuration screens may be performed by double-clicking the required
function in the Code Generator -> Peripheral Function on the left.
It is also possible to see a preview of the code that will be generated for the current peripheral function
settings by double-clicking the required function in the Code Generator -> Code Preview on the left.

RSK+RX71M 4. Code Generation Using the e2studio plug in
R20UT3224EG0100 Rev. 1.00 Page 17 of 53
Jan 23, 2015
4.3 Code Generation
In the following sub-sections, the reader is guided through the steps to configure the MCU for a simple project
containing interrupts for switch inputs, timers, ADC and a UART.
4.3.1 Clock Generator
Figure 4-3 shows a screenshot of Code Generator with the Clock Generator function open. Click on the
‘Clock setting’ sub tab. Configure the system clocks as shown in the figure. In this tutorial we are using the
on board 24 MHz crystal resonator for our main clock oscillation source and the PLL circuit is in operation.
The PLL output is used as the main system clock and the divisors should be set as shown in Figure 4-3.

RSK+RX71M 4. Code Generation Using the e2studio plug in
R20UT3224EG0100 Rev. 1.00 Page 19 of 53
Jan 23, 2015
4.3.2 Interrupt Controller Unit
Referring to the RSK+ schematic, SW1 is connected to IRQ5 (P15) and SW2 is connected to IRQ2 (P12).
SW3 is connected to directly to the ADTRG0n and will be configured later in §4.3.4. Navigate to the ‘Interrupt
Controller Unit’ node in Code Generator and in the ‘General’ tab, configure these two interrupts as falling edge
triggered as shown in Figure 4-4 below.
Figure 4-4 Interrupt Functions tab
Navigate to the ‘Group Interrupts’ sub tab and ensure that the ‘Group BL0’ interrupt is selected as shown in
Figure 4-5. The Group BL0 interrupt is used for SCI Transmit End Interrupts (TEI) and Reception Error
Interrupts (ERI) as described in §4.3.5.

RSK+RX71M 4. Code Generation Using the e2studio plug in
R20UT3224EG0100 Rev. 1.00 Page 20 of 53
Jan 23, 2015
Figure 4-5 Group Interrupt Functions tab
4.3.3 Compare Match Timer
Navigate to the ‘Compare Match Timer’ node in Code Generator. CMT0 will be used as an interval timer for
generation of accurate delays. CMT1 and CMT2 will be used as timers in de-bouncing of switch interrupts.
In the ‘CMT0’ sub-tab configure CMT0 as shown in Figure 4-6. This timer is configured to generate a High
priority interrupt every 1ms. We will use this interrupt later in the tutorial to provide an API for generating high
accuracy delays required in our application.
Figure 4-6 CMT0 tab
Navigate to the ‘CMT1’ sub-tab and configure CMT1 as shown in Figure 4-7. This timer is configured to
generate a High priority interrupt after 20ms. This timer is used as our short switch de-bounce timer later in
this tutorial.
Other manuals for RX71M
1
This manual suits for next models
2
Table of contents