Updated 4 LED Blinky on S3A7 Fast Prototyping Board

s3a7

#1

In this tutorial, you will build a simple application from scratch that blinks all 4 LEDs on the S3A7 fast prototyping board. This tutorial extends the earlier S3A7 tutorial located here: Blinky on the S3A7 IoT Fast Prototyping Kit. In this case, we use the board support package for the fast prototyping board rather than forcing another bsp to work.

Prerequisites:

  1. S3A7 IoT Fast Prototyping Kit including the J-Link debugger
  2. Renesas e2 studio - latest version is 5.4.0.015 as of 5/25/2017
  3. Renesas Synergy Software Package SSP v 1.1.3 (not the latest, but required for this board)
  4. Segger J-Flash Lite 6.14a or later (older versions probably work, too)

Step 1)
Follow the “Building Smart Chef Demo from Source” tutorial far enough to put the downloaded pack file, user.s3_iot_lcd_dev.1.1.3.pack in the correct directory. Without this step, you won’t have the board support package (bsp) you need to create this application.

Step 2)
Open e2 Studio in a new blank workspace

Step 3)
Select ‘New – Synergy C Project’

Step 4)
Make sure to point to the synergy license location (default shown)

Step 5)
Select Synergy 1.1.3 (that is the version the BSP used). Select the correct board (highlighted).

Step 6)
Select the project template for our board.

Step 7)
Open the Synergy perspective.

Step 8)
Generate content (sanity check – there is no content yet). We are just making sure that everything is configured properly so far.

Step 9)
Build empty project from C/C++ perspective (also a sanity check to make sure you have configured everything correctly).

Step 10)
Configure the 4 GPIO pins which will drive the 4 LEDs. The 4 LEDs on the fast prototyping board are connected to port 7 pins 0-3. These 4 pins must be configured as GPIO outputs. The two screen shots below show you how to do this from within the synergy perspective.

Step 11}
Press ‘Generate Project Content’ again to auto-generate code which implements the changes you just made to the GPIO pins.

Step 12)
Open the file ‘hal_entry.c’. This is where custom application code goes. It is not reset every time the ‘Generate Project Content’ is clicked.

Step 13)
Paste in the blinky code below:

/* HAL-only entry function */
#include "hal_data.h"
void hal_entry(void)
{
    bool OnOff = true;
    bool OffOn = false;
    while(true)
    {
        g_ioport.p_api->pinWrite(IOPORT_PORT_07_PIN_00, OnOff);
        g_ioport.p_api->pinWrite(IOPORT_PORT_07_PIN_01, OffOn);
        g_ioport.p_api->pinWrite(IOPORT_PORT_07_PIN_02, OnOff);
        g_ioport.p_api->pinWrite(IOPORT_PORT_07_PIN_03, OffOn);

        OnOff = !OnOff; //toggle
        OffOn = !OffOn; //toggle

        for (int i = 0; i < 2.2E5; i++)
        {
            //Do Nothing
            //Clock is 48MHz
            //Counting to 220,000 results in a frequency of roughly 1Hz
            //Next step is to use timer module to control this precisely
        }
    }
}

Step 14)
Build the project again. There should be no errors or warnings. Next, locate the .srec file. You will need to point the Segger J-Link Lite software to that file in order to flash the board with this new project.

Step 15)
Flash the board by pointing to the file above with the J-Link software. The correct settings are shown below:

Here is a J-Link tutorial in case you haven’t done this before:
http://renesas-blog.mediumone.com/how-to-flash-the-s3a7-board/

Finished!
After flashing the board and resetting it, the LEDs should now flash 2 at a time at roughly 1Hz.

Next Steps:
A more sophisticated version of this would use the S3A7 timers to accurately set the frequency. I’ll work on that version next.


Blinky with Timers and Interrupts on the S3A7
Learn IoT MeetUp - June 5 in San Jose
Learn IoT MeetUp - June 5 in San Jose
Blinky on the S3A7 IoT Fast Prototyping Kit
#2

Here is a link to the version that uses timers. Dan


#3

Awesome tutorial summary. I want to contribute how to step through the code in the debug mode while the code is running on the board. So, the value of the variable can be examined.

Setup: Make sure that you connect the J-Link debugger to your Windows or Mac computer and connect the debugger to the S3A7 Fast Prototyping board. Power up the board.

Step 1: Enter into the debug mode. Click on the folder for the pop up menu. Select Renesas GDB Hardware Debugging.

Step 2: Add variable i and isOn to watch. Just type the variables into the fields under Expression. Use your mouse to click the blue bar next to the code line for your break point. Press Resume (F8).

Michael


#4

The debugging feature of e2 studio will replace step 15 in Dan’s tutorial. e2 studio will upload the code into the board for you. You would not need to use J-Flash Lite software to program the device.

Best regards,
Michael


#5

Michael,

This is a cool observation. I haven’t used e2 Studio to flash boards. I will try this.

Jesse