Synergy Software Package User's Manual
Tutorial: Your First Synergy Project - Blinky

Tutorial Blinky

The goal of this tutorial is to quickly get acquainted with the Synergy Platform by moving through the steps of creating a simple application using e2 studio and running that application on a Synergy board.

What Does Blinky Do?

The application used in this tutorial is Blinky, traditionally the first program run in a new embedded development environment.

Blinky is the “Hello World” of microcontrollers. If the LED blinks you know that:

  • The toolchain is setup correctly and builds a working executable image for your chip.
  • The debugger has installed with working drivers and is properly connected to the board.
  • The board is powered up and its jumper and switch settings are probably correct.
  • The microcontroller is alive, the clocks are running, and the memory is initialized.

The Blinky example application used in this tutorial is designed to run the same way on all boards offered by Renesas that hold the Synergy microcontroller. The code in Blinky is completely board independent. It does the work by calling into the BSP (board support package) for the particular board it is running on. This works because:

  • Every board has at least one LED connected to a GPIO pin.
  • That one LED is always labeled LED1 on the silk screen.
  • Every BSP supports an API that returns a list of LEDs on a board, and their port and pin assignments.

Prerequisites

To follow this tutorial, you need:

  • Windows based PC
  • e2 studio
  • Synergy Software Package
  • A Synergy board kit

Create a New Project for Blinky

The creation and configuration of a Synergy project is the first step in the creation of an application. The base SSP pack includes a pre-written Blinky example application that is simple and works on all Renesas Synergy boards.

Note
The e2 studio screens shown in this manual are examples. Some details may differ between different releases of the e2 studio ISDE and the SSP.

Follow these steps to create a Synergy project:

  1. In e2 studio ISDE, click File > New > Synergy C/C++ Project, select Renesas Synergy C Executable Project, and click Next.
  2. Assign a name to this new project. Blinky is a good name to use for this tutorial.
  3. Click Next. The Project Configuration window shows your selection.

    figure-tutorial-blinky-image1.png
    e2 studio ISDE Project Configuration Window (Part 1)
  4. Select the board support package by selecting the name of your board from the Device Selection drop-down list and click Next.

    figure-tutorial-blinky-image2.png
    e2 studio ISDE Project Configuration Window (Part 2)
  5. Select the Blinky template for your board and click Finish.
    figure-tutorial-blinky-image3.png
    e2 studio ISDE Project Configuration Window (Part 3)
    Once the project has been created, the name of the project will show up in the Project Explorer window of the ISDE. Now press the Generate Project Content button in the top right corner of the Project Configuration window to generate your board specific files.
figure-tutorial-blinky-image4.png
e2 studio ISDE Project Configuration Tab

Your new project is now created, configured, and ready to build.

Details about the Blinky Configuration

The Generate Project Content button creates configuration header files, copies source files from templates, and generally configures the project based on the state of the Project Configuration screen.

For example, if you check a box next to a module in the Components tab and press the Generate Project Content button all the files necessary for the inclusion of that module into the project will be copied or created. If that same check box is then unchecked those files will be deleted.

Configuring the Blinky Clocks

By selecting the Blinky template, the clocks are configured by the ISDE for the Blinky application. The ISDE clock configuration tab (see Configuring Clocks) shows the Blinky clock configuration. The Blinky clock configuration is stored in the BSP clock configuration file (see BSP Clock Configuration).

Configuring the Blinky Pins

By selecting the Blinky template, the GPIO pins used to toggle the LED1 are configured by the ISDE for the Blinky application. The ISDE pin configuration tab shows the pin configuration for the Blinky application (see Configuring Pins). The Blinky pin configuration is stored in the BSP configuration file (see BSP Pin Configuration).

Configuring the Parameters for Blinky Components

The Blinky project automatically selects the following HAL components in the ISDE Component:

  • r_cgc
  • r_elc
  • r_fmi
  • r_ioport

To see the configuration parameters for any of the components, check the Properties tab in the HAL window for the respective driver (see Adding and Configuring HAL Drivers).

Where is main()?

The main function is located in < project >/src/synergy_gen/main.c. It is one of the files that are generated during the project creation stage and only contains a call to hal_entry(). For more information on generated files Adding and Configuring HAL Drivers .

Blinky Example Code

The blinky application is stored in the hal_entry.c file. This file is generated by the ISDE when you select the Blinky Project template and is located in the project's src/ folder.

The application performs the following steps:

  1. Get the LED information for the selected board by calling the BSP HAL function R_BSP_LedsGet().
  2. Define the output level HIGH for the GPIO pins controlling the LEDs for the selected board.
  3. Get the selected system clock speed and scale down the clock, so the LED toggling can be observed.
  4. Toggle the LED by writing to the GPIO pin with
    g_ioport.p_api->pinWrite()

Build the Blinky Project

Highlight your new project in the Project Explorer window and build it.

There are three ways to build a project:

a. Click on Project in the menu bar and select Build Project.

b. Click on the hammer icon.

c. Right-click on the project and select Build Project.

figure-tutorial-blinky-image5.png
e2 studio ISDE Project Explorer Window

Once the build is complete a message is displayed in the build Console window that displays the final image file name and section sizes in that image.

figure-tutorial-blinky-image6.png
e2 studio ISDE Project Build Console

Debug the Blinky Project

Debug prerequisites

To debug the project on a board, you need:

  • The board to be connected to the ISDE
  • The debugger to be configured to talk to the board
  • The application to be programmed to the microcontroller

Applications run from the internal flash of your microcontroller. To run or debug the application, the application must first be programmed to the microcontroller’s flash. There are two ways to do this:

  • JTAG debugger
  • Built-in boot-loader via UART or USB

Some boards have an on-board JTAG debugger and others require an external JTAG debugger connected to a header on the board.

Refer to your board’s user manual to learn how to connect the JTAG debugger to your ISDE.

Debug steps

To debug the Blinky application, follow these steps:

  1. Configure the debugger for your project by clicking Run > Debugger Configurations ...

    figure-tutorial-blinky-image7.png
    e2 studio ISDE Debug Icon

    … or by selecting the drop-down menu next to the bug icon and selecting Debugger Configurations ...

    figure-tutorial-blinky-image8.png
    e2 studio ISDE Debugger Configurations Window
  2. Select your debugger configuration in the window. If it is not visible then it must be created by clicking the New icon in the top left corner of the window. Once selected, the Debug Configuration window displays the Debug configuration for your Blinky project.
    figure-tutorial-blinky-image9.png
    e2 studio ISDE Debugger Configurations Window with Blinky Project
  3. Press Debug to begin debugging the application.

Details about the Debug Process

In debug mode, the ISDE executes the following tasks:

  1. Downloading the application image to the microcontroller and programming the image to the internal flash memory.
  2. Setting a breakpoint at main().
  3. Setting the stack pointer register to the stack.
  4. Loading the program counter register with the address of the reset vector.
  5. Displaying the startup code where the program counter points to.
figure-tutorial-blinky-image10.png
e2 studio ISDE Debugger Memory Window

Run the Blinky Project

While in Debug mode, click Run > Resume or click on the Play icon twice.

figure-tutorial-blinky-image11.png
e2 studio ISDE Debugger Play Icon

The LED on the board marked LED1 should now be blinking.