Writing S-Functions | ![]() ![]() |
Process View
The following figures shows the order in which Simulink invokes an S-function's callback methods.
Calling Structure for the Real Time Workshop
When generating code, the Real-Time Workshop does not go through the entire calling sequence outlined above. After initializing the model as outlined in the preceding section, Simulink calls mdlRTW
, an S-function routine unique to the Real-Time Workshop, mdlTerminate
, and exits.
For more information about the Real-Time Workshop and how it interacts with S-functions, see The Real-Time Workshop User's Guide and The Target Language Compiler Reference Guide.
Alternate Calling Structure for External Mode
When running Simulink in external mode, the calling sequence for S-function routines changes. This picture shows the correct sequence for external mode.
Simulink calls mdlRTW
once when it enters external mode and again each time a parameter changes or when you select Update Diagram under your model's Edit menu.
Note Running Simulink in external mode requires the Real-Time Workshop. For more information about external mode, see the Real-Time Workshop User's Guide. |
![]() | How Simulink Interacts with C S-Functions | Data View | ![]() |