HowTo: Send Data to PC Using USB/COM on SK-S7G2





While learning or developing new embedded applications for Internet of Things (IoT) devices, many developers need to know how to send out debug or result information to their PC. Often a DISPLAY unit like an LCD panel is either missing or if there is a need for one you end up being required to write a display driver to display anything. Without displaying information it can be a very hard and time consuming process to develop a simple application.

My objective in this tutorial is to show how to configure and write data such as debug lines or any sensor values so on your PC you can clearly see what’s going on.

Another motivation for this tutorial is to create a first “Hello World” application as starting point, just like learning any other new programming language.

Luckily :slight_smile: Renesas Synergy Platform provides very easy to configure and build applications on their boards. You only need to write very few line of code to get going.

What will you learn:

  • You will learn how to redirect your printf() or any text strings (event logs) to your PC using a USB/COM connection.

NOTE: There are other tutorials which cover using UART which require special types of cables like TTL-USB and need a bit more complex configuration than this method.

  • Setting up the receiver on your PC.

What you need:

  • SK-S7G2 Starter Kit.

  • Two USB cables. One cable to power/program the board. The other cable to send data to your PC using the USB port.

  • A Windows PC with serial communication software like Putty or TeraTerm. You can download these software programs by Googling them.

  • SEGGER JLink Driver software.

Step 1: Start E2Studio and choose a workspace you like, for example:

Step 2: Choose project type

Step 3: Name of the Application or Project and Device Selection, SSP version:

**Step 4: We are going to choose Blinky with ThreadX

The Blinky thread will blink the on board LEDs. We will add code to post debug messages to the serial communication data queue.

Now our basic project is ready. You need to add USB communication configuration information and a thread to read the message string from the queue and send that debug message to your PC over the serial port.

Step 5: Select “Threads” Tab on configuration panel

Step 6: Add new Thread, Name and change priority
Follow the step numbers in the screenshot below.

Step 7: Now we need to add the Synergy Communication Framework like below and then add the set of components required for this application

After above you will see this:

Step 8: Select USBX Device Configuration
Change the property “Class Code” to “Miscellaneous.” In the screenshot below, this is Labels 1 and 2.
You need to add USBX Port DCD (Label 3)

Step 9: Now we need to fix the USBX port DCD property called "Full Speed Interrupt Priority." I have chosen Priority 10 as an example.

Now all the required frameworks have been added to the configurator. Next we will add queue to post the debug message string.

The Blinky thread will post an event/debug string to the queue and the USB console thread will get that string and write it to the serial port.

Step 10: Add Queue

  • Select the USB Serial Port Thread.
  • Add Queue * Change Queue property Name: CDC Queue, Symbol g_cdc_queue, Message size 10 (80 Bytes) Queue Size 80 (bytes).

At this point, you are now done with all the needed configuration!

Step 11: Generate Project Content

Next you will need to type few lines of code for both thread entry functions.


NOTE: You can copy and paste the code snippets below directly into your own project or application or you can download this project and follow the Synergy Platform Import Guidelines.

Entire project and source can be downloaded here (1.2 MB)

From github

Step 12: Open blinky_thread_entry.c

Declare this just above the _void blinky_thread_entry(void) line

 extern TX_QUEUE g_cdc_queue;

Copy and past the code snippet here to replace the existing While (1) Loop

char send_str[80];  //to store debug strings
sprintf(send_str, "Welcome to SKS7G2");
tx_queue_send(&g_cdc_queue, send_str, TX_WAIT_FOREVER);

uint32_t counter = 0;

while (1) {
    /* Determine the next state of the LEDs */
    if(IOPORT_LEVEL_LOW == level) {
        level = IOPORT_LEVEL_HIGH;
        sprintf(send_str, "LED LEVEL HIGH %d\r",counter );
    }   else  {
        level = IOPORT_LEVEL_LOW;
        sprintf(send_str, "LED LEVEL LOW %d\r", counter);
    ++counter ;

    /* Update all board LEDs */
    for(uint32_t i = 0; i < leds.led_count; i++)   {
        g_ioport.p_api->pinWrite(leds.p_leds[i], level);

   //TX_WAIT_FOREVER : This will block Blinky Thread until PC receive message.
    tx_queue_send(&g_cdc_queue, send_str, delay);  // TX_WAIT_FOREVER);

    /* Delay */
    tx_thread_sleep (delay);

Step 13: Copy the code snippet here to usb_console_thread_entry() Function

 void usb_console_thread_entry(void)
      char rx_msg[80];
      while (1)  {
           //get debug string from Queue
           tx_queue_receive(&g_cdc_queue, rx_msg, TX_WAIT_FOREVER);

           //Write debug String to USB device framework.
           g_sf_comms0.p_api->write(g_sf_comms0.p_ctrl, rx_msg, strlen(rx_msg), TX_WAIT_FOREVER);
           tx_thread_sleep (1);
      } //END OF WHILE


If your application needs something like printf("%2.2f", temperature) or sprintf("%2.4f", temperature) or display on GUIX floating point numbers then compiler setting should be updated with “float with nono printf”.

Right click on your Project then Select “Renesas Tools and Settings” or press ALT + T to make the following changes:


You are done with SKS7 application side. Now you’ll build the application and flash the program into the SK-S7G2 board.

The SKS7G2 board comes with two micro USB ports. One is for JTAG Debug. Connect the USB cable between your PC’s standard USB port and the micro USB on SKS7G2 board. See the picture below for clarification.

Receiving console output thru COM Port on PC:

This section explains how to receive message strings from the SKS7G2 board over the USB/COM port.

Step1: Your application should be running on the SKS7G2 board. Otherwise the device COM port won’t show up in the PC Device Manager list.

Step 2: On you PC, Right click on the Windows Start Button to open the Device Manager Panel. We need to know to which COM port the SKS7G2 board is connected.

See the screenshot for reference:

NOTE: Some PC COM port numbers may vary. On my system COM6 is assigned to my board. We need this PORT information to receive the information from board.

NOTE 2: If your board does not show up in Windows Device Manager or you get a driver error, please follow these steps:™_Platform/Renesas_Synergy_Knowledge_Base/Installing_USB_CDC_Driver_on_Windows_10

Step 3: Download one of the applications. I am providing screenshots of both applications. If you have already one of these just choose which ever one you prefer and ignore this download step.

For Putty (SSH client) My preference is Putty which displays fonts better than TeraTerm.

For TeraTerm :

Step 4: Start the application

For Putty configuration follow these 3 steps:

To print each write in a newline in the terminal window, follow these settings when you configure Putty. Otherwise only the last received message will be displayed in your terminal window.

You can see that whatever current debug string has been written from the SKS7G2 USB console thread now appears in your PC Terminal window.

For TerTerm Configuration:

:smiley: :wine_glass:

Any Comments/Suggestions/Successes/Failures relating to this tutorial are greatly appreciated. It will be extremely helpful for my next tutorial.


HowTo: Generate Pulse Width Modulation (PWM) signals on S7G2