Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop   

Integrating External Code Using Model Configuration Parameters


Configure a model such that the Real-Time Workshop code generator includes external code—headers, files and functions—in generated code by using the Custom Code pane.

Use the Custom Code pane to insert code into the generated files and to include additional files and paths in the build process.

To...Select...
Insert custom code near the top of the generated model.c or model.cpp file, outside of any functionSource file and enter the custom code to insert.
Insert custom code near the top of the generated model.h fileHeader file and enter the custom code to insert.
Insert custom code inside the model's initialize function in the model.c or model.cpp fileInitialize function
Insert custom code inside the model's terminate function in the model.c or model.cpp file. Terminate function and enter the custom code to insert. Also select the Terminate function required parameter on the Interface pane.
Add include directories, which contain header files, to the build processInclude directories and enter the absolute or relative paths to the directories. If you specify relative paths, the paths must be relative to the directory containing your model files, not relative to the build directory. The order in which you specify the directories is the order in which they are searched for header, source, and library files.
Add source files to be compiled and linkedSource files and enter the full paths or just the file names for the files. A file name is sufficient if the file is in the current MATLAB directory or in one of the include directories. For each additional source that you specify, the Real-Time Workshop build process expands a generic rule in the template makefile for the directory in which the source file is found. For example, if a source file is found in directory inc, the Real-Time Workshop build process adds a rule similar to the following:

 %.obj: buildir\inc\%.c 
           $(CC) -c -Fo$(@F) $(CFLAGS) $< 

The Real-Time Workshop build process adds the rules in the order you list the source files.

Add libraries to be linked Libraries and enter the full paths or just the file names for the libraries. A file name is sufficient if the library is located in the current MATLAB directory or in one of the include directories.
Use the same custom code settings as those specified for simulation of Embedded MATLAB Function blocks, Stateflow charts, and Truth Table blocksUse the same custom code settings as Simulation Target

    Note   This option refers to the Simulation Target pane in the Configuration Parameters dialog box.

Enable a library model to use custom code settings unique from the parent model to which the library is linkedUse local custom code settings (do not inherit from main model)

    Note   This option is available only for library models that contain Embedded MATLAB Function blocks, Stateflow charts, or Truth Table blocks. Select Tools > Open RTW Target in the Embedded MATLAB Editor or Stateflow Editor for your library model.

For descriptions of Custom Code pane parameters, see Real-Time Workshop Pane: Custom Code in the Real-Time Workshop reference documentation.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS