Real-Time Workshop | ![]() ![]() |
Choosing a Code Format for Your Application
Your choice of code format is the most important code generation option. The code format specifies the overall framework of the generated code and determines its style.
When you choose a target, you implicitly choose a code format. Typically, the system target file will specify the code format by assigning the TLC variable CodeFormat. The following example is from ert.tlc
.
If the system target file does not assign CodeFormat, the default is RealTime
(as in grt.tlc
).
If you are developing a custom target, you must consider which code format is best for your application and assign CodeFormat accordingly.
Choose the real-time or real-time malloc code format for rapid prototyping. If your application does not have significant restrictions in code size, memory usage, or stack usage, you may want to continue using the generic real-time (GRT) target throughout development. The real-time format is the most comprehensive code format and supports almost all the built-in blocks. It is also capable of executing in "hard real time" (however, if the hard execution time constraints are not satisfied, a catastrophic system failure occurs). For further information on satisfying time constraints in both singletasking and multitasking environments, see Models with Multiple Sample Rates.
If your application demands that you limit source code size, memory usage, or maintain a simple call structure, then you should choose the Real-Time Workshop Embedded Coder target, which uses the embedded C format.
Finally, you should choose the S-function format if you are not concerned about RAM and ROM usage and want to:
.dll
or MEX-file object
Table 3-1 summarizes the various options available for each Real-Time Workshop code format/target, noting exceptions below.
rt_main
files emulate execution of hard real time, and when explicitly connected to a real-time clock execute in hard real-time.![]() | Introduction | Real-Time Code Format | ![]() |