Real-Time Workshop User's Guide    

Code Modules

This section summarizes the code modules and header files of the Real-Time Workshop Embedded Coder, and describes where to find them.

Generated Code Modules

The Real-Time Workshop creates a build directory in your working directory to store generated source code. The build directory also contains object (.obj) files, a makefile, and other files created during the code generation process.

The default name of the build directory is model_ert_rtw. The build directory contains the following generated source code modules:


Note that the Real-Time Workshop Embedded Coder code generation report contains further information about code modules generated during a build. (See Generating a Code Generation Report).

Main Program Module

Real-Time Workshop provides the module
matlabroot/rtw/c/ert/ert_main.c as a template example for developing embedded applications. ert_main.c is not part of the generated code; it is provided as a basis for your custom modifications, and for use in simulation.

We recommend that you copy ert_main.c to your working directory and rename it to model_ert_main.c before making modifications. The Build process will create model_ert_main.obj in the build directory.

ert_main.c contains:

Program Execution contains a detailed discussion of the main module, as well as guidelines for modifying it to meet your requirements.

Utility Header Files

The following support header files are provided in the directory

You can include these header files generically for all models. Inclusion of the header files adds no overhead to the generated code.

Table 9-1 summarizes the Real-Time Workshop Embedded Coder header files.

Table 9-1: Real-Time Workshop Embedded Coder Header Files
Build directory
(Used only if MAT-file logging is enabled)
Build directory
Build directory

User-Written Code Modules

Code that you write to interface with generated model code will include a customized main module, and may also include interrupt handlers, device driver blocks and other S-functions, and other supervisory or supporting code.

We recommend that you establish a working directory for your own code modules. Your working directory should be on the MATLAB path. You must also modify the Real-Time Workshop Embedded Coder template makefile and system target file so that the build process can find your source and object files. See Chapter 17, Targeting Real-Time Systems for information.

 Real-Time Object Program Execution