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.

 채택된 답변

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.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Simulink Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by