MATLAB: How to debug the S-Function generated for SIL simulation with a target from Embedded Coder 5.5 (R2011a)

Embedded Coderertsoftware-in-the-loop

I use Embedded Coder to run SIL (Software-In-the-Loop) simulations. I would like to be able to debug the S-Function that is generated for the SIL simulation.

Best Answer

To debug the SIL S-Function you need to build the necessary libraries with debug information. Please follow the steps below to do this.
1.
Check the ”Verbose build” check box under Code Generation > Debug in the Configuration Parameters.
2.
Prepare and generate code for model with the required settings to generate the SIL-block. For details on the required settings, please see:
3.
Edit the generated make file
\<model>_<target>_rtw\<model>.mk
by changing the DEBUG_BUILD flag in the following section to 1:
# To enable debugging:
# set DEBUG_BUILD = 1
DEBUG_BUILD = 0
4.
Close the model with the SIL block and execute the command
>> clear mex
to make sure the SIL S-Function MEX file is not locked.
5.
Execute the file
\<model>_<target>_rtw\<model>.bat
To rebuild the model with debug information.
You can do this from within MATLAB by making the
\<model>_<target>_rtw\
folder your current directory and then execute:
>> !<model>.bat
6.
The project is now built for debugging.
For information on how to debug S-Functions/MEX-files, please see the following guide: