Skip to content

How to create RL78 FreeRTOS with Smart Configurator

Shunichiro Nakamura edited this page Jul 13, 2026 · 25 revisions

Renesas/FreeRTOS-Kernel wiki


How to create projects for a microcontroller supported by the Smart Configurator

The procedure for creating a FreeRTOS project for an RL78 microcontroller supported by the Smart Configurator is described on this page.

Environment for the Procedure

In the procedure for creation, a project for the following environment is given as an example.

Development Environment

Item Tool Name (Version)
Board RL78/G24 Fast Prototyping Board
IDE e2 studio (2026-04.2)
Compiler CC-RL (V1.16.00)
Hardware debug configuration COM port

Operating Environment

Item Specifications
Main system clock
  • High-speed on-chip oscillator
  • Frequency: 48 MHz
FreeRTOS V11.1.0
(Can be obtained from Blinky Demo (R20AN0819EJ0100))
System timer
  • 32-bit interval timer (TML32)
    • 16-bit counter mode
    • Clock source: fIHP 48 MHz
  • RTOS tick frequency: 1 tick/ms
FreeRTOS memory allocation implementation heap_4
User application
  • The Blinky Demo is in use
    • LED1 blinks on and off at 1-second intervals
    • LED2 blinks on and off at 2-second intervals

✅ Note:

  • A demonstration program, the Blinky Demo, includes FreeRTOS which includes the portable layer for CC-RL. Download this before creating a project.
  • The items of the operating environment, which are not referred to in the above table, conform with the specifications of the Blinky Demo.
  • Customize the operating environment to suit the requirements of the user system.
  • For details on the RL78/G24 microcontroller or peripheral functions, refer to the RL78/G24 User’s Manual: Hardware.

Creation Procedure

  1. Creating a bare-metal project

    1. After invoking e2 studio, select File menu - New - Renesas C/C++ Project - Renesas RL78 to open the wizard for creating a new project.

    2. Select Renesas CC-RL C/C++ Executable Project, enter the project name in <Project name>, and select RL78G24_FastPrototypingBoard for Target Board (and Target Device to be used).
      After that, click on Next.

    3. Select the Use Smart Configurator checkbox, select the Bare Metal - Minimal checkbox, and click on Finish.

    4. Change the C language standard to C99.
      Right-click on <project name> in Project Explorer, select Properties - C/C++ Build - Settings then, on the Tool Settings tabbed page, select Compiler - Source - Language, and select C99 language standard for Language standard of C language.

  2. Adding FreeRTOS

    1. Add the FreeRTOS kernel for the CC-RL to the bare-metal project of the user.
      Copy the directory of the kernel of the FreeRTOS supplied with the Blinky Demo to the project.

      • From [Blinky Demo]: r20an0819xx0100-rl78/RL78/rl78g23_fpb_blinky/src/kernel
      • To [User project]: <project name>/src/kernel
    2. Exclude the examples of FreeRTOS from the targets for building.
      Right-click on the <project name>/src/kernel/examples folder in Project Explorer and select Properties - C/C++ Build - Settings, then select the Exclude resource from build checkbox.

    3. Set the include path of the common part of FreeRTOS.
      Right-click on <project name> in Project Explorer, select Properties - C/C++ Build - Settings then, on the Tool Settings tabbed page, select Compiler - Source, and add the following file path to Include file directories.

      • "${workspace_loc:/${ProjName}/src/kernel/include}"
  3. Setting the portable layer of FreeRTOS

    1. Set the portable layer for the CC-RL compiler and the memory management function as the targets for building.

      1. Start by setting portable layer as non-targets for building to simplify operations.
        Right-click on the <project name>/src/kernel/portable folder in Project Explorer and select Properties - C/C++ Build - Settings, then select the Exclude resource from build checkbox.

      2. Return the portable layer for the CC-RL compiler back as a target for building.
        Right-click on the <project name>/src/kernel/portable/Renesas/RL78 folder in Project Explorer and select Properties - C/C++ Build - Settings, then deselect the Exclude resource from build checkbox.

      3. Return the memory management function (heap_4.c) back as a target for building.
        Right-click on the <project name>/src/kernel/portable/MemMang folder in Project Explorer and select Properties - C/C++ Build - Settings, then deselect the Exclude resource from build checkbox.
        Next, right-click on the following files under the <project name>/src/kernel/portable/MemMang folder and select the Properties - C/C++ Build - Settings, then select the Exclude resource from build checkbox.

        • heap_1.c
        • heap_2.c
        • heap_3.c
        • heap_5.c

        ✅ Note:
        Since the operation of excluding targets from building cannot be performed for multiple files at the same time, files must be excluded from building one at a time.

      4. If the settings have been made correctly, the portable layer settings in Project Explorer will become as follows:

    2. Set the include path of the portable layer for the CC-RL compiler.
      Right-click on <project name> in Project Explorer, select Properties - C/C++ Build - Settings then, on the Tool Settings tabbed page, select Compiler - Source, and add the following file path to Include file directories.

      • "${workspace_loc:/${ProjName}/src/kernel/portable/Renesas/RL78}"
    3. Check the interrupt handler of the software interrupt (vector interrupt that is generated by executing a BRK instruction).
      Confirm that the vector table number of _vPortYield in <project name>/src/kernel/portable/Renesas/RL78/portasm.asm is 0x7E. (Since the vector table number of the software interrupt is 0x7E in both the RL78/G23 and RL78/G24, if portasm.asm is the file copied from the Blinky Demo, no changes are required.)

      ;   /* brk */
          _vPortYield     .VECTOR 0x7E

      ✅ Note:
      When using another microcontroller, check the vector table number of the software interrupt in the hardware manual and change it as required.

  4. Setting the system timer

    For the specifications of the system timer given as examples in this procedure, see the operating environment.

    1. Using the Smart Configurator, set up the hardware related to the setting of the system timer in advance.

      ✅ Note:
      Although setting up hardware is properly a procedure that should be performed independently of the setting of the system timer, it is explained here as part of the setting of the system timer for convenience.

      1. Open the Smart Configurator (double-click on <project name>.scfg in Project Explorer).

      2. Set the clock source of the peripheral timer used for the system timer.
        Open the Clocks tabbed page of the Smart Configurator and set the frequency of the main system clock or the clock provided to the peripheral timer and related items. Specifically, set the Frequency of the High-speed on-chip oscillator to 48 MHz, and set fIHP to 48 MHz.

    2. Using the Smart Configurator, install the driver of the peripheral timer used for the system timer.

      1. On the Components tabbed page of the Smart Configurator, click on Add component to open the Software Component Selection window.

      2. Select Interval Timer as the component type and click on Next.

      3. Select 16 bit count mode for Operation and ITL000_ITL001 for Resource, then click on Finish.

      4. Select ITL000_ITL001 (visible in the left pane on the Components tabbed page) that was selected earlier, set fIHP for the Operation clock (fITL0) and fITL0 for the Clock source, and then set 1 ms for the Interval value.

        ✅ Note:
        When using a different RTOS tick frequency, adjust the interval value according to the RTOS tick frequency.

    3. Check the interrupt handler for the system timer.
      Confirm that the vector table number of _vPortTickISR in <project name>/src/kernel/portable/Renesas/RL78/portasm.asm is 0x38. (Since the vector table number of the interrupt of the system timer (ITL000_ITL001) used in the operating environment is 0x38, if portasm.asm is the file copied from the Blinky Demo, no changes are required.)

      ;   /* 32bit interval timer */
          _vPortTickISR   .VECTOR 0x38

      ✅ Note:
      When using another microcontroller or peripheral timer, check the vector table number of the interrupt of the peripheral timer in the hardware manual and change it as required.

    4. Exclude the default interrupt handler generated by the Smart Configurator from the targets for building.

      1. Open the Smart Configurator (double-click on <project name>.scfg in Project Explorer) and click on Generate Code. This operation automatically generates the default interrupt handler.

      2. Right-click on the <project name>/src/smc_gen/general/r_cg_itl_common_user.c file in Project Explorer and select Properties - C/C++ Build - Settings, then select the Exclude resource from build checkbox.

        ✅ Note:
        When using another microcontroller or peripheral timer, a different file is used for implementing the default interrupt handler.

  5. Implementing FreeRTOS-related applications

    1. Make FreeRTOS settings.

      1. Copy the directory of the settings of the FreeRTOS supplied with the Blinky Demo to the project.

        • From [Blinky Demo]: r20an0819xx0100-rl78/RL78/rl78g23_fpb_blinky/src/application/config
        • To [User project]: <project name>/src/application/config
      2. Set the include path of the settings of FreeRTOS.
        Right-click on <project name> in Project Explorer, select Properties - C/C++ Build - Settings then, on the Tool Settings tabbed page, select Compiler - Source, and add the following file path to Include file directories.

        • "${workspace_loc:/${ProjName}/src/application/config}"
      3. Adjust the setting macros of src/application/config/FreeRTOSConfig.h to suit the requirements of the user system.
        For details on the setting macros, refer to the official Web page.

        ✅ Note:
        Note the heap size setting (configTOTAL_HEAP_SIZE) that is dependent on the microcontroller used or the user system requirements.

    2. Implement the hook function and kernel startup processing.

      1. Copy the directory of the startup of the FreeRTOS supplied with the Blinky Demo to the project.

        • From [Blinky Demo]: r20an0819xx0100-rl78/RL78/rl78g23_fpb_blinky/src/application/startup
        • To [User project]: <project name>/src/application/startup
      2. Set the include path for the startup of FreeRTOS.
        Right-click on <project name> in Project Explorer, select Properties - C/C++ Build - Settings then, on the Tool Settings tabbed page, select Compiler - Source, and add the following file path to Include file directories.

        • "${workspace_loc:/${ProjName}/src/application/startup}"
      3. Change the hook function file copied from the Blinky Demo (for RL78/G23) to match the operating environment.
        Specifically, change the following two points.

        • vApplicationSetupTimerInterrupt() (in freertos_user.c): Change the code so that R_Config_ITL000_ITL001_Start() is called instead of R_Config_ITL_Start().
        • vApplicationTickHook() (in freertos_start.c): Confirm that ITLS0 = 0U; is implemented in the body of the function. This is for setting the interrupt request signal (INTITL) for each of the timer interrupts to the low level (for details, see the hardware manual).

        ✅ Note:
        When using another microcontroller or peripheral timer, modify the hook function to suit the requirements of the user system.

      4. Implement the kernel startup processing.
        Change main() as follows: after calling Processing_Before_Start_Kernel() in src/application/startup/freertos_user.c, call vTaskStartScheduler(), which starts the scheduler.

        ✅ Note:
        main() is implemented in src/application/app/main.c supplied with the Blinky Demo, and is copied to the project in the "Implementing the user application" procedure described later. Therefore, main() does not yet exist in the project at this point in the procedure.

        ✅ Note:
        Processing_Before_Start_Kernel() is provided for the purpose of generating RTOS objects before the scheduler of the kernel is started. The implementation or calling of this function is arbitrary and can be changed to suit the requirements of the user system.
        Also, Processing_Before_Start_Kernel() copied from the Blinky Demo generates a task with main_task() (implemented in src/application/app/main.c) as the entry function. If you are going to use this without change, add an implementation of main_task() to the user application.

    3. Integrate the code generated by the Code Generator with FreeRTOS.

      1. Open the Smart Configurator (double-click on <project name>.scfg in Project Explorer) and click on Generate Code.

      2. Change the setting of BSP_CFG_RTOS_USED in src/smc_gen/r_config/r_bsp_config.h to 1.

      3. Change the setting of BSP_CFG_ASM_RTOS_USED in src/smc_gen/r_config/r_bsp_config.inc to 1.

  6. Implementing the user application

    1. Copy the directory of the user application supplied with the Blinky Demo to the project.

      • From [Blinky Demo]: r20an0819xx0100-rl78/RL78/rl78g23_fpb_blinky/src/application/app
      • To [User project]: <project name>/src/application/app
    2. Set the include path of the user application.
      Right-click on <project name> in Project Explorer, select Properties - C/C++ Build - Settings then, on the Tool Settings tabbed page, select Compiler - Source, and add the following file path to Include file directories.

      • "${workspace_loc:/${ProjName}/src/application/app}"
    3. Set the LED connection pins (the P62 port pin for LED1 and P63 port pin for LED2) through the Smart Configurator.
      For details on the connection pins, refer to the user’s manual for the board.

      1. Install the driver for the I/O ports.
        On the Components tabbed page of the Smart Configurator, select Add component to open the Software Component Selection window.
        Select Ports as the component type and click on Next. After that, select Port for Resource, then click on Finish.

      2. In the pane for making detailed settings of the Port driver on the Components tabbed page of the Smart Configurator, select the PORT6 checkbox.

      3. Set P62 and P63 on the PORT6 tabbed page to Out.

      4. Click on Generate Code in the Smart Configurator.

    4. Exclude src/<project name>.c from the targets for building. This is to avoid overlapping with main() existing in src/application/app/main.c.
      Right-click on the <project name>/src/<project name>.c file in Project Explorer and select Properties - C/C++ Build - Settings, then select the Exclude resource from build checkbox.

    5. Open the Smart Configurator (double-click on <project name>.scfg in Project Explorer) and click on Generate Code.
      This operation automatically generates the source code for the code (and SIS modules) that were set with the Smart Configurator.

    ✅ Note:
    When implementing an original user application, implement the tasks, peripheral drivers, and interrupt handlers. A peripheral driver made by Renesas can be added through the Smart Configurator.

  7. Debug configurations

    For the specifications of debugging given as examples in this procedure, refer to the development environment.

    1. Connect the board to the debugger. For debugging through a COM port, use a USB-to-serial connection to connect the board to a Windows PC on which the e2 studio has been started.

    2. Select Run menu - Debug Configurations.

    3. Select the debug configuration profile of the project (<project name> HardwareDebug) from the left pane in the pop-up window.

    4. On the Connection Settings tabbed page on the Debugger tabbed page, set the COM port number that is used for connection to the board in COM Port.

    5. After setting the other debug configurations as required, click on Apply to fix the settings.

  8. Building and program execution

    1. Right-click on <project name> in Project Explorer and select Build Project.

    2. After building has finished successfully, start the debugger by selecting Run menu - Debug As - Renesas GDB Hardware Debugging, then execute the program.

    3. Confirm that the program is running normally.
      When the user application of the Blinky Demo is in use, LED1 and LED2 will blink on and off.

Clone this wiki locally