Why does my function name change when I build my subsystem with Real-Time Workshop Embedded Coder?

When I use Real-Time Workshop Embedded Coder to right-click build a subsystem, the corresponding function is named "MyFnc_Start" instead of "MyFnc" in the generated C code.

 Accepted Answer

This code generation behavior results from the "Sample time" parameter setting for a Constant block. When you set a Constant block's "Sample time" parameter to 'inf', Real-Time Workshop Embedded Coder assumes that the value of the Constant block cannot change and generates the start function "MyFnc_Start". If you set the "Sample time" parameter to '-1' (inherited), the coder assumes the value must be checked for each time step and generates functions for each time step, including "MyFnc" function.
To work around this issue, do the following:
1. Double click a Constant block to access the block parameters.
2. Change the setting of "Sample time" from 'inf' to '-1' (inherit sample time).
3. Click OK.
4. Repeat steps 1 to 3 for any remaining Constant blocks.
5. Rebuild the subsystem.

More Answers (0)

Categories

Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!