100
• Overview of the RX71M MCU and the development board • Development and debugging in the e 2 studio IDE • Introduction to programming with three project described in detail Markus Stäuble / Bernd Westhoff / Christian Immler Renesas RX71M Revelation Kit Quick start guide for the The concise introduction to the world of powerful RX71M 32-bit microcontrollers by Renesas.

Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

  • Upload
    docong

  • View
    233

  • Download
    4

Embed Size (px)

Citation preview

Page 1: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

• Overview of the RX71M MCU and the development board• Development and debugging in the e2 studio IDE• Introduction to programming with three project described in detail

Markus Stäuble / Bernd Westhoff / Christian Immler

Renesas RX71M Revelation Kit

Quick start guide for the

The concise introduction to the world of powerful RX71M 32-bit microcontrollers by Renesas.

Page 2: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

© 2016 Franzis Verlag GmbH, 85540 Haar bei München

This book is written and produced for Renesas Electronics Europe GmbH (Renesas). Renesas is allowed to

distribute the content of this book in any format. For all others the following copyright statement is valid:

All rights reserved, including photomechanical reproduction and electronical storage. The production and

distribution of copies on paper, digital media or the internet, especially as PDF, is only admissible with an

explicit permission by the publishing house and will be legally prosecuted otherwise.

Most product names of hard- and software as well as company names and logos referred to in this

volume are registered trademarks and should be considered as such. The publishing house mostly

keeps with the spelling of the manufacturers when referring to the products.

Productmanagement: Dr. Markus StäubleAuthor: Markus Stäuble / Bernd Westhoff / Christian Immler art & design: www.ideehoch2.de

ISBN 978-3-645-20526-9

60526-7 Titelei.qxp 19.10.16 12:26 Seite 2

Page 3: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

3

Table of contents

Preface ....................................................................................................................... 5

1. RX71M Revelation Board .................................................................................... 71.1 Overview of the board .............................................................................. 71.2 RX71M ....................................................................................................... 91.2.1 A short history of the RX ........................................................................... 91.2.2 The RX family .......................................................................................... 101.2.3 Features of the RX71M ............................................................................. 111.2.4 Controlling a TFP display by the RX71M .................................................. 121.3 Demo applications .................................................................................. 131.3.1 GAPI demo .............................................................................................. 141.3.2 Business card demo ............................................................................... 19

2. Development Environment ............................................................................... 232.1 Creating a MyRenesas account ............................................................... 242.2 e2 studio ................................................................................................. 282.2.1 Installation ............................................................................................. 282.2.2 Switching to another interface language ................................................ 382.2.3 The user interface ................................................................................... 402.2.4 Source text editor ................................................................................... 422.2.5 Perspectives and views ........................................................................... 442.2.6 Configuringthedebugger ....................................................................... 452.2.7 Using the debugger ............................................................................... 482.3 Creating a project ................................................................................... 522.3.1 Peripheral Code Generator ..................................................................... 542.3.2 Firmware Integration Technology (FIT) ................................................... 572.3.3 Combining Peripheral Code Generator and FIT ....................................... 642.3.4 Why are both Code Generator and FIT provided for RX71M? ................... 65

3. Projects for the Revelation Board .................................................................... 673.1 Project 1: Flashing LED with Compare Match Timer and

Peripheral Code Generator ..................................................................... 673.2 Project 2: Flashing LED with Compare Match Timer and FIT ................... 733.3 Project 3: Determining the temperature, writing it to

the Flash memory and displaying it via USB ........................................... 77

4. Executing programs on the Revelation Board .................................................. 914.1 Execution in e2 studio ............................................................................. 914.2 Executing programs without e2 studio .................................................... 924.2.1 Re-install the demo program .................................................................. 92

5. Appendix .......................................................................................................... 975.1 Keyboard shortcuts in the source text editor .......................................... 975.2 Keyboard shortcuts in the debugger ...................................................... 995.3 Weblinks ................................................................................................. 99

Page 4: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and
Page 5: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

5

PrefaceWith the purchase of the Revelation Kit, you have decided on a powerful development board with the 32-bit RX71M microcontroller by Renesas. As you have already noticed, the board is equipped with a TFT display, which you can operate by touch. You can have a try right now, as the board comes with a pre-installed graphical demo application with two modes. Simply press and hold the SW1 switch while powering on the board to invoke the business card mode. You can even make changes to this demo program on your PC without writing any code. Just connect the CN3 port via a USB cable to your PC and you can change the run-ning text or upload a different picture. More information about this process can be found in section 1.3 of this book.

However, you purchased this board mainly for development, and that is what this book is about. First, we show you how to install the development environment e2 studio and explain the most important parts of its user interface. If you already know Eclipse, you will feel familiar with e2 studio because it is based on the Eclipse platform. As the Revelation Kit en-compasses the integrated E2 Lite debugger, we will also show you how to debug a program in e2 studio.

Building on this basic knowledge, you learn how to implement three projects step by step. You will especially like the fact that you do not have to program the microcontroller manu-ally. In the Peripheral Code Generator you can set the desired option, and then the source code is generated based on your choices. In the first project, you let two on-board LEDs flash alternately. However, with more complex projects, you cannot avoid to write code yourself. To facilitate the work, the Firmware Integration Technology (FIT) provides numerous librar-ies. In the second project, you thus use FIT to let the two LEDs flash alternately. The third project is much more complex: Here, you use the on-board ADC to read the temperature from an integrated sensor. You also write this value into a file in the internal Flash memory and transfer the file via a USB connection at the CN3 port to your PC, where you can view it. This project uses the Peripheral Code Generator as well as FIT. The projects are available for download at http://renesas.com/revalation so that you can follow along.

We want to give our special thanks to Kieran Slorach and Richard Warner. Without your support, this book would not have been possible.

Have fun with your projects!

The authors: Dr. Markus Stäuble, Bernd Westhoff and Christian Immler

Page 6: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and
Page 7: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

7

1. RX71M Revelation Board1.1 Overview of the boardThe RX71M Revelation Board provides several switches, LEDs and connectors for external hardware. The schematic diagram shows the location of the components on the board.

Fig. 1.1: Schematic diagram of the bottom side of the RX71M Revelation Board. The TFT touch display is located on the top side.

IC1 – RX71M microcontroller on the board.

IC2 – RX631 E2 Lite on-board debugger chip.

USB CN3 – Connector for using the board as USB mass storage drive. This connector cannot be used as power supply.

USB CN9 – Power supply and USB port for the E2 Lite on-board debugger. This connector is used to program the board and for the demo mode.

Both USB connectors are mini USB ports as used by early smartphones and digital cameras. If you still have a cable from that era you can use it for these connections. Make sure that the voltage is sufficient. If you use a USB hub, it must have its own power supply to provide sufficient voltage for supplying the board.

CN1, CN2, CN8, CN10 – Connectors for hardware extensions. Here you can solder pin or socket headers as needed.

CN5, CN6, CN7, CN13 – Jumper pins for configuring the LCD module. In the default configura-tion, no jumpers are set.

Page 8: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

8

CN11 – Connector for an external E1 emulator. This is a reverse-polarity protected socket header for attaching a ribbon cable.

CN12 – Connector for the LCD module. This module is attached via a special foil cable. Pull the black cover of the connector a short distance away from the white part in order to re-lease the lock so that you can attach or detach the cable. When attaching the cable, its contact side must point downwards towards the board.

CN14 – Connector for a separate external touch screen (in case the touch screen is not con-nected to the display via CN12).

SW1 – Push-buttons for program functions.

SW2 – Two switches to turn on the debugger mode or the reset mode, respectively. For using the demo program and for programming in e2 studio, both switches have to be set to OFF (position 1 and 2).

LED0, LED1 – Two freely programmable LEDs, which can be used by program functions.

LED5 – Status LED for the E2 Lite on-board debugger. This LED shines continuously when the connection to the debugger is established.

LED5 MeaningContinuous light USB connection to the PC driver at the CN9 USB connector is

established.

Flashing light Power supply active, but no USB connection to the PC driver.

No light No power supply at the CN9 USB connector.

Page 9: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

9

1.2 RX71MThe Revelation Kit is built upon RX71M microcontroller with 4 MByte on-chip Flash memory and 552 kByte on-chip RAM. With its 4.35 coremark/MHz and a CPU frequency of 240 MHz, this 32-bit microcontroller achieves extremely high computing power. This makes it highly suitable for many applications that require high performance, whilst at the same time ben-efiting from low power consumption due to being manufactured on an advanced 40 nm process technology.

Figure: Specifications of the RX71M

To accommodate many applications with varying requirements, the RX71M is highly scalable. The RX71M products are available with 2 MB to 4 MB of integrated Flash memory and a con-stant RAM of 552 KB. There are also different package types, such as LQPF, LGA and BGA.

1.2.1 A short history of the RXRenesas Electronics developed the first version of their 32-bit RX microcontroller as early as 2008. The RX microcontroller is based on an extended Harvard architecture, which allows clock frequencies up to 120 MHz due to the integrated "zero wait state" Flash technology and thus represents the fastest integrated Flash solution in the world.

The first components used the RXv1 processor core. However, the increased demand for more integrated Flash memory beyond 2 MByte and for higher CPU clock rates led to the

Page 10: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

10

development of an enhanced RX, the RXv2. This allows for higher clock rates, less power consumption and extended functionality.

This second version of the processor core (RXv2) with extended DSP functionality and im-proved FPU also allows for more memory capacity and clock rates up to 240 MHz. It is avail-able in the current components of the RX product lines.

In the new RXv2 design, Renesas has also retained the real-time functionality of the RXv1 core.

The single-precision FPU of the RXv2 core now comes with its own pipeline, which increased the data throughput. Furthermore, Renesas added another computing unit (ALU). By com-bining two computing units and two 32-bit multiplication and addition commands, DSP op-erations can now be completed in a single instruction cycle.

The dual-issue core (which means that in each clock cycle, the processor can transfer two instruction from one pipeline stage to the next) with a five-stage pipeline and the improved DSP/FPU functionality turns the RXv2 core into a high-performance processor core, which can be clocked at max. 240 MHz. Due to its 2.0 DMIPS/MHz, the RXv2 core can achieve a calculating power of 480 DMIPS.

The RXv2 core is a General Register Architecture and has a 4 GB linear address range, which contains both program and data areas. To enable maximum performance across the ad-dress space, the RXv2 core supports ten different address modes. The memory structure is designed for Little Endian instruction sets. However, for the data regions the user can select between Little Endian and Big Endian.

1.2.2 The RX familyThe RX family is a continuously growing and internally compatible product line. Among other things, RX provides the largest integrated Flash memory in the area of embedded comput-ing, the fastest MCU with integrated FPU (Floating Point Unit), the broadest choice of inte-grated peripherals and a multitude of different package types. Currently the four product series RX100, RX200, RX600 and RX700 are available. All of these product lines comprise many different product groups covering different applications (see figure).

Page 11: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

11

Figure: Product lines and application areas

The broad choice of RX products provides solutions for various applications.

1.2.3 Features of the RX71MAs embedded systems usually have a high real-time demand, the RX products provide a high-speed interrupt. This allows for response to an interrupt signal within 5 clock cycles. In order to fulfill the increasing demand for security, the RX includes various integrated security features, e.g. Flash memory protection by an ID code, integrated MPU (Memory Protection Unit), protection against accidentally overwriting the registers and independent clock supply for the watchdog feature. Furthermore, hardware test functions that allow the checking of the I/O status of the ports are implemented. An ADC self-test, which can detect the disconnection of external signals, can also be executed. A CRC hardware unit to check memory contents and a test function to check the clock source complete the features.

Communication is a decisive factor in many applications, whether it is a simple serial inter-face for communicating with another module or an extended communication protocol like Ethernet, CAN or USB.

Whatever you need, the required interfaces are supported by the RX71M!

Page 12: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

12

1.2.4 Controlling a TFP display by the RX71MThere is an unstoppable trend towards integrating displays as intelligent user interfaces. This can often be implemented by a simple segment or matrix display. However, more and more often graphics displays (i.e. TFT displays) are desired. In such a case, the use of a graphics controller is usually very complex and too expensive for the application at hand. However, a cost-effective solution based on the RX71M microcontroller can be offered.

As the RX71M has a large internal RAM and integrated TFT controller, the Revelation Kit can be used to implement a cost effective single chip display solution. There is no requirement for additional external memory. Due to the high performance of the RX71M and the large internal RAM, the Revelation kit can support a QVGA TFT, 320 x 240 resolution, with a 16-bit colour depth.

The CPU load on the RX71M for displaying an image amounts to only approx. 5%. This means that sufficient resources remain for other application functions, e.g. connectivity.

The TFT control principle is documented in detail. You can download it from the following Web site: www.renesas.com/revelation.

Page 13: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

13

1.3 Demo applicationsTwo demo applications are pre-installed on the RX71M Revelation Board. Using the included graphics library, they show several possibilities for graphics applications on the LCD mod-ule. The source code of the demo applications can be downloaded from the Revelation site: www.renesas.com/revelation.

To invoke the demo applications, attach the board via the CN9 USB connector and a USB cable to your PC or to an external power supply. The splash screen shown in the figure below appears.

Fig. 1.2: Splash screen of the RX71M Revelation Board.

When you see an error message due to a missing driver while attaching the board to the PC, you can ignore this for now as long as you only use the demo application. At the lat-est, the missing driver will be installed automatically when you install the development environment.

Fig. 1.3: Installing the device driver.

Page 14: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

14

1.3.1 GAPI demoWith the default settings, the RX71M Revelation Board automatically launches the GAPI demo after approx. 4 seconds. GAPI (Renesas Graphics Application Programming Interface) is a function library for developing graphical user interfaces for the TFT and the touch screen.

Renesas GAPI for your own projectsIf you want to develop your own projects with the Renesas GAPI, we recommend to use GAPI Journey Application Note, which is specifically designed for the Revelation Kit. For more information, see www.renesas.eu.

Fig. 1.4: Main menu of the GAPI demo.

The GAPI demo starts with a menu where you can select one of four different demo pro-grams by touching the respective icons on the touch screen. When you do not touch an icon within 30 seconds, a loop is started that briefly shows each of the demo programs one after the other.

Page 15: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

15

Weather appThis demo represents a typical weather app. As a demo, it does not display real weather data, but only demonstrates the graphical possibilities. When you touch one of the weekday icons, the display changes accordingly. When you touch the home icon in the top right cor-ner, the program goes back to the selection screen for the demo applications. This applies to all demos.

Fig. 1.5: Demo of a graphical weather app.

Medical monitorThis demo emulates a medical monitor with a typical heart beat graph. Touch the heart icon on the slider and drag the slider to the right or to the left in order to alter the behavior of the graph.

Fig. 1.6: Demo of a medical monitor.

Page 16: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

16

Refrigerator displayThis demo emulates a control display for a refrigerator with a freezing compartment. You can use the plus and minus icons to change the temperature display.

Fig. 1.7: Demo of a refrigerator control.

Basic graphics functionsThe fourth demo shows another selection screen where you can launch different demos. These are significantly simpler and only demonstrate the basic functions of the Graphics API for graphical interfaces.

Fig. 1.8: Screen for selecting the simple graphics demos.

Page 17: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

17

CountdownA simple countdown demonstrates the use of an object with different buttons as well as the transparent rendering of text in front of a colored background.

AnimationThis demo shows the GAPI functions that allow you to move objects on a background. An alpha channel is used for the transparency of the depicted sun. As every object has a rectan-gular shape, the area between the sun beams is transparent so that the background remains visible.

Fig. 1.9: Moving objects on a background.

Calibrating the touch screensTouch screens can be calibrated so that the position of a touched point matches the shown position of the point. The touch screen module included with the RX71M Revelation Board does not have to be calibrated, but it supports calibration nonetheless. The demo succes-sively shows the points to be touched and provides the coordinates for calibration. By press-ing the SW1 push-button, you can skip a point.

GAPI_TThis demo shows the transparency functions of GAPI. The sliders allow you to set the RGB color components of a transparent layer, which is superimposed on an object by means of several logic functions. The ring-shaped symbols show the effect of the color change in real time.

Page 18: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

18

Measuring the screen build-up timesThis demo calculates how long it takes to fill the screen with several instances of a given picture. The build-up time depends on image size and color depth, among others.

Fig. 1.10: Filling the screen and measuring how long it takes.

Frame rateThis demo shows the effect of the adjustable frame rate on the rendering quality and the performance of the screen.

UTF 8 character displayGAPI can not only display the characters of the US English alphabet but also UTF 8 charac-ters for letters of European and other languages. This demo shows the display of foreign language characters on the screen.

Page 19: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

19

QWERTY keyboardThis demo shows a screen keyboard that can be used to enter text in a form field.

Fig. 1.11: Screen keyboard on the touch screen.

1.3.2 Business card demoDetach the USB cable from the CN9 USB port on the board. Press and hold SW1 while you re-attach the cable until the splash screen appears. In this way, you switch to the second demo mode. This mode is retained even if you cut and re-establish the power supply.

Fig. 1.12: Business card demo.

The business card demo shows running text and two images. The data are taken from two files stored in a dedicated FAT file system (within the embedded DataFlash memory of the RX71M) on the RX71M Revelation Board. You can access this file system via the CN3 USB port.

As this port cannot be used for the power supply of the board, you need a second USB cable to connect the CN3 USB port with the PC.

Page 20: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

20

Windows Explorer on the PC shows a new drive, RPBRX71M.

Fig. 1.13: The FAT file system of the RX71M Revelation Board.

Caution!To avoid corruption of the FAT file system in the RX71M DataFlash, always select Eject or Safely Remove Hardware before you detach the USB cable.

The file system conforms to the classical FAT standard. For compatibility, use only file names in 8+3 format without spaces or special characters.

The text file demo.txt contains the configuration for the business card demo. This appli-cation shows two pictures, a running text and a static text in different areas of the screen.

You can change this file at any time. After you reset the board by cutting the power supply at the CN9 USB port, the new data are displayed.

Page 21: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

21

Fig. 1.14: Screen areas for the business card demo.

In the demo.txt file, you can define five sections for the data to be displayed. If a section is missing or if a file cannot be found, default values will be used.

Section Function[photo] JPG image, 150 × 110 pixels; is shown in the area Left Image.[logo] JPG image, 150 × 110 pixels; is shown in the area Right Image. If the section

[photo] is missing, this image is shown in the area Left Image. In this case, the Renesas logo appears in Right Image.

[banner] JPG image, 320 × 110 pixel; is shown in the top area of the screen. If this section is present, the sections [photo] and [logo] are ignored.

[name] Running text with max. 30 ASCII characters, shown as a marquee in the area Name.

[title] Static text with max. 30 ASCII characters, shown in the area Title.

In order to get back to the GAPI demo mode, pull the USB cable from the CN9 USB port. Press and hold SW1 while you re-attach the cable.

Feel free to experiment with your own images and texts in order to adapt this demo to your own needs.

Page 22: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and
Page 23: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

23

2. Development EnvironmentTo develop applications for the Revelation Board, you use the development environment Renesas eclipse embedded studio, also called e2 studio. You can use the full functionality of the integrated CC-RX compiler for 60 days; after that, a size limit of 128 kB for program code applies.

Renesas provides e2 studio including the CC-RX compiler for download at the following address:

www.renesas.com/en-eu/products/software-tools/tools/ide/e2studio.html

Fig. 2.1: The download page for e2 studio.

Page 24: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

24

2.1 Creating a MyRenesas accountIn order to download e2 studio, a few preparatory steps are required. First, you have to cre-ate a MyRenesas account. If you already have one, you can skip the respective steps and use this account to login at the proper time during the download process.

Step 1: Select e2 studio 5.1After clicking the Download button, a list of several software tools is shown. Click the first link, e2 studio 5.1 installer (Web installer). It is not necessary to set the check mark in front of this item.

Fig. 2.2: Selecting the e2 studio installer.

Page 25: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

25

Step 2: Confirm the downloadNow you see a page with additional installation information, e.g. the supported operating systems. Click the Download button in the bottom right corner.

Fig. 2.3: Installation information for e2 studio installer.

Page 26: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

26

Step 3: Create a MyRenesas accountOn the next page, you have to login with your MyRenesas account. If you do not already have one, click the link Don't have an account yet? Register here.

Fig. 2.4: MyRenesas login.

Enter your name and your email address to create the account.

Fig. 2.5: Creating a new MyRenesas account.

Page 27: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

27

For registration, use an email address where you can fully control the spam filter. There is a high probability that the confirmation email will end up in the spam filter.

In our tests, we received this confirmation email only after 10 to 20 minutes. Click on the link in the email in order to continue the registration of your MyRenesas account.

Next, you are asked to provide further data like company name, street address and phone number. Even if you have deselected the option to receive newsletters and advertisements, a long list of newsletter and information categories is shown. The button Next to complete the registration is displayed not before you have selected a newsletter category. However, you can deselect it at once and then complete the registration nonetheless.

Step 4: Login and downloadOn the next screen, you login with your new MyRenesas account. After that, the download of the e2 studio Web installer starts automatically. Store the installation file with a size of approx. 85 MByte on your local hard drive.

Page 28: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

28

2.2 e2 studio

2.2.1 Installation

Step 1: Launch the installationLaunch the installation by double-clicking the downloaded file. It will unzip automatically. After that, you have to confirm the message of the Windows user account control before the proper installation begins.

Fig. 2.6: The first step of the installation wizard

Page 29: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

29

Step 2: Select the installation directoryThe best option is to accept the default installation directory. However, in Windows 10, in-stallation within the default directory C:\Programs is not reasonable because of the security restrictions in this directory.

Fig. 2.7: Selecting the installation directory.

Step 3: Select the hardwareIn the next step, check Support for RX Devices so that you can develop programs for the RX71M Revelation Board.

Fig. 2.8: Selecting support for RX devices.

Page 30: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

30

Step 4: Select optional componentsIn the next few dialogs, you can select optional components. It is not necessary to select anything in the first dialog, Extra Components.

Fig. 2.9: Language packs and other optional components.

In the next dialog, Components, several optional components are already preselected. Keep this selection and click Next.

Page 31: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

31

Fig. 2.10: Optional components that have to be installed.

In the next dialog, Additional Software, nothing is selected by default. Check all Renesas CCRX compiler packages. The other packages further down the list are not required.

Page 32: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

32

Fig. 2.11: Selecting the required compiler packages for installation.

If you select the wrong components, an error message due to missing toolchains will appear when you launch the development environment for the first time. This prevents you from using e2 studio.

Page 33: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

33

Step 5: Start the installationAfter accepting the mandatory license agreement, you have to select the start menu group where the menu item to launch e2 studio will appear. A second start menu group with release notes and compiler documentation will be created automatically without your intervention.

Fig. 2.12: Selecting the start menu group.

Next, you see a summary of the components to be installed. Renesas also installs the pack-ages Microsoft Visual C++ 2008 Windows 7 Service Pack 1 Runtime and Microsoft Visual C++ 2010 Windows 7 Service Pack 1 Runtime, which are downloaded additionally.

Page 34: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

34

Fig. 2.13: The installation is running.

During installation, installation routines for the Renesas RX compiler are called automati-cally. For these, you have to click Next several times and accept the license agreements.

Fig. 2.14: Installing the Renesas RX compiler.

Page 35: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

35

Step 6: Complete the installation and launch e2 studioIn the last step of the installation process, check the option Launch e2 studio?, even if you do not want to start programming immediately. However, you have to adjust some basic set-tings in order to complete the installation.

Fig. 2.15: Completing the installation.

When you check View Release Notes?, a PDF document listing new features and resolved bugs in the current version of e2 studio is shown. You can also read this document later; you can find it in www2.renesas.eu/_custom/software/ree_eclipse/e2studio_ releasenote.pdf.

Before you can start e2 studio properly, you have to create a so-called workspace. In this folder, subfolders for your own projects are created automatically. It is best to accept the default setting whereby the workspace is created in your user directory. In this way, you do not loose it if you have to re-install e2 studio for some reason.

Page 36: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

36

Fig. 2.16: Creating a workspace.

Next, you have to integrate the installed toolchains. Check the top option Renesas CCRX to select every toolchain. You also have to select the checkbox Enable 'Toolchain integration' on startup.

Fig. 2.17: Integrating toolchains.

Now e2 studio starts by showing the message Code Generator Registration. Acknowledge this message by clicking OK.

Page 37: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

37

Fig. 2.18: e2 studio launches for the first time.

After a short installation process, you have to acknowledge the message Code Generator COM component registration. Use the start menu to launch e2 studio again.

Fig. 2.19: The last message prior to the restart of e2 studio.

Now you can start programming.

Page 38: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

38

2.2.2 Switching to another interface languagee2 studio is based on Eclipse, which in most open source projects is available in many dif-ferent languages. In order to switch to another interface language, you only have to load a different language module.

In the menu, select Help\Install new software. In the next dialog, click the Add... button.

Next, enter the string for the desired language, e.g. DE (for German), in the Name field and the following address of the download site in the Location field:

http://download.eclipse.org/technology/babel/update-site/R0.13.0/mars

Click OK. After a short while, the list of available language packs is shown.

Fig. 2.20: Selecting the German language pack.

Check the option Babel Language Packs in German. Click Next. The list of the packs to be downloaded is shown.

Page 39: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

39

Click Next again, accept the license agreement and click Finish. The download of the lan-guage pack starts automatically. It can take several minutes. If you see a security warning about unsigned content, just acknowledge it by clicking OK.

Fig. 2.21: You have to acknowledge this security warning by clicking OK.

After successful installation, you are asked to restart e2 studio. Confirm this message by clicking Yes.

Fig. 2.22: Restarting e2 studio after installing the new language pack.

After restarting the program, the interface is shown in the selected language.

Page 40: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

40

2.2.3 The user interfaceAfter launching e2 studio, you can see the development environment. The window is divided into several panes.

Fig. 2.23: The panes of the user interface of e2 studio.

The Project Explorer (1 in Fig. 2.23) allows you to navigate the project. It shows a logical view of the project. It is important to note that this view does not clearly match the saved project. In order to open the project in the file manager of the system, right-click to open the context menu and select System Explorer. In addition to the Project Explorer tab, the Project Explorer also has a menu with five icons. With the third icon, you can minimize the Project Explorer (Fig. 2.24).

Fig. 2.24: Icon menu of the Project Explorer.

Page 41: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

41

To show the Project Explorer again, click one of the two icons in the right side bar in Fig. 2.25.

Fig. 2.25: Showing the Project Explorer again.

Alternatively, select the function Window\Show View\Project Explorer in the e2 studio menu (5 in Fig. 2.23). When you double-click the Project Explorer tab, it will be maximized. Another double-click minimizes it again. This works in every view of e2 studio (see also the section »Perspectives and views«).

To open a file in the Project Explorer, you have to double-click it. The file will be opened in the pre-configured view in pane 2 (Fig. 2.23). In the side bar (3) and in pane 4, you can find other views for working with your project.

Page 42: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

42

2.2.4 Source text editorYou will edit most files in the source text editor of e2 studio. Hence, the most important features of this editor are explained in this section. When you open a source file (with the file extension .c or .cpp), it appears in the source text editor, which is divided into several panes (Fig. 2.26).

Fig. 2.26: The panes of the source code editor.

The largest part (1 in Fig. 2.26) is the source text pane. The line with the cursor is highlighted in color (light blue per default). On the left-hand side of the source text, there are three bars (2, 3 and 4 in Fig. 2.26). When you left-click in the white area (2), the cursor jumps to the respective line. When you click the outer bar (3), a breakpoint is set in the corresponding line (see also the section »Using the debugger« on page 46). It is possible to open several files at once in the source text editor. Each file is shown in a tab of its own (5 in Fig. 2.26). The current tab is selected. When you hover the mouse pointer over a function, a short descrip-tion is shown (Fig. 2.27).

Page 43: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

43

Fig. 2.27: The API documentation appears in an additional window near the function.

Bar 4 (Fig. 2.26) contains the »+« and »–« icons to expand and collapse block comments and functions. The source code editor has two context menus: One menu is opened when you click the side bar; the other one is opened when you click the source text pane. When you select a function by double-clicking it, it will be highlighted in color (Fig. 2.28). When you now open the context menu, you see actions for the selected functions.

Fig. 2.28: The function R_GPIO_PortDirectionSet is selected.

An important action in this context menu is Open Declaration. It allows you to jump directly to the implementation of the selected function. When you want to see the call hierarchy of a function, select the Open Call Hierarchy option in the context menu.

Fig. 2.29: The call order is shown by arrows. Here, the main function calls the R_GPIO_PortDirectionSet function.

Page 44: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

44

2.2.5 Perspectives and viewsThe user interface of e2 studio is made up of several views, e.g. the source text editor. Usu-ally, the interface renders several views. A combination of views can be saved as a perspec-tive. When using this manual, you will at least use the C\C++ perspective, the Code Genera-tor perspective and the Debug perspective. There are several ways to open a perspective. First, there is a quick access menu in e2 studio (Fig. 2.30).

Fig. 2.30: The most frequently used perspectives can be selected by icons.

If the menu is not available or the desired perspective is missing from the menu, you can also use Window\Perspective\Open Perspective in the main menu of e2 studio to open a per-spective. If you cannot find the perspective in the menu either, select Window\Perspective\Open Perspective\Other … Here, you get a menu with all available perspectives (Fig. 2.31).

Fig. 2.31: All perspectives configured in e2 studio.

You can maximize an open view by double-clicking it. Another double-click reverts it to its original size. When a view is closed, you can select and open it via Window\Show View. If the view is not shown there, you can view a list of all views by selecting Window\Show View\Other … (Fig. 2.32). There are so many views available that you can also use full-text search to find the desired view.

Page 45: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

45

Fig. 2.32: The numerous views are sorted by category.

This summary also shows the Code Generator category for the Peripheral Code Generator and the e2 solution toolkit category for the FIT Configurator. Alternatively, you can open these special menus under the Renesas Views option in the e2 studio main menu. You can find the Peripheral Code Generator under Renesas Views\Code Generator and the FIT Con-figurator under Renesas Views\e2 solution toolkit\FIT Configurator.

2.2.6 Configuring the debuggerThe development environment includes a powerful graphical debugger. Together with the integrated E2 Lite debugger of the Revelation Kit, this gives you all you need for debugging. After you have successfully compiled a program, you can use the debugger to download it to the board and to test it. When creating a C project in e2 studio (see the section »Creat-ing a project« on page 51), a debugger configuration is created automatically; however, it is not yet set up. To set it up, you first have to select it by using the menu option Run\Debug Configurations … Below Renesas GDB Hardware Debugging, the most relevant con-figurations are listed. The name of the configuration matches the project name, followed by HardwareDebug. For the purpose of explanation, we choose the configuration of project 1, PCG_LED_Flasher HardwareDebug (Fig. 2.33).

Page 46: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

46

Fig. 2.33: Selecting a debugger configuration for adjustmentAfter selecting the debugger configuration, it opens. The header line immediately shows an error message, Performance Timer Operating Frequency must not be empty and must be between 0.001 & 999.999MHz (Fig. 2.34).

Fig. 2.34: It is not possible to use a debugger configuration that is not yet set up; first, you have to set the timer frequency.

This error message appears because the debugger configuration is not yet set up. Select the Debugger tab for this configuration, and within this tab select the Connection Settings tab (Fig. 2.35).

Page 47: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

47

Fig. 2.35: The many options for debugger configurations are distributed among several tabs.

Select the Connection Settings tab and scroll down to the heading Power. Set Power Target From The Emulator (MAX 200mA) to No. As you use the internal debugger, the voltage is supplied by the board and not by an external emulator (Fig. 2.36).

Fig. 2.36: The power supply source has to be configured.

Next, change to the Debug Tool Settings tab within the Debugger tab (Fig. 2.37).

Fig. 2.37: Debug Tool Settings.

Scroll down to the heading Performance Timer and set Operating Frequency [MHz] to 240 (Abbildung 2.38). Activate the configuration by clicking Apply.

Fig. 2.38: Timer settings.

Page 48: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

48

2.2.7 Using the debugger Now that you have configured the debugger, you can test the program on the board.

Before you attach the board, you have to change the setting of the SW2 switch. Upon deliv-ery, both parts of the switch (21 and 12) are set to OFF. Set part 1 of the switch to ON. Connect the board via the CN9 socket to your computer. Now LED5 should flash. Start the debug-ger by clicking the Debug button. LED5 should no longer flash but shine continuously. This shows that the connection to the debugger is established. The program is now transferred to the board. After a successful download, you are asked to change the perspective in e2 studio. Confirm by clicking Yes (Fig. 2.39).

Fig. 2.39: There is a dedicated debugger perspective in e2 studio.

The debugger appears, and the program halts at the function PowerOn_Reset_PC (Fig. 2.40).

Fig. 2.40: The current line is highlighted in green.

1 Left part of the SW2 DIP switch.2 Right part of the SW2 DIP switch.

Page 49: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

49

The debugger launches with its own perspective and several views. Pane 1 (Fig. 2.40) is the source text editor. It shows the currently executed code. The status bar (7 in Fig. 2.40) shows the status of the running program; in this case Suspended. When you have completed all the breakpoints and the program is running, the status changes to Running. Pane 2 presents the call hierarchy and shows in a tree view at which point the program is currently executing. The outline of the source code is shown in pane 3. Pane 4 helps you to examine the program at run time. Here you see the various views for examining the program. In Fig. 2.40, the IO Registers view is opened. Here you can examine the current contents of the registers. The consoles are shown in pane 5, the toolbar for controlling the process in 6. When you hover the mouse pointer over an icon, a short description of the function is shown. When you hover the mouse pointer over a function or a variable in the source text editor (Fig. 2.41), you see additional runtime information.

Fig. 2.41: Runtime information about the PowerOn_Reset_PC function.

As already stated, there are four views for examining the program. One of the most impor-tant views is Variables, which allows you to examine the variables (Fig. 2.42).

Fig. 2.42: The my_cmt variable in the Variables view.

Page 50: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

50

In Fig. 2.42, you see the variable my_cmt, which is shown with the value <optimized out>. This is because during compilation, the program is optimized for size. Therefore, not all debug information is created, and thus you cannot see the respective values. As this does not allow for efficient debugging, you can change this behavior by turning off the optimiza-tion feature. In the Project Explorer, select the project and use File\Properties in the main menu to open the project properties (Fig. 2.43).

Fig. 2.43: In the Properties window, you can access the project settings, including the compiler settings.

The Properties window opens. In the left menu, select C\C++ Build\Settings. In the right part of the window, the Settings view appears. Select Compiler\Optimize and set Optimize level to 0 (Fig. 2.44).

Fig. 2.44: With optimization turned off, you can also see the value of the variable.

Page 51: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

51

In order to examine a program in more detail, you have to set breakpoints by clicking on the side bar of the source text editor (3 in Fig. 2.26 on page 39). In the corresponding line, a circle is shown, and during debugging, the program will stop at this line (Fig. 2.45). With a subsequent double-click, you can delete the breakpoint.

Fig. 2.45: The program stops at the breakpoint.

When you right-click a breakpoint in the source text editor, you see a context menu. With the Disable Breakpoint option, you can deactivate the breakpoint. To reactivate it, select Enable Breakpoint.

Reset SW2 after debuggingDo not forget to reset the SW2 switch to its original state (both parts set to OFF).

Page 52: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

52

2.3 Creating a projectIn e2 studio, you work in projects. Projects for the Revelation board are C projects. This is the type of project that we will create now.

Step 1: Specify project name and project type

In the menu, select File\New\C Project to open the C Project dialog. Enter the project name in the field Project name. The option Use default location is checked by default (Fig. 2.46).

Fig. 2.46: The project name automatically determines the location; here it is SampleProject in the workspace.

This means that the project is saved within the workspace in a directory with the name of the project. If you want to change this behavior, you have to uncheck this option. You can then change the directory as needed. However, this is not recommended. Next, you have to select the type of the project. In the Executable (Renesas) category, select Sample Project. Select Renesas RXC Toolchain as the toolchain. This choice allows you to test the project directly on the Revelation board.

Fig. 2.47: Selecting the project type and the toolchain.

Page 53: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

53

Show only supported project typese2 studio is based on the Eclipse platform, which offers a broad functionality. Hence, many different project types are available under Project type. After installation of e2 stu-dio, the option Show project types and toolchains only if they are supported on the plat-form is selected by default. This causes the program to show only a limited choice.

Step 2: Configure the target hardware

Click Next to get to the Select Target Specific Settings screen where you can specify the tar-get hardware. For all projects in this manual, set Toolchain Version to v2.05.00. As you will use the debugger on the Revelation board, select the Debug Hardware option E2 Lite (RX). Accept the preset option of Data endian, i.e. Little-endian data. Finally, you have to select the MCU in Select Target. Choose RX700\RX71M\RX71M – 100pin\R5F571MLCxFP. Leave the rest of the settings at their default values (Fig. 2.48).

Fig. 2.48: Pay attention to select the correct MCU (R5F571MLCxFP) when configuring the target hardware.

Page 54: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

54

Step 3: Specify the development technology

Click Next to get to the Code Generator and FIT Settings screen. Here you define which de-velopment technologies you want to use in the project. You can use the Peripheral Code Generator, the Firmware Integration Technology (FIT), or both. The three options are ex-plained in further detail in the following sections.

2.3.1 Peripheral Code GeneratorIf you want to use the Code Generator for a project, you first have to follow the steps 1 and 2 in the section »Creating a project« and to select the option Use Peripheral code Generator in the installation step Code Generator and FIT Settings (Fig. 2.49).

Fig. 2.49: The code generator is selected.

Now you can create the project by clicking Finish. Subsequently, you see a summary of the selected settings in the Project generator summary window. After clicking OK, the project is created. Next, you are asked if you want to switch to the C\C++ perspective. Confirm by click-ing Yes. When using the Code Generator, many settings are configured and afterwards gen-erated as source code. You configure these settings in the Code Generator, which you open by selecting Renesas Views\Code Generator\Peripheral Functions (Fig. 2.51). Alternatively, you can open the Code Generator in the Project Explorer. Under Code Generator, expand the Peripheral Functions menu (Fig. 2.50) so that the various panes of the code generator are shown. Double-click to open the Code Generator with the selected pane.

Page 55: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

55

Fig. 2.50: You can also open the code generator directly in the project tree.

Together with the Code Generator, the so-called Clock Generator is opened. This is one of several panes in the Code Generator. Some of the panes present so many options that they are split into tabs.

Fig. 2.51: Code Generator opened with Clock Generator.

Above the settings pane of the Code Generator, there is a menu bar with three actions (Fig. 2.53). The first action, Generate Code, creates source code based on the configured settings. The second action opens the Code Generator Console and displays a generator report (Fig. 2.52).

Page 56: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

56

Fig. 2.52: Summary of the generator actions in the Generator Console.

The last action displays a menu of the available Code Generator panes. By selecting a line in the expanded menu, you navigate to the respective pane.

Fig. 2.53: Menu bar of the Code Generator.

After clicking Generate Code, the source code is created in the cg_src directory (Fig. 2.54).

Fig. 2.54: Within the src directory, there is the cg_src directory with the source files created by the generator.

Page 57: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

57

2.3.2 Firmware Integration Technology (FIT)If you want to use FIT for a project, you first have to follow steps 1 and 2 in the section »Creat-ing a project« (on page 51) and to select the Use FIT module option in the installation step Code Generator and FIT Settings (Fig. 2.55).

Fig. 2.55: FIT is selected.

When using FIT for the first time, you have to download the so-called FIT modules. Click the Download FIT modules button and select your region (Fig. 2.56).

Fig. 2.56: When downloading the FIT modules, you have to specify the region of your work station.

In the examples in this manual, the region Europe\Middle East\Africa is selected, but of course you have to adjust the selection to your region. After choosing the region, a list of available FIT modules is shown (Fig. 2.57).

Page 58: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

58

Fig. 2.57: Renesas provides many FIT modules for various functions.

It is best to download all available FIT modules. Use the Select All button to select all mod-ules, and then download them by clicking Download. Now you have to enter the details of your My Renesas account (Fig. 2.58).

Fig. 2.58: The details of the My Renesas account used for downloading the development environment are required again for downloading the FIT modules.

Page 59: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

59

After entering the details, you have to accept the END USER LICENSE AGREEMENT by click-ing the Agree button. The modules are downloaded. You can monitor the progress of the download in the Progress Information window (Fig. 2.59).

Fig. 2.59: Downloading the FIT modules takes some time.

Another information window with the message FIT module download is finished notifies you of the successful completion of the download (Fig. 2.60).

Fig. 2.60: The FIT modules have been downloaded successfully.

Now you are back in the configuration step Code Generator and FIT Settings. To complete the configuration, click Finish. A summary of the project is shown, and when you click OK, the project is created. During the creation of the project, a confirmation dialog is shown (Fig. 2.61) asking you if you trust the Renesas certificate. Select the specified certificate and acknowledge it by clicking OK.

Page 60: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

60

Fig. 2.61: You have to trust the Renesas certificate.

In order to work with FIT, the Board Support Package (BSP) has to be included. To do this, open the FIT Configurator by selecting Renesas Views\e2 solution toolkit\FIT Configurator in the menu (Fig. 2.62). Select the module r_bsp and add it by clicking Add Module >>. With << Remove Module, you can remove a FIT module from a project.

Fig. 2.62: Choose the required FIT modules for your project from the list of available modules.

Page 61: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

61

FIT modules with different versionsThe FIT modules listed in the FIT Configurator have a name (Modules column), a descrip-tion (Description column) and a version (Version column). When there are different ver-sions of a FIT module, the newest one is selected by default. If you want to use a different version, you have to click the Version column. This opens a dropdown menu with the available versions.

Here you can choose the desired version.

Next, click Generate Code at the top of the FIT Configurator (Fig. 2.63).

Fig. 2.63: Similar to the Peripheral Code Generator, the FIT Configurator has a menu at the top.

This causes e2 studio to generate the respective code. A confirmation window (FIT Genera-tion – Summary) shows the changes that have been made (Fig. 2.64).

Fig. 2.64: The newly added FIT modules are listed. The module r_config is added automatically.

Page 62: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

62

When adding r_bsp, the FIT module r_config is added automatically. After completing the generation process, the project has two additional directories, r_bsp and r_config (Fig. 2.65).

Fig. 2.65: Every FIT module has its own directory in the project tree.

Page 63: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

63

Documentation of a FIT moduleWhen adding FIT modules to a project, a new directory is created for each module in the project. The name of the directory is the name of the corresponding FIT module (e.g. r_bsp). In the subdirectory doc, you can find the documentation for the module

After downloading the FIT modules, they are located in the e2 studio directory under FITModules.

The documentation for a FIT module can be found in the doc subdirectory of the respec-tive module directory.

Manually adding a FIT module to a projectBesides using the FIT Configurator, you can also add a FIT module manually. To do so, copy the whole corresponding directory, e.g. r_flash_rx, into the project directory. You also have to copy the configuration file from the ref directory into r_config. The names of the files in the ref directory include the string _reference, e.g. r_flash_rx_config_reference.h. For the files in the r_config directory, you have to delete this part of the name. The file in our example would thus be called r_flash_rx_config.h.

Page 64: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

64

2.3.3 Combining Peripheral Code Generator and FITYou can also use both the Code Generator and FIT in the same project. To do this, follow steps 1 and 2 in the section »Creating a project« (page 51) and select both options Use Pe-ripheral code Generator and Use FIT module in the installation step Code Generator and FIT Settings (Fig. 2.66).

Fig. 2.66: When using FIT for the first time, you have to download the modules via Download FIT modules.

Now you can generate the project by clicking the Finish button. The Peripheral Code Gen-erator and FIT have to be synchronized. To do this, open the Peripheral Functions view by selecting Renesas Views\Code Generator\Peripheral Functions. On the pre-selected Clock setting tab, click the Load button (Fig. 2.67).

Fig. 2.67: Click Load to align the configuration of the Board Support Package and the Code Generator.

This loads parameters such as the clock settings and external oscillator frequency into the Code Generator from the file r_bsp_config.h. If you need to change these parameters for your application or target hardware, you can change the settings within Code Generator and the r_bsp_config.h file will be overwritten with the new settings when »Generate Code« is selected.

Page 65: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

65

Initialization in the source code requiredThe Code Generator and the Firmware Integration Technology have been developed inde-pendently. In order to use them together, you not only have to synchronize the Code Gen-erator and the BSP (Fig. 2.67), but you need to include a function call to initialise periph-erals configured with Code Generator. If you are using only Code Generator the function HardwareSetup() is called automatically in the start-up code in »r_cg_resetprg.c«. However when using Firmware Integration Technology a different start-up code in file »resetprg.c« is executed and so HardwareSetup() is not called automatically. There-fore we need to include a call to HardwareSetup() at the beginning of main().

2.3.4 Why are both Code Generator and FIT provided for RX71M?Code Generator and Firmware Integration were developed as separate and alternate ways of providing driver code for RX peripherals and on-chip functions. Code Generator was in-tended to provide an easy to use tool, mainly for static initialisation of simple peripherals such as timers, serial ports and analogue functions. Meanwhile separate middleware was provided for driving more complex peripherals such as USB and Ethernet and for controlling on-chip Flash programming. Later Firmware Integration Technology was developed as a way to combine device initialisation and peripheral drivers and complex middleware into a single software architecture.

In the latest RX devices Renesas has allowed users to incorporate both Code Generator and FIT in the same project and to pick and choose which of these tools to use for some peripherals.

So whether to use Code Generator or FIT to configure the Compare Match Timer, for ex-ample, is down to user preference, and which approach they prefer or is most suitable for their application.

However to use more complex Renesas provided middleware, such as TCP/IP stack or USB drivers, for the latest RX microcontrollers such as RX71M FIT must be used.

Page 66: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and
Page 67: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

67

3. Projects for the Revelation BoardThe following descriptions of three projects do not include the complete source text. Only the most important steps will be shown. You can download the projects from http://www.renesas.com/revelation.

3.1 Project 1: Flashing LED with Compare Match Timer and Peripheral Code GeneratorThis project uses the Peripheral Code Generator alternate illumination of LED0 and LED1. To switch between the LEDs, a Compare Match Timer (CMT) is used. This section describes the project step by step.

Step 1: Create the C projectAs explained in the section »Creating a project« (page 51), you first have to create a C project named PCG_LED_Flasher. Select the Peripheral Code Generator as your development technology as described in the section »Peripheral Code Generator« (page 54). When the project is created, it shows up in the Project Explorer of e2 studio (Fig. 3.1).

Fig. 3.1: The sample project PCG_LED_Flasher.

Step 2: Configure the clock generatorNext, you have to configure the clock generator, the so-called resonator. Open the Code Generator via Renesas Views\Code Generator\Peripheral Functions. If the Code Generator window is too small, enlarge it by double-clicking the Code Generator tab (Fig. 3.2).

Fig. 3.2: The Code Generator.

Configure the resonator in the Main clock oscillator and RTCMCLK setting section. For Main clock oscillation source, accept the default setting Resonator. Set the Frequency to 12, i.e. 12 MHz (Fig. 3.3).

Page 68: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

68

Fig. 3.3: Settings for the resonator.

Next, turn on PLL circuit setting by checking the Operation option in this section. Select x 20.0 for Frequency multiplication factor (Fig. 3.4).

Fig. 3.4: Configuring PLL circuit setting.

Next, you have to configure the System clock setting section. For Clock source, select the previously configured PLL circuit and set it up according to Fig. 3.5.

Fig. 3.5: Configuring PLL circuit setting.

Page 69: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

69

Step 3: Activate the on-chip debuggerNavigate to the On-chip debug setting tab and turn on the debugger by selecting JTAG. (Fig. 3.6) Save the changes by pressing [Ctrl]+[S].

Fig. 3.6: Addressing the integrated debugger via JTAG.

Step 4: Turn on the LEDsIn the menu bar of the Peripheral Code Generator, click the icon with the downwards arrow and select I\O Ports. Switch to the PortA tab and configure PA0 and PA1 as outputs by select-ing Out. The initial state of PA1 should be 1; hence you have to select the checkbox Output 1 (Fig. 3.7). Save your changes by pressing [Ctrl]+[S].

Fig. 3.7: Defining the ports connected to the LEDs as outputs.

Step 5: Configure the Compare Match TimerThe alternating flashing of the LEDs is accomplished by a Compare Match Timer, which can also be configured in the Peripheral Code Generator. In the menu bar of the Code Generator, click the icon with the downwards arrow and select Compare Match Timer. The CMT0 tab is pre-selected. Turn on the timer by clicking Used and set Count clock setting to PCLK\512. Set Interval value to 250 ms and Priority to Level 1 (Fig. 3.8).

Page 70: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

70

Fig. 3.8: After the specified interval, the CMT triggers an interrupt.

Save the changes by pressing [Ctrl]+[S]. Create the source code by clicking Generate Code. After a short while, the newly generated source files will appear in the directory src/cg_src (Fig. 3.9).

Fig. 3.9: All configurations in the Peripheral Code Generator result in a source file, e.g. r_cg_cmt.c for the configured CMT.

Step 6: Start the timer in the source codeNext, you have to start the timer in the source code. Open the file r_cg_main.c by select-ing it in the Project Explorer or by pressing [Ctrl]+[Shift]+[R] and entering r_cg_main.c. The source code file r_cg_main.c opens in the source code editor of e2 studio (Fig. 3.10).

Page 71: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

71

Insert source code at the right placeWhen using the Code Generator, the system creates much of the source text. Howev-er, you cannot avoid writing source text of your own. However, you have to insert your source text at the right place so that it will not be overwritten in the next pass of the Code Generator. The sections reserved for your source text are marked by the following comments:

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

Source code between these comments does not get overwritten by the Code Generator.

Fig. 3.10: When using the Peripheral Code Generator, e2 studio relieves you of much typing work.

Between the comments, add a call to R_CMT0_Start to the main method. This call starts the timer CMT0, which you have previously configured in the Peripheral Code Generator. If you want to use a different Compare Match Timer, you have to call a different method. Here you see the code of the main function:

Page 72: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

72

void main(void) { R_MAIN_UserInit(); /* Start user code. Do not edit comment generated here */ R_CMT0_Start(); while (1U) { ; } /* End user code. Do not edit comment generated here */ }

Step 7: Switch the LEDs in the interruptNext, you have to program the switch between the two LEDs. The right place for doing this is the interrupt method called by CMT0. The corresponding function can be found in the source file r_cg_cmt_user.c in the directory cg_src. Open this file in the Project Explorer or in the Open Resource dialog by pressing [Ctrl]+[Shift]+[R]. In the source text editor, find the function r_mt_cmi0_interrupt and add the required code:

static void r_cmt_cmi0_interrupt(void) { /* Start user code. Do not edit comment generated here */ PORTA.PODR.BIT.B0 ^= 1; PORTA.PODR.BIT.B1 ^= 1; /* End user code. Do not edit comment generated here */ }

Step 8: Compile the programThe program is now complete and can be tested on the Revelation Board. To do this, you have to build it first. Click the hammer icon (Fig. 3.11) or press [F7].

Fig. 3.11: The most important functions of e2 studio are available in the tool bar below the menu.

The compilation takes some time. When it is completed successfully, the console displays the message Build Finished. 0 errors.

Step 9: Execute the programSet up the debugger configuration PCG_LED_Flasher HardwareDebug as described in »Con-figuring the debugger« (page 44), and launch the program as shown in »Execution in e2 stu-dio« (page 94). The two LEDs should flash alternately.

Page 73: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

73

3.2 Project 2: Flashing LED with Compare Match Timer and FITThis project uses Firmware Integration Technology to let the LEDs LED0 and LED1 flash alter-nately as in the first project (see page 66). Again, a Compare Match Timer (CMT) is used for switching between the LEDs. This section describes the project step by step.

Step 1: Create the C projectAs explained in the section »Creating a project« (page 51), you first have to create a C project named FIT_LED_Flasher. Select FIT as your development technology as described in the chapter »Firmware Integration Technology (FIT)« (starting at page 57). When the project is created, it shows up in the Project Explorer of e2 studio (Fig. 3.12).

Fig. 3.12: The project with the added Board Support Package (r_bsp).

Step 2: Configure the clock generator in the source codeWhen using FIT, the configuration is carried out directly in the source code. Open the source file r_bsp_config.h created by e2 studio in the directory r_config by double-clicking inside the source code editor (Fig. 3.13).

Fig. 3.13: The MCU configuration is located in the file r_bsp_config.h.

Page 74: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

74

First, you have to specify the MCU type:

#define BSP_CFG_MCU_PART_PACKAGE (0x5)

Then, you have to specify the clock frequency:

/* Input clock frequency in Hz (XTAL or EXTAL). */ #define BSP_CFG_XTAL_HZ (12000000)

Scroll down to locate the multiplier:

/* PLL Frequency Multiplication Factor Select (STC). Available multipliers = x10.0 to x30.0 in 0.5 increments (e.g. 10.0, 10.5, 11.0, 11.5, ..., 29.0, 29.5, 30.0) */ #define BSP_CFG_PLL_MUL (20.0)

Step 3: Add FIT modules for CMT and GPIO accessSwitching between the LEDs is again done in an interrupt method, which is called by the Compare Match Timer in the specified rhythm. In order to switch the LEDs physically, GPIO is used. In order to use the Compare Match Timer and GPIO, you have to add two FIT modules. Open the FIT Configurator via Renesas Views\e2 solution toolkit\FIT Configurator, add the modules r_cmt_rx and r_gpio_rx to the project and click Generate Code (Fig. 3.14).

Fig. 3.14: Now the project can use CMT and GPIO.

After switching to the C\C++ perspective, you should see the additional directories r_cmt_rx and r_gpio_rx in the Project Explorer (Fig. 3.15).

Page 75: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

75

Fig. 3.15: The two additional FIT modules are represented by their respective directories in the project tree.

Step 4: Include header filesThe proper functionality is now added in the source file FIT_LED_Flasher.c. Open it in the source text editor. In order to use the functions provided by the FIT modules r_cmt_rx and r_gpio_rx in the source code, you have to include the corresponding header files, in this case r_cmt_rx_if.h and r_gpio_rx_if.h. Include them by using the #in-clude directive:

#include "r_cmt_rx_if.h" #include "r_gpio_rx_if.h”

Step 5: Configure the GPIO portBoth LEDs are connected to GPIO port A. In order to turn the LEDs on and off, this port must be defined as an output by using the R_GPIO_PortDirectionSet function. Add the following line to the main function:

R_GPIO_PortDirectionSet (GPIO_PORT_A,GPIO_DIRECTION_OUTPUT,0x03);

Step 6: Start the CMTTo make the LEDs flash alternately, the CMT has to be started by the method R_CMT_Cre-atePeriodic:

uint32_t my_cmt; if (R_CMT_CreatePeriodic(2,my_cmt_callback,&my_cmt)==false) while(1){};

Page 76: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

76

The my_cmt_callback variable is a function pointer to the interrupt method that will be implemented in the next step.

Step 7: Implement the callbackSwitching between the LEDs is implemented in the my_cmt_callback method. To do this, the GPIO port is toggled by the the R_GPIO_PinWrite method:

void my_cmt_callback(void *pdata) { static bool led_on = false; if(led_on) { R_GPIO_PinWrite(GPIO_PORT_A_PIN_0,GPIO_LEVEL_HIGH); R_GPIO_PinWrite(GPIO_PORT_A_PIN_1,GPIO_LEVEL_LOW); led_on = false; } else { R_GPIO_PinWrite(GPIO_PORT_A_PIN_0,GPIO_LEVEL_LOW); R_GPIO_PinWrite(GPIO_PORT_A_PIN_1,GPIO_LEVEL_HIGH); led_on = true; } }

Step 8: Execute the programSet up the debugger configuration FIT_LED_Flasher HardwareDebug as described in »Con-figuring the debugger« (page 44), and start the program as shown in »Execution in e2 stu-dio« (page 94). Now the two LEDs should flash alternately.

Page 77: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

77

3.3 Project 3: Determining the temperature, writing it to the Flash memory and displaying it via USB

This project puts everything together by using the Peripheral Code Generator as well as FIT. The internal temperature sensor of the RX71M is read by means of the ADC and then written into a file in the internal DataFlash of the RX71M. The RX71M on-board USB0 interface is configured as a Peripheral Mass Storage Class device and the file is then available to read from a PC via the USB connection (CN3).

Step 1: Create the C projectAs explained in the section »Creating a project« (page 51), you first have to create a C project named Temperature_USB. Select both the Peripheral Code Generator and FIT as your development technologies as described in the section »Combining Peripheral Code Genera-tor and FIT« (page 66). When the project is created, it shows up in the Project Explorer of e2 studio (Fig. 3.16).

Fig. 3.16: The sample project Temperature_USB.

Manually adding a FIT module to a projectBesides using the FIT Configurator, you can also add a FIT module manually. To do this, copy the whole corresponding directory, e.g. r_flash_rx, into the project directory. You also have to copy the configuration file from the ref directory into r_config. The names of the files in the ref directory include the string _reference, e.g. r_flash_rx_config_reference.h. For the files in the r_config directory, you have to delete this part of the name. The file in our example would thus be called r_flash_rx_config.h.

When using the Peripheral Code Generator and FIT in combination, it is important to join these technologies in the source code. To this end, you insert a call to the HardwareSetup method into the existing file Temperature_USB.c:

void main(void) { HardwareSetup(); }

Page 78: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

78

Step 2: Configure the ADCThe ADC can be configured in the Peripheral Code Generator. In the menu, select Renesas Views\Code Generator\Peripheral Functions to open the Code Generator. Use the menu (downward arrow) to navigate to the pane 12-Bit A\D Converter. Open the S12AD1 tab and select Used to turn on ADC1 (Fig. 3.17).

Fig. 3.17: Activating the AD converter.

As you want to read values continuously, select the option Continuous scan mode in the Operation mode setting pane (Fig. 3.18).

Fig. 3.18: Continuously reading values.

Next, you have to specify that you want to read temperature values. You do this in the Ana-log input channel setting pane. Under Convert (Group A), select the checkbox in the line Temperature sensor output (Fig. 3.19).

Page 79: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

79

Fig. 3.19: Sensor values will be read

Next, turn off the interrupt by deselecting the option Enable AD conversion end interrupt (S12ADI1) in the Interrupt setting pane (Fig. 3.20).

Fig. 3.20: Deactivating the interrupt.

The AD converter is now configured. Use Generate Code to create the source code. Now the directory src/cg_src should look as in Fig. 3.21.

Page 80: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

80

Fig. 3.21: Three files have been created for using the AD converter: r_cg_s12ad_user.c, r_cg_s12ad.c and r_cg_s12ad.h.

Start the AD converter in the main method of the file Temperature_USB.c. First, you have to include two header files at the beginning of the file, namely stdint.h for the type definition (e.g. uint16_t) and cg_src/r_cg_s12ad.h for using the AD converter:

#include "stdint.h" #include "cg_src/rg_cg_s12ad.h"

In the main method, start the AD converter by calling the R_S12AD1_Start method:

void main(void) { HardwareSetup(); R_S12AD1_Start(); while (1); }

Step 3: Read the temperature from the ADCYou use the method R_S12AD1_Get_ValueResult to read the values. Note that it may take some time until a value is returned; that is why the read is carried out in a while loop. The value is saved in the variable adc_value:

Page 81: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

81

void main(void) { HardwareSetup(); R_S12AD1_Start(); uint16_t adc_value =0; while (adc_value == 0) { R_S12AD1_Get_ValueResult(ADTEMPSENSOR, &adc_value); } while (1); }

You can quickly check the value of adc_value in the debugger. In doing so you will notice that the return value is not specified in centigrade but in millivolt (Fig. 3.22).

Fig. 3.22: The return value is stated as 1559.

Page 82: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

82

Converting the return value of the AD converterIn order to convert the value returned by the ADC to centigrade, you need a reference value.1 Table 64.50 in the data sheet specifies a value of 1.24 V for 25 °C. For calculating the temperature value, you use the following formula:

T = (Vs - V1)/slope + T1

According to the data sheet, slope amounts to 4.1. V1 is the reference value at the tem-perature T1. Vs is the value that you want to calculate. The ADC can represent 4096 val-ues at maximum and runs at a reference voltage of 3.3 V. Hence, Vs can be calculated as follows:

Vs = (1559/4096)*3.3 V = 1.256 V = 1256 mV

This results in the following temperature T:

T = (1256 – 1240)/4.1 + 25 °C = 28.9 °C

Next, the value in the variable adc_value has to be written to the Flash memory and sent via USB to the PC where you can view it.1

Step 4: Include FIT modules for Flash and USBIn order to use Flash and USB, additional FIT modules are required. Select Renesas Views\e2 solution toolkit\FIT Configurator to open the FIT Configurator. For USB, the modules u_usb_basic and r_usb_pmsc are required, and for Flash you need the module r_flash_rx. Furthermore, you have to write the file to an appropriate file system so that you can view it on the PC. With the FIT module r_tfat_rx, you can write files to a FAT file system. Select the four modules and generate the code by clicking Generate Code (Fig. 3.23).

Fig. 3.23: In total, five FIT modules are required for the project.

In the Project Explorer of e2 studio, the new project should look as in Fig. 3.24.

1 As sensors are subject to variance, it is recommended to carry out an additional measurement with a high-quality thermometer and to complement the calculation formula by a compensating factor.

Page 83: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

83

Fig. 3.24: There is a directory for each FIT module plus the separate directory r_config containing the module configuration.

Step 5: Include the TFAT libraryYou have already included the FIT module r_tfat_rx to use TFAT. But in order to use its functions at runtime, you have to reference the TFAT library. There are four libraries in the lib directory of the FIT module. The right one for the RX71M is tfat_rx600_little.lib (Fig. 3.25).

Fig. 3.25: The TFAT runtime libraries are stored in the lib directory. There are different versions for Little Endian and Big Endian.

Page 84: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

84

The library has to be provided to the linker. To do this, select the project in the Project Ex-plorer and open the project settings via File\Properties. Next, select C\C++ Build\Settings\Linker to open the linker settings (Fig. 3.26).

Fig. 3.26: Here you can configure the compilation process in detail.

At the top, you see a small icon menu. Click the plus sign (Fig. 3.27).

Fig. 3.27: External libraries have to be added manually. If you do not need a given library, you can use the X icon to remove it.

Now you have to select the correct library. Click the Workspace… button and select the tfat_rx600_little.lib library in the r_tfat_rx/lib directory of the project Temperature_USB. Confirm your choice by clicking OK (Fig. 3.28).

Fig. 3.28: When referencing a workspace library, path variables are used.

Page 85: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

85

Now the library should appear in the summary. You can use its functions in your program (Fig. 3.29).

Fig. 3.29: The tfat_rx600_little.lib library is now available in the program.

Step 5: Configure the FIT moduleWhen including a FIT module, a directory for the respective module is created in the project, e.g. r_tfat_rx for the TFAT module. Additionally, a configuration file is saved in the direc-tory r_config (Fig. 3.30).

Fig. 3.30: The configuration of the FIT modules takes place in header files.

Page 86: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

86

You have to alter the following configuration files2 in order to use Flash and USB:

• r_media_driver_api_config.h • r_usb_atapi_driver_config.h • r_usb_basic_config.h

First, you adjust the configuration of the USB access in r_usb_basic_config.h:

#define USB_FUNCSEL_USBIP0_PP USB_PERI_PP #define USB_FUNCSEL_USBIP1_PP USB_NOUSE_PP //#define USB_OVERCURRENT(ptr, data1, data2)

The access driver to be used is defined in r_usb_atapi_driver_config.h:

//#define USE_RAM #define ATAPI_MEDIA_LUN RAM_DISK_LUN #define USB_ATAPI_BLOCK_UNIT (512ul)

In r_media_driver_api.h, you have to add the new constant DATAFLASH_DISK_LUN:

typedef enum { SPI_FLASH_LUN = 0, /* device 0: Only RSK63N currently. */ SDCARD_LUN, /* device 1: Not implemented for PMSC. */ RAM_DISK_LUN, /* device 2: Default PMSC demo, all boards. */ DATAFLASH_DISK_LUN, /* device 3: Dummy */ /* Do not add after this line. */ MAX_NUM_LUNS /* Do not change this line. */ } media_lun_t;

2 The following listings only show the changes and not the complete files.

Page 87: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

87

Step 6: Implement Flash accessThe access to the Flash memory is implemented in the file r_usb_dataflash_disk.c. The corresponding header file r_usb_dataflash_disk.h contains the usable definition. First, you have to define the dimensions of the Flash memory as constants:

/* 64k - full size of data flash */ #define FLASHDISK_MEDIASIZE (64ul * 1024ul) /* 512 bytes per sector - 8 x Data Flash unit of programming */ #define FLASHDISK_SECTSIZE (512ul) #define FLASHDISK_TOTALSECT (FLASHDISK_MEDIASIZE / FLASHDISK_SECTSIZE) /* Number of bytes per data flash block */ #define FLASHDISK_DATA_FLASH_BLOCK (64)

Additionally, you have to define structures for the driver (dataflash_media_driver) and the boot sector (flash_disk_boot_sector):

extern struct media_driver_s g_dataflash_media_driver; extern uint8_t flash_disk_boot_sector[];

The driver structure in r_usb_dataflash_disk.c specifies the device (previously de-fined in r_media_driver_api.h) and the functions to be used:

struct media_driver_s g_dataflash_media_driver = { DATAFLASH_DISK_LUN, &flash_disk_open, &flash_disk_close, &flash_disk_read, &flash_disk_write, &flash_disk_ioctl };

Page 88: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

88

Step 7: Implement USB accessThe USB access is implemented in r_usb_pmsc_apl.c and defined in r_usb_pmsc_apl.h. The following functions are important:

void usb_main( void ); void usb_msc_driver(void); void usb_driver_init( void ); void pmsc_registration(USB_UTR_t *ptr); void usb_mcu_init(void); void usb_board_init( void ); void media_driver_init( void ); void msc_configured(USB_UTR_t *ptr, uint16_t data1, uint16_t data2); void msc_detach(USB_UTR_t *ptr, uint16_t data1, uint16_t data2); void msc_suspended(USB_UTR_t *ptr, uint16_t data1, uint16_t data2);

The method usb_main initializes the USB access:

void usb_main( void ) { /* USB pin function and port mode setting. */ usb_mcu_init(); /* RSK I/O Initialisation process */ usb_board_init(); /* Start Peripheral USB driver */ usb_driver_init(); /* Initialisation Media driver */ media_driver_init(); }

To carry out changes at the USB port, the method usb_msc_driver has to be called periodically:

Page 89: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

89

void usb_msc_driver(void) { /* Scheduler */ R_usb_cstd_Scheduler(); if( USB_FLGSET == R_usb_cstd_CheckSchedule() ) { /* USB Peripheral control driver Task */ R_usb_pstd_PcdTask((USB_VP_INT_t)0); /* Execute ATAPI commands Process */ R_usb_pmsc_atapi_task((USB_VP_INT_t)0); /* Peripheral Mass Storage Class Task */ R_usb_pmsc_task((USB_VP_INT_t)0); } }

Step 8: Configure CMT0Open the Peripheral Code Generator by selecting the menu item Renesas Views\Code Gen-erator\Peripheral Functions. Use the Code Generator menu (downward arrow) to navigate to Compare Match Timer. Configure CMT0 as shown in Fig. 3.31 and create the corresponding source code by clicking Generate Code.

Fig. 3.31: Deactivating the interrupt.

Page 90: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

90

Step 9: Call USB periodicallyThe previously described method usb_msc_driver is periodically called by CMT0 in r_cmt_cmi0_interrupt inside cg_src/r_cg_cmt_user.c:

static void r_cmt_cmi0_interrupt(void) { /* Start user code. Do not edit comment generated here */ usb_msc_driver(); /* End user code. Do not edit comment generated here */ }

Step 10: Write the fileNow you can implement the functionality in the main method of Temperature_USB:

void main(void) { HardwareSetup(); usb_main(); R_CMT0_Start(); R_S12AD1_Start(); uint16_t my_value, adc_value = 0; while (adc_value == 0) { R_S12AD1_Get_ValueResult(ADTEMPSENSOR , &adc_value); } my_value = adc_value; FATFS file_system_object; FIL file_object; FRESULT fresult = R_tfat_f_mount(0, &file_system_object); if (TFAT_FR_OK == fresult) { fresult = R_tfat_f_open(&file_object, "0:temp.txt", TFAT_FA_CREATE_ALWAYS | TFAT_FA_WRITE); char char_to_write[4]; sprintf (char_to_write, "%u", adc_value); uint16_t writecnt = 0; if (TFAT_FR_OK == fresult) { fresult = R_tfat_f_write(&file_object, (void*) &char_to_write, sizeof(char_to_write), &writecnt); R_tfat_f_close(&file_object); } } while (1) ; }

Page 91: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

91

4. Executing programs on the Revelation BoardThere are two possibilities to execute a program on the Revelation Board:

• Execute the program directly in e2 studio • Upload the program to the board

4.1 Execution in e2 studioWhen executing a program in e2 studio, it is uploaded via the debugger so that you can debug it at the same time. First, you have to configure the debugger as described in »Con-figuring the debugger« (page 44). Then start the program as shown in the section »Using the debugger « (page 46). The program begins to run, but nothing happens. This is because the previously inserted source code is not yet executed. To execute it, continue debugging by clicking the green arrow or by pressing [F8] (Fig. 4.1).

Fig. 4.1: Clicking the green arrow continues program execution.

You have now arrived in the main method where you can see the code that you have in-serted (Fig. 4.2).

Fig. 4.2: The debugger has reached the main method of project 1.

Click the green arrow again. Now the program runs. In the case of project 1, the two LED flash alternately.

When changing a program, you have to compile it againIf you apply changes to a program, you have to recompile it before you start the debugger. Otherwise, the debugger will execute the old program.

Page 92: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

92

4.2 Executing programs without e2 studioOnly completely compiled programs can be executed without e2 studio. Among others, the development environment creates a MOT file, which you can upload directly to the board. This allows you to hand your completed program over to a colleague or a customer without having to share the whole source code project. This section describes how to upload a MOT file to the board. The sample program to illustrate this process is the one included with the board.

Programs on the board are overwrittenIt is important to note that any program installed on the board will be overwritten when you program the board.

4.2.1 Re-install the demo programIn order to re-install the demo program, you do not need e2 studio. Renesas provides a PC utility called Renessas Flash Programmer (RFP) to install compiled programs. Follow these steps to use it.

Step 1: Download

Download the Flash programmer from the following URL:

www.renesas.com/en-eu/products/software-tools/tools/programmer/renesas-flash-programmer-programming-gui.html

Again, you have to login with your Renesas account in order to download the tool. Make sure to download the most current version of the Flash programmer (v3.01.00 at the time of writing). In this example the free version (Free-of-charge edition) was used.

Page 93: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

93

Step 2: Install

Execute the file Renesas_Flash_Programmer_Package_V30100_free.exe that you downloaded to install the Flash programmer. You have to confirm the message of the Windows user account control.

Fig. 4.3: Installing the Flash programmer.

Keep all the preselected components to be installed. During installation, you have to con-firm the installation of a device driver.

Fig. 4.4: Installing the device driver.

Page 94: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

94

Additionally, download the project file for the demo program from http://www.renesas.com/revelation. This archive also contains the prebuilt .s file (RPB_RX71M_Image.s).

Step 3: Create the new project

Start the Renesas Flash programmer. In the menu, select File\Create New Project… to create a new project (Fig. 4.5).

Fig. 4.5: Creating a new project in the File menu.

A new dialog appears. In the Microcontroller field, select the microcontroller that you want to program, in this case RX700. Next, specify the project directory in Project Folder and the project name in Project Name. In this example, Renesas_Demo was chosen as the project name. The Flash programmer creates the new directory Renesas_Demo in the specified directory. Next, you have to specify how to transfer to program. For the Revelation Kit, the integrated E2 Lite debugger will be used. In the Tool box, select E2 Lite (Fig. 4.6).

Fig. 4.6: Configuring the programmer.

Page 95: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

95

Step 4: Connect to the board

Before you connect to the board, you have to change the position of the SW2 switch on the board. Upon delivery, both parts of this switch are set to OFF (2 and 1).1 Set switch 1 to ON. Connect the port to your PC via a USB cable at the CN9 port. Click Connect. After a short while, the green message Operation completed should appear. This tells you that the con-nection has been established successfully (Fig. 4.7).

Fig. 4.7: The connection has been established successfully.

Step 5: Download the demo project

Specify the file to be downloaded in the Program File field. Click Browse to select the file, in this case RPB_RX71M_Image.s. Click Start to transfer the program (Fig. 4.8).

1 Note that SW2 consists of two switches; the left one is switch no. 2, the right one is switch no. 1.

Page 96: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

96

Fig. 4.8: Uploading the program takes a while.

A successful download is indicated by OK next to the Start button (Fig. 4.9).

Fig. 4.9: The program has been successfully transferred to the board.

Step 6: Launch the program

Before you can start the program on the board, you have to reset the SW2 switch. Detach the USB cable from the PC, set switch no. 1 back to OFF and reattach the cable to the PC. Launch the demo program.

Page 97: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

97

5. Appendix5.1 Keyboard shortcuts in the source text editor

Command ShortcutHide all [Ctrl]+[Shift] + divide sign on the number pad

Show all [Ctrl] + multiplication sign on the number pad

Open call hierarchy [Ctrl]+[Alt]+[H]

Hide [Ctrl] + minus sign on the number pad

Select up to the beginning of the line [Shift]+[Home]

Select up to the end of the line [Shift]+[End]

Delete up to the end of the line [Ctrl]+[Shift]+[Del]

Remove block comment [Ctrl]+[Shift]+[\]

Add block comment [Ctrl]+[Shift]+[/]

Block selection on/off [Alt]+[Shift]+[A]

Build single file [Ctrl]+[Shift]+[Z]

Comment/uncomment [Ctrl]+[/]

Declaration [Ctrl]+[G]

Open declaration [F3]

Show [Ctrl] + plus sign on the number pad

Toggle insert mode [Ctrl]+[Shift]+[Ins]

Open element [Ctrl]+[Shift]+[T]

Explore macro expansion [Ctrl]+[=]

Extract constant – refactoring [Alt]+[C]

Extract function – refactoring [Alt]+[Shift]+[M]

Extract local variable – refactoring [Alt]+[Shift]+[L]

Format [Ctrl]+[Shift]+[F]

Go to line [Ctrl]+[L]

To upper case [Ctrl]+[Shift]+[X]

To lower case [Ctrl]+[Shift]+[Y]

Add include [Ctrl]+[Shift]+[N]

Toggle compression [Ctrl] + divide sign on the number pad

Show scale context menu [Ctrl]+[F10]

Toggle selection [Alt]+[Shift]+[O]

To the left [Shift]+[Tab]

Search next instance [Ctrl]+[K]

Next word [Ctrl]+[→]

Select next word [Ctrl]+[Shift]+[→]

Delete next word [Ctrl]+[Del]

Open include browser [Ctrl]+[Alt]+[I]

Page 98: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

98

Command ShortcutOrganize includes [Ctrl]+[Shift]+[O]

Quick type hierarchy [Ctrl]+[T]

Show quick info [F2]

References [Ctrl]+[Shift]+[G]

Restore last C/C++ selection [Alt]+[Shift]+[↓]

Toggle differences [Ctrl]+[Shift]+[Q]

Quick menu for Surround With [Alt]+[Shift]+[Z]

Quick menu for Show Source [Alt]+[Shift]+[S]

Search backwards step by step [Ctrl]+[Shift]+[J]

Search step by step [Ctrl]+[J]

Select enclosing C/C++ element [Alt]+[Shift]+[↑]

Select next C/C++ element [Alt]+[Shift]+[à]

Select previous C/C++ element [Alt]+[Shift]+[ß]

Show outline [Ctrl]+[O]

Sort lines [Ctrl]+[Alt]+[S]

Reset structure [Ctrl]+[Shift] + multiplication sign on the number pad

Start of text [Ctrl]+[Home]

End of text [Ctrl]+[End]

Toggle function – refactoring [Alt]+[Shift]+[T]

Toggle source/header [Ctrl]+[Tab]

Open type in hierarchy [Ctrl]+[Shift]+[H]

Open type hierarchy [F4]

Toggle overwriting [Einfg]

Rename – refactoring [Alt]+[Shift]+[R]

Search previous instance [Ctrl]+[Shift]+[K]

Previous word [Ctrl]+[←]

Select previous word [Ctrl]+[Shift]+[←]

Delete previous word [Ctrl]+[Back]

End of word [Alt]+[/]

Indent line [Ctrl]+[I]

Delete line [Ctrl]+[D]

Insert line above current line [Ctrl]+[Shift]+[Enter]

Add line below current line [Shift]+[Enter]

One line forward [Ctrl]+[↓]

One line back [Ctrl]+ [↑]

Duplicate lines [Ctrl]+[Alt]+ [↑]

Page 99: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

99

Command ShortcutCopy lines [Ctrl]+[Alt]+[↓]

Move lines upwards [Alt]+[↑]

Move lines down [Alt]+ [↓]

Merge lines [Ctrl]+[Alt]+[J]

Start of line [Pos1]

End of line [Ende]

To the next member [Ctrl]+[Shift]+[↓]

To the previous member [Ctrl]+[Shift]+[↓]

To matching bracket [Ctrl]+[Shift]+[P]

5.2 Keyboard shortcuts in the debugger

Command ShortcutsBuild all [Shift]+[F7]

Execute up to the end of the line [Ctrl]+[R]

Stop [Ctrl]+[F2]

Single step – Select [Ctrl]+[F5]

Reverse resume [Shift]+[F8]

Reverse step into [Shift]+[F5]

Reverse step over [Shift]+[F6]

Step into [F5]

Step over [F6]

Step back [F7]

Uncall [Shift]+[F7]

Resume [F8]

5.3 WeblinksE2 Lite, https://www.renesas.com/en-us/products/software-tools/tools/ emulator/e2-emulator-lite.html

e2 Studio, https://www.renesas.com/en-us/products/software-tools/tools/ide/e2studio.html

Revelation Kit, www.renesas.com/revelation

Renesas Flash Programmer (RFP), www.renesas.com/en-eu/products/software-tools/tools/programmer/renesas-flash-programmer-programming-gui.html

RX71M, https://www.renesas.com/en-us/products/microcontrollers-microprocessors/rx/rx700/rx71m.html

Page 100: Quick start guide for the Renesas RX71M Revelation Kit · PDF file7 1. RX71M Revelation Board 1.1 Overview of the board The RX71M Revelation Board provides several switches, LEDs and

ISBN 978-3-645-20526-9

Markus Stäuble / Bernd Westhoff / Christian Immler

The concise introduction to the world of powerful RX71M 32-bit microcontrollers by Renesas.

Content summery:

• Overview of the RX71M and the Revelation Kit

• Installing e2 studio

• Source text editor, perspectives and views

• Configuring and using the debugger

• Peripheral Code Generator

• Firmware Integration Technology (FIT)

• Combined use of PeripheralCode Generator and FIT

• Using Compare Match Timerfor interrupts

• Reading a temperature sensor

• Writing data to Flash memory

• Viewing the contents of theFlash memory at the PC via USB

• Using Renesas Flash Programmer (RFP)

Renesas RX71M Revelation Kit

Quick start guide for the

With the purchase of the Revelation Kit, you have decided on a powerful development board based on the 32-bit RX71M microcontroller by Renesas.This book shows you how to install the development environment e2 studio and explains the most impor-tant parts of its user interface. In a dedicated chap-ter, you will learn how to use e2 studio together withthe integrated E2 Lite debugger.

In the course of this book, you implement three projectsstep by step. You will especially like the fact that youdo not have to program the basic setting of the micro-controller manually. In the Peripheral Code Generatoryou can set the desired options, and then the sourcecode is generated based on your choices. In the firstproject, you let two on-board LEDs flash alternately.However, with more complex projects, you cannotavoid to write some code yourself. To facilitate thework, the Firmware Integration Technology (FIT) provides various libraries. In the second project, youthus use FIT to let the two LEDs flash alternately. Afterthat, you use the embedded ADC to read the tempera-ture of an integrated sensor. You also write this valueinto a file in the embedded Flash memory and transferthe file via a USB connection at the CN3 port to yourPC, where you can view it. The projects are available fordownload and are thus an ideal starting point for yourown projects.