Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


FreeRTOS for Renesas RX113 (RX100)
Supporting GCC, IAR and Renesas compilers
[RTOS Ports]


Renesas RX113 RSK


Introduction

This page documents the RTOS demo applications that targets the Renesas RX113 family of microcontrollers.

Three projects are provided:

  1. An e2studio project that uses the GCC compiler.

  2. An e2studio project that uses the Renesas compiler.

  3. An IAR Embedded Workbench project that uses the IAR compiler.

All three projects include build options that allow the creation of a simple blinky demo or a comprehensive demo, and target the RX113 RSK (Renesas Start Kit) evaluation board. The comprehensive demo includes a command line interface implemented with FreeRTOS+CLI.



IMPORTANT! Notes on using the RX113 RTOS demo projects

Please read all the following points before using this RTOS port.

  1. Source Code Organisation
  2. The Demo Application
  3. RTOS Configuration and Usage Details
See also the FAQ My application does not run, what could be wrong?



Source Code Organisation

The FreeRTOS download contains the source code for all the RTOS ports, so contains lots more files than are required by the RX113 projects. See the Source Code Organization section of this website for more information.

The IAR project is called RTOSDemo.eww, and is located in the /FreeRTOS/Demo/RX100_RX113-RSK_GCC_e2studio_IAR directory.

The e2studio projects have the usual Eclipse project name .project. The project that uses the GCC compiler is also located in the /FreeRTOS/Demo/RX100_RX113-RSK_GCC_e2studio_IAR directory, and the project that uses the Renesas compiler is located in the /FreeRTOS/Demo/RX100_RX113-RSK_Renesas_e2studio directory. These are the directories that must be selected when importing the projects into the e2studio Eclipse workspace.



Building and Running the Renesas RX113 RTOS Demo

The RTOS demo projects can be configured to build either a simple blinky project, or a comprehensive test and demo project. The constant mainCREATE_SIMPLE_BLINKY_DEMO_ONLY, which is defined at the top of main.c, is used to switch between the two. The comprehensive project is created when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0. The simple demo is created when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.

The demos use an LED and the UART to USB converter built onto the RSK development board, so no hardware set up is required.


Building with e2studio (GCC and Renesas compilers)

Note: Some of the C source files built by the e2studio projects are included in the project using a project relative path, so the project will fail to build if the FreeRTOS directory structure has been altered from that provided in the official .zip file download.
  1. Start the e2studio Eclipse IDE, and either create a new or select an existing workspace when prompted.

  2. Select "Import" from the IDE's "File" menu. The dialogue box shown below will appear. Select "General->Existing Project into Workspace", as shown below.

    Importing the RX113 project into the e2studio Eclipse IDE
    The dialogue box that appears when "Import" is first clicked


  3. In the next dialogue box, select /FreeRTOS/Demo/RX100_RX113-RSK_GCC_e2studio_IAR as the root directory if you are using the GCC compiler, or /FreeRTOS/Demo/RX100_RX113-RSK_Renesas_e2studio if you are using the Renesas compiler.


  4. Make sure the RTOSDemo project is checked in the "Projects" area, and that the Copy Projects Into Workspace check box is not checked, before clicking the Finish button (see the image below for the correct check box states).

    Selecting the RTOS source code when importing into Eclipse CDT
    Make sure RTOSDemo is checked, and "Copy projects into workspace" is not checked


  5. Open main.c and locate the mainCREATE_SIMPLE_BLINKY_DEMO_ONLY definition, which is near the top of the file. Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to 1 to build the simply blinky style (starter) project. Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to 0 to build the comprehensive test and demo application.

  6. Select "Build All" from the e2studio Eclipse "Project" menu to build the demo project, and wait for the build to complete.

  7. Ensure the E1 debug adapter (which comes with the RSK starter kit) is connected between the RX113 RSK board and the computer running e2studio. If you configure the launch configurations as per the images below then there is no need for a separate power supply.

  8. Select "Debug Configurations" from the Eclipse "Run" menu to configure a launch configuration that can be used to program the microcontroller flash memory, and start a debug session. Configure the debug launch configuration as shown in the images below.



    Click images to enlarge


Demo Application Functionality

The simply blinky example

The blinky example is built when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1 in main.c. When this is done, main() calls main_blinky():
  • The main_blinky() Function:

    main_blinky() creates an RTOS queue, a queue send task, and a queue receive task, then starts the scheduler.

  • The Queue Send Task:

    The queue send task is implemented by the prvQueueSendTask() function in main_blinky.c.

    prvQueueSendTask() sends the value 100 to the RTOS queue every 200 milliseconds.

  • The Queue Receive Task:

    The queue receive task is implemented by the prvQueueReceiveTask() function in main_blinky.c.

    prvQueueReceiveTask() blocks to wait for data to arrive on the RTOS queue. Each time the value 100 is received from the queue it toggles LED 0. As data is sent to the queue every 200ms, the LED will toggle every 200ms.


The comprehensive test and demo application

RTOS CLI The comprehensive example is created when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0 in main.c. When this is done, main() calls main_full():
  • The main_full() Function:

    main_full() creates a set of standard demo tasks, some application specific test tasks, a command line interface (CLI) task, a pseudo randomiser task, and then starts the scheduler. The pseudo randomiser task is just used to ensure some variation is added to the sequence in which the test tasks execute, and in so doing, improve the test coverage.

  • The command line interface (CLI)

    The CLI is implemented using the FreeRTOS+CLI extensible command line interface, and uses SCI1 at 19200 baud for its input and output. As always with FreeRTOS+CLI, type "help" to see a list of registered commands.

  • The "Reg Test" Tasks:

    The reg test tasks test the context switching mechanism by filling each MCU register with a known value, then continuously checking that each register maintains its expected value for the lifetime of the task.

  • The "Check" Task:

    The "Check" task monitors the status of all the other tasks in the system, looking for a task either stalling, or reporting an error. It toggles LED 0 each time it iterates around its implementing loop.

    If the LED is toggling every three seconds then the check task has not detected any stalled tasks, or detected any errors. If the LED is toggling every 200ms then at least one error has been found.



RTOS Configuration and Usage Details


RX113 RTOS port specific configuration

Configuration items specific to this demo are contained in /FreeRTOS/Demo/RX100_RX113-RSK_GCC_e2studio_IAR/src/FreeRTOSConfig.h for the IAR and GCC projects, and /FreeRTOS/Demo/RX100_RX113-RSK_Renesas_e2studio/src/FreeRTOSConfig.h for the Renesas compiler project. The constants defined in these files can be edited to suit your application. In particular -
  • configTICK_RATE_HZ

    This sets the frequency of the RTOS tick. The supplied value of 1KHz is useful for testing the RTOS kernel functionality but is faster than most applications need. Lowering this frequency will improve efficiency.

  • configKERNEL_INTERRUPT_PRIORITY

    This defines the interrupt priority used by the RTOS kernel for the RTOS tick timer and software interrupts. This should always be set to the lowest interrupt priority, which is 1 for the RX113. See the configuration pages for more information.

  • configMAX_SYSCALL_INTERRUPT_PRIORITY

    This defines the maximum interrupt priority from which RTOS API functions can be called. Interrupts at or below this priority can call FreeRTOS API functions provided that the API function ends in 'FromISR'. Interrupts above this priority cannot call any FreeRTOS API functions but will not be effected by anything the RTOS kernel is doing. This makes them suitable for functionality that requires very high temporal accuracy (motor control for example).

The RX100 port layer #defines 'BaseType_t' to 'long'.


Writing interrupt service routines (ISRs)

Interrupts can be written using the standard compiler syntax. Examples for all three supported compilers are provided below.

Often an ISR wants to cause a context switch so the task that is returned to when the ISR completes is different to the task that the ISR originally interrupted. This would be the case if the ISR caused a task to unblock, and the unblocked task had a priority above that of the task that was already in the Running state. This can be achieved by calling portYIELD_FROM_ISR(), which takes a single parameter. The parameter must be 0 if a context switch is not required, or non-zero if a context switch is required. portYIELD_FROM_ISR() is used in the examples below.

/* Pragma used to install the interrupt.  The 'enable' used in the pragma
tells the compiler to enable interrupts before executing the user code. */
#pragma interrupt ( Excep_PERIB_INTB128( vect = 128, enable ) )

/* Function definition. */
void Excep_PERIB_INTB128( void )
{
long lHigherPriorityTaskWoken;

    /* Interrupts are already enabled here.  See comment above. */

    /* vTaskNotifyGiveFromISR() is an interrupt safe FreeRTOS function.  It is
    assumed the task handle has already been stored.  If notifying the task
    unblocks the task, and the task that is unblocked has a priority above the
    priority of the currently executing task, then the lHigherPriorityTaskWoken
    parameter will get set to pdTRUE inside the vTaskNotifyGiveFromISR()
    function. */
    vTaskNotifyGiveFromISR( xTask, &lHigherPriorityTaskWoken );
    portYIELD_FROM_ISR( lHigherPriorityTaskWoken );
}
An example interrupt service routine using the Renesas compiler syntax


/* Pragma used to install the interrupt.  */
#pragma vector = VECT_TMR0_CMIA0

/* Function definition. */
__interrupt void vT0_1_InterruptHandler( void )
{
long lHigherPriorityTaskWoken;

    /* Unlike when using the Renesas compiler, interrupts must be explicitly
    re-enabled inside the interrupt service routine. */
    __enable_interrupt();

    /* vTaskNotifyGiveFromISR() is an interrupt safe FreeRTOS function.  It is
    assumed the task handle has already been stored.  If notifying the task
    unblocks the task, and the task that is unblocked has a priority above the
    priority of the currently executing task, then the lHigherPriorityTaskWoken
    parameter will get set to pdTRUE inside the vTaskNotifyGiveFromISR()
    function. */
    vTaskNotifyGiveFromISR( xTask, &lHigherPriorityTaskWoken );
    portYIELD_FROM_ISR( lHigherPriorityTaskWoken );
}
An example interrupt service routine using the IAR compiler syntax


/* The function prototype uses the interrupt attribute.  The then function
must be manually inserted into the interrupt vector table. */
static void vT0_1_InterruptHandler( void ) __attribute__((interrupt));

/* Function definition. */
void Excep_PERIB_INTB128( void )
{
long lHigherPriorityTaskWoken;

    /* Unlike when using the Renesas compiler, interrupts must be explicitly
    re-enabled inside the interrupt service routine. */
    __asm volatile( "SETPSW	I" );


    /* vTaskNotifyGiveFromISR() is an interrupt safe FreeRTOS function.  It is
    assumed the task handle has already been stored.  If notifying the task
    unblocks the task, and the task that is unblocked has a priority above the
    priority of the currently executing task, then the lHigherPriorityTaskWoken
    parameter will get set to pdTRUE inside the vTaskNotifyGiveFromISR()
    function. */
    vTaskNotifyGiveFromISR( xTask, &lHigherPriorityTaskWoken );
    portYIELD_FROM_ISR( lHigherPriorityTaskWoken );
}
An example interrupt service routine using the GCC compiler syntax


Generating the RTOS tick interrupt

FreeRTOS requires exclusive use of a timer that is capable of generating the tick interrupt - but it is up to the application writer to define which timer is used. To do this, the application must define a function called vApplicationSetupTimerInterrupt() that configures a timer to generate an interrupt at the frequency specified by the configTICK_RATE_HZ setting in FreeRTOSConfig.h, then install the RTOS tick interrupt handler in the corresponding location within the interrupt vector table.

When using the IAR and Renesas compilers the RTOS tick handler is installed simply by defining configTICK_VECTOR to the appropriate vector number in FreeRTOSConfig.h.

When using the GCC compiler the RTOS tick handler and RTOS software interrupt handler must be manually added to the appropriate vectors in the vector table definition. The RTOS tick handler is called vPortTickISR(), and the RTOS software interrupt handler is called vPortSoftwareInterruptISR(). See the source file vector_table.c in the GCC project for an example.

It is suggested that a compare match timer is used to generate the tick interrupt, and an example implementation of vApplicationSetupTimerInterrupt() that uses compare match timer 0 is included in main.c within each RX100 demo application.


Resources used by FreeRTOS

FreeRTOS requires exclusive use of the software interrupt.


Compiler options

As with all the ports, it is essential that the correct compiler options are used. The best way to ensure this is to base your application on the provided demo application files.


Memory allocation

Source/Portable/MemMang/heap_4.c is included in the RX113 demo application project to provide the memory allocation required by the RTOS kernel. Please refer to the Memory Management section of the API documentation for full information.


Miscellaneous

Note that vPortEndScheduler() has not been implemented.





[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner