Real-Time Workshop Embedded Coder    

The Static Main Program Module

In most cases, the easiest strategy for deploying your generated code is to use the Generate an example main program option to generate the ert_main.c module (see Generating the Main Program).

However, if you turn the Generate an example main program option off, you can use the module
matlabroot/rtw/c/ert/ert_main.c as a template example for developing your 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. If your existing applications, developed prior to this release, depend upon ert_main.c, you may need to continue using this module.

When developing applications using ert_main.c, we recommend that you copy ert_main.c to your working directory and rename it to model_ert_main.c before making modifications. Also, you must modify the template makefile such that the build process will create model_ert_main.obj (on Unix, model_ert_main.o) in the build directory.

ert_main.c contains

In the static version of ert_main.c, the operation of rt_OneStep and the main function are essentially the same as described in Stand-Alone Program Execution.

Modifying the Static Main Program

As in a generated program, a few modifications to the main loop and rt_OneStep are necessary. See Guidelines for Modifying the Main Program and Guidelines for Modifying rt_OneStep.

Also, you should replace the rt_OneStep call in the main loop with a background task call or null statement.

Other modifications you may need to make are


  Model Entry Points Code Generation Options and Optimizations