Everything

CHAPTER 2 SYSTEM CONSTRUCTION


This chapter describes how to build a system (load module) that uses the functions provided by the RI850V4.
2.1 Outline
System building consists in the creation of a load module using the files (kernel library, etc.) installed on the user development environment (host machine) from the RI850V4's supply media.
The following shows the procedure for organizing the system.
Figure 2-1 Example of System Construction
The RI850V4 provides a sample program with the files necessary for generating a load module.
For the location where the sample program is stored, see "RI Series Start".
2.2 Cording System Configuration File
Code the SYSTEM CONFIGURATION FILE required for creating information files (system information table file, system information header file, entry file) that contain data to be provided for the RI850V4.
Note For details about the system configuration file, refer to "CHAPTER 17 SYSTEM CONFIGURATION FILE".
2.3 Coding Processing Programs
Code the processing that should be implemented in the system.
In the RI850V4, the processing program is classified into the following seven types, in accordance with the types and purposes of the processing that should be implemented.
- Tasks
A task is processing program that is not executed unless it is explicitly manipulated via service calls provided by the RI850V4, unlike other processing programs (cyclic handler, interrupt handler, etc.).
- Cyclic handlers
The cyclic handler is a routine dedicated to cycle processing that is activated periodically at a constant interval (activation cycle).
The RI850V4 handles the cyclic handler as a "non-task (module independent from tasks)".
Therefore, even if a task with the highest priority in the system is being executed, the processing is suspended when a specified activation cycle has come, and the control is passed to the cyclic handler.
- Interrupt Handlers
The interrupt handler is a routine dedicated to interrupt servicing that is activated when an EI level maskable interrupt occurs.
The RI850V4 handles the interrupt handler as a "non-task (module independent from tasks)".
Therefore, even if a task with the highest priority in the system is being executed, its processing is suspended when an EI level maskable interrupt occurs, and control is passed to the interrupt handler.

- Extended Service Call Routines
This is a routine to which user-defined functions are registered in the RI850V4, and will never be executed unless it is called explicitly, using service calls provided by the RI850V4.
The RI850V4 positions extended service call routines as extensions of the processing program that called the extended service call routine.
2.4 Coding User-Own Coding Module
To support various execution environments, the hardware-dependent processing and various information required for the RI850V4 to execute processing are extracted as user-own coding modules.
This enhances portability for various execution environments and facilitates customization as well.
The user-own coding modules for the RI850V4 are classified into the following six types depending on the type of hardware-dependent processing to be executed and the usage of the module.
- Post-overflow processing
A routine dedicated to post-processing (function name: _kernel_stk_overflow) that is extracted as a user-own coding module to execute post-overflow processing and is called when a stack overflow occurs in the RI850V4 or a processing program.
Acceptance of interrupts is disabled (the ID flag in the program status word (PSW) is set to 1) in the initial state after activation.

- Interrupt entry processing
A routine dedicated to entry processing that is extracted as a user-own coding module to assign processing for branching to the relevant processing (such as interrupt preprocessing), to the handler address to which the CPU forcibly passes control when an interrupt occurs.
The interrupt entry processing for the EI level maskable interrupts defined in the
Interrupt handler information in the system configuration file is included in the entry file created by executing the configurator for the system configuration file.
Therefore, coding of interrupt entry processing is necessary for other interrupts (such as a reset) that are not EI level maskable interrupts.

- Initialization routine
A routine dedicated to initialization processing that is extracted as a user-own coding module to initialize the hardware dependent on the user execution environment (such as the peripheral controller), and is called from the Kernel Initialization Module.
- Idle Routine
A routine dedicated to idle processing that is extracted from the SCHEDULER as a user-own coding module to utilize the standby function provided by the CPU (to achieve the low-power consumption system), and is called from the scheduler when there no longer remains a task subject to scheduling by the RI850V4 (task in the RUNNING or READY state) in the system.
- Boot processing
A routine dedicated to initialization processing that is extracted as a user-own coding module to initialize the minimum required hardware for the RI850V4 to perform processing, and is called from Interrupt entry processing.
- System dependent information
The system-dependent information is a header file (file name: userown.h) including various information required for the RI850V4 to execute processing, which is extracted as a user-own coding module.
2.5 Trace Information File
The trace information file (file name: trcinf.c) includes descriptions of the processing necessary for the trace mode selected in the Property panel -> [Task Analyzer] tabbed page -> [Trace] category -> [Selection of trace mode].
The user does not need to modify the contents of this file.
Note that this file should be incorporated into the load module even when the trace facility is not used. Include this file as a target of build processing even when using the GHS-version development environment.
2.6 Creating Load Module
Run a build on CS+ for files created in sections from "2.2 Cording System Configuration File" to "2.4 Coding User-Own Coding Module", the trace information file, and the library files provided by the RI850V4 and C compiler package, to create a load module.
1 ) Create or load a project
Create a new project, or load an existing one.
Note See RI Series Real-time OS User's Manual: Start or CS+ Integrated Development Environment User's Manual: Start for details about creating a new project or loading an existing one.
2 ) Set a build target project
Specify a project as the target of build.
Note See CS+ Integrated Development Environment User's Manual: RH850 Build for details about setting the active project.
3 ) Set build target files
For the project, add or remove build target files and update the dependencies.
Note See CS+ Integrated Development Environment User's Manual: RH850 Build for details about adding or removing build target files for the project and updating the dependencies.
The following lists the files required for creating a load module.
- System configuration file created in "CHAPTER 2.2 Cording System Configuration File"
Note Specify "cfg" as the extension of the system configuration file name. If the extension is different, "cfg" is automatically added (for example, if you designate "aaa.c" as a file name, the file is named as "aaa.c.cfg").
- C/assembly language source files created in "2.3 Coding Processing Programs"
- Processing programs (tasks, cyclic handlers, interrupt handlers, extended service call routines)
- C/assembly language source files created in "2.4 Coding User-Own Coding Module"
- User-own coding module (post-overflow processing, interrupt entry processing, initialization routine, idle routine, boot processing, system dependent information)
- Trace information files provided by the RI850V4
- Library files provided by the RI850V4
- Kernel library
- Library files provided by the C compiler package
- Standard library, Math library, etc.
Note 1 If the system configuration file is added to the Project Tree panel, the Real-Time OS generated files node is appeared.
The following information files are appeared under the Real-Time OS generated files node. However, these files are not generated at this point in time.
- System information table file
- System information header file
- Entry file
Figure 2-2 Project Tree Panel (After Adding sys.cfg)
Note 2 When replacing the system configuration file, first remove the added system configuration file from the project, then add another one again.
Note 3 Although it is possible to add more than one system configuration files to a project, only the first file added is enabled. Note that if you remove the enabled file from the project, the remaining additional files will not be enabled; you must therefore add them again.
4 ) Specify the output of a load module file
Specify the type of load module file to be generated.
Note For details of the load module output settings, see "CS+ CC-RH Build Tool Operation".
5 ) Set the output of information files
Select the system configuration file on the project tree to open the Property panel.
On the [System Configuration File Related Information] tab, set the output of information files (system information table file, system information header file, and entry file).
Figure 2-3 Property Panel: [System Configuration File Related Information] Tab
6 ) Set trace function
Use the task analyzer tool (a utility tool provided by the RI850V4) on the [Task Analyzer] tabbed page in the Property panel to specify the information necessary to analyze the execution history (trace data) of the processing program.
Figure 2-4 [Task Analyzer] Tab
7 ) Set build options
Set the options for the compiler, assembler, linker, and the like.
When using the RI850V4, some options should always be specified. For details, see "15.4 Conditional Compile Macro".
Note See CS+ Integrated Development Environment User's Manual: RH850 Build for details about setting build options.
8 ) Run a build
Run a build to create a load module.
Note See CS+ Integrated Development Environment User's Manual: RH850 Build for details about running a build.
Figure 2-5 Project Tree Panel (After Running Build)
9 ) Save the project
Save the setting information of the project to the project file.
Note See CS+ Integrated Development Environment User's Manual: Project Operation for details about saving the project.
2.7 Option Settings for Build
When using the RI850V4, the following options should always be specified for user applications.
In addition, the options listed in "15.4 Conditional Compile Macro" should also be specified when using the header file provided by the RI850V4.
- CC-RH version
Build Option
Description
-Xreserve_r2
Reserves the r2 register.
-D__rel__
Definition of the compiler from Renesas Electronics.
Add two underscores before and after "rel".
-Xep=callee
Specifies the handling of the EP register.

- CCV850 version
Build Option
Description
-reserve_r2
Reserves the r2 register.
-D__ghs__
Definition of the compiler from Green Hills Software.
Add two underscores before and after "ghs".