model_step
Generated C/C++ entry-point function that contains execution code for each step in a Simulink model
Description
is
an execution function that contains the output and update code for the blocks in a
Simulink® model.void
model_step(void
)
is an execution function with a task identifier that contains the output and update code for
the blocks in a Simulink model.void
model_step_N(void
)
The step entry-point function computes the current values of the blocks. If logging is
enabled, the step function updates logging variables. By design, the step function is called
at the interrupt level from rt_OneStep
(invoked as a timer ISR). The
rt_OneStep
function calls the model_step
function to
execute processing for one clock period of the model. For a more information, see rt_OneStep and Scheduling Considerations (Embedded Coder).
If the model has a finite stop time, the step function signals the end of execution when the current time equals the stop time. Otherwise, if one or more of these conditions are true, the step function does not check the current time against the stop time and the program runs indefinitely:
The model stop time is set to
inf
.Logging is disabled.
Parameter Terminate function required is not selected.
The generated calling interface of the step entry-point function for a model differs depending on these parameters:
To generate a step entry-point function, select the Single output/update function parameter. If you clear this parameter,
model_output
andmodel_update
entry-point functions are generated in place of the step function.To generate a single step function with configurable arguments, clear the Treat each discrete rate as a separate task parameter. To generate separate step functions based on timing requirements, select this parameter. For more information, see Treat each discrete rate as a separate task.
Parameter Value:
Off
(single rate or multirate single-tasking model)Function Prototype:
void model_step(void);
Parameter Value:
On
(multirate multi-tasking model)Function Prototype:
void model_step_N (void);
(N
is a task identifier)
To change the generated calling interface, set the Language and Code interface packaging parameters. For more information, see Code interface packaging.
To preview and customize the name and arguments of the generated C or C++ step entry-point function an Embedded Coder® license is required. To preview a step entry-point function, open the Code Mappings editor and click the Functions tab. To customize the function name, in the Function Name column click and edit the spreadsheet directly. To customize the function name and arguments, in the Function Preview column click the function hyperlink and configure the step function from the opened dialog box. To customize a function using a template, in the Function Customization Template column select a template to apply to the function. For more information, see Configure Name and Arguments for Individual Step Functions (Embedded Coder), Interactively Configure C++ Interface (Embedded Coder), and Configure Default Code Generation for Functions (Embedded Coder).
To view the generated step entry-point function, open the Code view or Code Generation Report and view the source code for your model. For more information see, Analyze Generated Data Code Interface Report (Embedded Coder).
Examples
Input Arguments
Output Arguments
Version History
Introduced before R2006a
See Also
model_initialize
| model_terminate
| model_reset
(Embedded Coder)
Topics
- Configure Generated C Function Interface for Model Entry-Point Functions
- Configure Name and Arguments for Individual Step Functions (Embedded Coder)
- Interactively Configure C++ Interface (Embedded Coder)
- Configure Default Code Generation for Functions (Embedded Coder)
- Analyze Generated Data Code Interface Report (Embedded Coder)
- Startup, Reset, and Shutdown Function Interfaces