Real-Time Workshop Embedded Coder | ![]() ![]() |
Controlling Stack Space Allocation
Real-Time Workshop offers a number of options that let you control how signals in your model are stored and represented in the generated code. This section discusses options that:
For a complete discussion of signal storage options, see the Code Generation and the Build Process chapter of the Real-Time Workshop documentation.
If you want to store signals in stack space, you must turn the Local block outputs option on. To do this:
General code generation options
.
Your embedded application may be constrained by limited stack space. When the Local block outputs option is on, you can limit the use of stack space by using the following TLC variables:
MaxStackSize
: The total allocation size of local variables that are declared by all functions in the entire model may not exceed MaxStackSize
(in bytes). MaxStackSize
can be any positive integer. If the total size of local variables exceeds this maximum, the Target Language Compiler will allocate the remaining variables in global, rather than local, memory.
MaxStackVariableSize
: Limits the size of any local variable declared in a function to N
bytes, where N>0
. A variable whose size exceeds MaxStackVariableSize
will be allocated in global, rather than local, memory.
To set either of these variables, use assign
statements in the system target file (ert.tlc
), as in the following example:
We recommend that you write your %assign
statements in the Configure RTW code generation settings
section of the system target file. The %assign statement is described in the Target Language Compiler documentation.
![]() | Generating Block Comments | Generating a Code Generation Report | ![]() |