フィルターのクリア

how to turn off "ConstCode" optimization

4 ビュー (過去 30 日間)
Paul
Paul 2023 年 6 月 20 日
回答済み: Paul 2023 年 6 月 20 日
I'm using Embedded Coder to generate code from a system that contains some custom S-Functions written in C. They are fully inlined, so I have .mex64 files and .tlc files.
If the s-function blocks have constant inputs, Simulink is emitting my code in a function called ModelName_Const() which is called only once at initialization. There's a comment saying "ConstCode for S-Function (my_sfunction)" followed by my custom code.
Why is it doing that, and how do I make it stop? My code has side effects, so I don't want it called only once. I want it called in the main ModelName_step() block. Is there a way to tell Simulink that the s-function has side effects, so it doesn't get moved?
In some cases, the s-function block is in a triggered subsystem. I don't want the code to get run at all until the subsystem is triggered, but Simulink doesn't care. It calls it once at initialization time whether the subsystem gets triggered or not.

採用された回答

Paul
Paul 2023 年 6 月 20 日
I figured this out. I needed this flag passed to ssSetOptions(): SS_OPTION_DISALLOW_CONSTANT_SAMPLE_TIME

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by