Configuring and Using the UART Interface on the DK-S124

Created by Austin Oltmanns, last modified on Jun 06, 2017

Welcome, this is the second guide on using the DK-S124 available from Digi-Key at This guide will cover identifying the pins/ports on the development board to use, setting the proper switch configuration, creating a new project in e2 studio, using the Synergy Software Package for setting up UART and sending/receiving data over UART. This guide assumes you have a working development environment set up (such as the one configured in the previous guide, ), a DK-S124 to run the code on and also a way to send and receive serial data. For sending and receiving serial data, this guide will be using PuTTY, a free program for Windows available here: PuTTY: a free SSH and Telnet client and a USB to Serial adapter, like this one DA-70156 Assmann WSW Components | Computer Equipment | DigiKey.

Like the previous guide, this one aims to be a standalone document. However, attached below is some useful reference material if you feel that something is missing.

Dev-Board User’s Manual:

S124 Data Sheet:

S124 User’s Manual:

Synergy Software Package User’s Manual:

Identifying the Ports

On page 26 of the Dev-Board User’s Manual, Table 8 shows the pin-out of the serial communications screw-terminal-block header. Note that pin 1 starts towards the headphone jack and pin 8 is towards the barrel jack. Also note that even though channel 1 and 2 are connected to the Serial circuit from the green screw block, only channel 1 is passed to the S124. That means this guide will be using pins 4, 5 and 7 of the green block. For the DB9 Serial connector, pins 2, 3 and 5 will be used. Note that Tx and Rx must be crossed between the two devices, i.e. Rx of the DK-S124 goes to Tx of the serial connection and vice-versa.

Female to Male jumper cables work well for connecting the two devices. A DB9 breakout and some soldered wire could also be used. Both are available for purchase from Digi-Key.

Male/Female Jumpers: 825 Adafruit Industries LLC | Prototyping, Fabrication Products | DigiKey

DB9 breakout: A-DF 09 A/KG-T2S Assmann WSW Components | Connectors, Interconnects | DigiKey

Note that only GND, Rx and Tx are needed for this guide. The other pins on the serial connection are for more complicated flow control methods than what will be used here.

Setting the Switches

The default configuration of the switches should be set up for UART communication. In the event they have been changed, please ensure switch 1 is in the ON position for RS232 mode and switch 4 is in the OFF position for full duplex mode. This will enable bidirectional communications over UART. The positions of switches 2 and 3 do not matter as they are used for RS485 communication. Please see the above image in “Identifying the Ports” if you have any doubts.

Creating a Project

Launch e2 studio, if you do not have it installed, please refer to the previos guide for the installation of Renesas Synergy Platform. You may already have another project open if you have just completed the Getting Started Guide. Regardless, navigate to File>New>Synergy C Project and click. This guide will use UARTguide as the project name. You should notice that the License area is already filled out if you have your software configured correctly.

Click next. Now you will be asked to choose your device. Ensure that the “Board” field reads
“S124 DK” and that the device matches your chip. This should read “R7FS124773A01CFM”.

Click next. For this guide, the regular BSP project template will be used. If the perspective of e2 studio is not to your likeing, you may of course change it by using the perspective switcher in the top right corner of the editor or through Window>Perspective>Open Perspective> Other… This guide will be using the C/C++ perspective.

Using the Synergy Software Package

Renesas has gone to great lengths to abstract away details like manually setting register values. This can greatly reduce development time, as developers don’t need to spend hours pouring through multiple, 1000+ page datasheets looking for which bit to flip. Because of these efforts, configuring the UART module can be done with a few clicks and sending data over UART can be done in one line.
After your new project has loaded, double click “configuration.xml” in root of the project structure. This will open the project configuration page if it is not already open.

From the project configuration page, click on the tab at the bottom that reads “Threads”. Click the new thread icon in the upper left corner of the “Threads” area. This will create a new thread called “New Thread”.

You may rename the thread by clicking the “properties” tab and editing the field named “Name”. You may also want to change the symbol to something useful as well.

Next, a “stack” needs added to the UARTThread in order to use the UART peripheral. To do this, press the “add stack” icon in the upper right corner of the Stacks area. Navigate to Driver > Connectivity > UART Driver on r_sci_uart.

Notice that immediately the name of the stack appears in red. This is because it still needs configured. To configure the stack, scroll down the properties of the stack until you reach the Interrupt Priority fields. These need configured as well as the “Name of UART callback…” field.

For this simple example, the user defined uart callback can be set to NULL, as it won’t be used. Additionally, the interrupt priorities can be set to anything as long as its 0, 1 or 2. The other priorities are only valid for a different architecture (this board is a ARM Cortex M0+) and applications not using Renesas’s ThreadX platform. In the end, your properties should look like this:

Also note that for this guide, a baud of 9600 with 8 data bits, no parity and 1 stop bit will be used. You may use a different setup, but remember to configure your serial communications setup in kind.
After you have added your properties, press Generate Project Content in the upper right corner of the Threads area. This will configure your project to use the settings you have just added.

You should now have a new source file, named like what was entered into the symbol field earlier. Double click it to open it in the editor.

We will now use the Renesas API to use the UART module, it can be found in 7.32 of the Synergy Software Package User’s Manual if you would like the full API.
To quickly test the UART setup, only 3 lines of code are needed. The commented code is attached below.

#include "uartthread.h"
/* UARTThread entry function */
void uartthread_entry(void)
    uint8_t cstr[] = "Hello! "; //the text to be sent, stored as unsigned 8 bit data.
    g_uart0.p_api->open(g_uart0.p_ctrl, g_uart0.p_cfg); //initialization of the UART module
    //g_uart0 comes from the configuration, p_api is the pointer to the API structure for this device
    //p_crtl is the "control structure" part of the abstraction layers Renesas has set up
    //p_cfg is the configuration structure
    while (1)
        g_uart0.p_api->write(g_uart0.p_ctrl, cstr, 7);
        //write takes 3 arguments: the control structure of the device,
        // a pointer to the first character to write,
        // and the number of characters to write.
        tx_thread_sleep (1); //need to let this thread sleep so the other threads can function
        //(not really an issue for this simple application)

After the code has been copied in, press the hammer icon to watch it build. If everthing has been entered correcty, the project should build after a short time. If there are errors or warnings, be sure to double check that everything has been entered correctly. Once the project builds, it is time to upload it to the board. Plug your board into the computer using the USB A to USB micro cable, making sure to use the debugging port on the side of the board next to the battery holder and not the one at the top of the board next to the screw terminal block.
Next, PuTTY will be set up to show the serial communications.

Sending and Receiving Data using PuTTY

(available here: PuTTY: a free SSH and Telnet client)

To download PuTTY, click the above link and click the link labeled “Download it here”. You may use the installer or simply download putty.exe as it will be the only tool needed.
Once downloaded/installed, launch PuTTY and you will see a screen like this:


A “Serial” connection will be used.


It is also necessary to check the options in the “Serial” section. Make sure “Flow Control” is set to none, as no flow control has been implemented in this simple application.


Now, you must find which COM device to use. This will depend on how you have configured your serial device. It can be checked by opening Windows Device Manager. You should be able to open it by clicking the Windows Start button and typing “Device Manager”. Scroll to where it says “Ports (COM & LPT)”. You should see your serial device here. In this case, a USB to Serial device has enumerated as COM4. Windows should automatically install drivers for most USB to Serial devices. However, if your device does not install, look at the manufacturers page for instructions/drivers.

Change the COM device in putty as needed and press “Open” at the bottom. You should have a blank terminal starting at you, waiting to receive data from the serial line. Press the debug icon in e2 studio now to upload the new program to the board. If you are lucky, you will not receive the spooky error from before.

The error text reads:

Error in final launch sequence
  Failed to execute MI command:
target extended-remote localhost:61234
Error message from debugger back end:
localhost:61234: The system tried to join a drive to a directory on a joined drive.
    Failed to execute MI command:
target extended-remote localhost:61234
Error message from debugger back end:
localhost:61234: The system tried to join a drive to a directory on a joined drive.
    localhost:61234: The system tried to join a drive to a directory on a joined drive.

If you are less fortunate, you may try the ritual of closing and opening e2 studio, making new debug configurations with the same settings and maybe even restarting your computer.

Once you are past the spooky error, or maybe you were lucky and didn’t get it, you should have an open PuTTY session, e2 studio should have started the debugger and the program should be halted at main on your board. Press “Resume” in e2 studio to continue execution of your program, you may need to press it twice to get through all the breakpoints that are set.

Congratulations! you have now sent data over UART using the Renesas DK-S124. The Renesas Synergy Software Platform makes it easy to get up and running with development. On most other platforms, this same example would have required the manual setting of several registers cross referenced with a few datasheets and user manuals just to set it up. Renesas has reduced this to one main user manual (the Synergy Software Platform User’s Manual, linked above) and a simple configurator. With a few clicks and 3 lines of code it was possible to initialize the UART and start sending data.


Any questions or comments please go to Digi-Key’s TechForum