Filter löschen
Filter löschen

how to turn off "ConstCode" optimization

4 Ansichten (letzte 30 Tage)
Paul
Paul am 20 Jun. 2023
Beantwortet: Paul am 20 Jun. 2023
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.

Akzeptierte Antwort

Paul
Paul am 20 Jun. 2023
I figured this out. I needed this flag passed to ssSetOptions(): SS_OPTION_DISALLOW_CONSTANT_SAMPLE_TIME

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by