Renesas RX200 Demo
Using the Renesas Compiler and HEW IDE
[RTOS Ports]



Renesas RX210 Starter Kit (RSK)

This page documents the Renesas RX210 FreeRTOS port and demo application that uses the Renesas RX compiler, and HEW IDE. The project is pre-configured to run on the RSKRX210 starter kit.

This demo application demonstrates:



IMPORTANT! Notes on using the Renesas RX200 port and demo application

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 HEW workspaces for the RSK development board is called RTOSDemo.hws and is located in the FreeRTOS/Demo/RX200_RX210-RSK_Renesas directory.

The FreeRTOS zip file download contains the implementation of all the FreeRTOS ports, and every single official demo application project. It therefore contains many more files than used by this demo. See the Source Code Organization section for a description of the downloaded files and information on creating a new project.



RX210 Demo Application

Functionality

The project includes three build configurations:

Build configuration Description
Blinky This is a very simple example that creates two tasks and one queue. The tasks communicate with each other via the queue, and an LED is toggled on each successful queue receive. The main() function used by the Blinky build configuration is defined in main-blinky.c. The main() function used by the other two build configurations is defined in main-full.c.
Debug This is a very comprehensive demo that creates nearly 50 tasks before starting the RTOS scheduler, then continuously dynamically creates and deletes another two tasks as the application executes. It also creates many queues and different types of semaphore. The tasks consist mainly of the standard demo tasks - which don't perform any particular functionality other than testing the port and demonstrating how the FreeRTOS API can be used. Information on additional tasks that are created is provided immediately below this table. The Debug build configuration includes standard demo tasks that demonstrate interrupt nesting, but does not include the high frequency timer interrupt.
Debug_with_optimisation This is similar to the Debug build configuration, but includes the high frequency timer interrupt. The build configuration also has compiler optimisation turned up to maximum.

The Debug and Debug_with_optimisation build configurations create the following tasks, timers, and tests, in addition to the standard demo tasks:


When executing, the demo application will behave as follows:


Building and executing the demo application

  1. Before opening the project - connect the RX210 RSK to the host computer using an E1 FINE interface, which is provided in the RSK kit. Once connected, apply power to the development board.

  2. Open the FreeRTOS/Demo/RTOSDemo.hws workspace from within the HEW IDE - following the prompts to connect to the target interface as the project opens.

  3. Select "Build" from the HEW "Build" menu - the demo application should build without any genuine errors or warnings, although dependency errors are produced as the pre-processor [inexplicable] looks for header files that omitted from the build by preprocessor directives - these erroneous errors will not effect the build.

  4. When the build has completed, a dialogue box will appear that asks if you want the produced binary to be downloaded to the RX210 microcontroller - select "yes" to program the flash, and start a debug session. The debugger will break on entry to the main() function.



RTOS Configuration and Usage Details

FreeRTOS RX200 RTOS port specific configuration

Configuration items specific to this demo are defined in FreeRTOS/Demo/RX200_RX210-RSK_Renesas/RTOSDemo/FreeRTOSConfig.h. The constants can be edited to suit your application. In particular - The RX200 port layer #defines 'BaseType_t' to 'long'.


Writing interrupt service routines (ISRs)

Interrupt service routines can be implemented using the standard Renesas compiler syntax. For example, the demo application defines the high frequency timer using:
/* The 'enable' in the following line causes the compiler to generate code that
re-enables interrupts on function entry.  This will allow interrupts to nest
(although in this case the high frequency timer interrupt is the highest priority
interrupt in the demo). */
#pragma interrupt ( prvTimer2IntHandler( vect = _VECT( _CMT2_CMI2 ), enable ) )
static void prvTimer2IntHandler( void )
{
    /* ISR implementation goes here. */
}
See the examples provided by Renesas and the compiler documentation for full details.

Often an ISR wants to cause a context switch, so the task that the ISR returns to when the ISR processing is completed is different from the task that the ISR originally interrupted. This would be the case if the ISR caused a task to unblock, and the task that was unblocked has a priority above the task in the Running state (the task that was interrupted). The macro portYIELD_FROM_ISR() is provided for this purpose. portYIELD_FROM_ISR() takes a single parameter: If the parameter is zero, a context switch is not performed, if the parameter is non-zero, a context switch is performed. This is demonstrated in the code below - which is part of the RX210 demo, and implemented in FreeRTOS/Demo/RX200_RX210-RSK_Renesas/RTOSDemo/ButtonAndLCD.c.

/* The 'enable' in the following line causes the compiler to generate code that
re-enables interrupts on function entry.  This will allow interrupts to nest. */
#pragma interrupt ( prvIRQ1_Handler( vect = 65, enable ) )

static void prvIRQ1_Handler( void )
{
static TickType_t xTimeLastInterrupt = 0UL;
static const unsigned char ucCommand = lcdSHIFT_BACK_COMMAND;
BaseType_t xHigherPriorityTaskWoken;

  /* prvSendCommandOnDebouncedInput() returns true or false, depending on
  whether the function unblocked a task that has equal or higher priority than the task
  that is already in the running state. */
  xHigherPriorityTaskWoken = prvSendCommandOnDebouncedInput( &xTimeLastInterrupt,
                                                             ucCommand );
  portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}


Resources used by FreeRTOS

FreeRTOS requires exclusive use of the software interrupt. FreeRTOS also 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.

The application must define a function called vApplicationSetupTimerInterrupt() to configure the tick interrupt, then define configTICK_VECTOR to be the interrupt vector number associated with the chosen timer source.

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 both main-full.c and main-blinky.c in this demo application. The demo application defines configTICK_VECTOR within FreeRTOSConfig.h to be _CMT0_CMI0 (the compare match 0 interrupt vector number). The provided example implementations can be used in any application that does not itself need to use the compare match 0 timer/interrupt.


Switching between the pre-emptive and co-operative RTOS kernels

Set the definition configUSE_PREEMPTION within RTOSDemo/FreeRTOSConfig.h to 1 to use pre-emption or 0 to use co-operative. The full demo application may not execute correctly when the co-operative RTOS scheduler is selected.


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_2.c is included in the RX210 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.