Effacer les filtres
Effacer les filtres

how to turn off "ConstCode" optimization

4 vues (au cours des 30 derniers jours)
Paul
Paul le 20 Juin 2023
Réponse apportée : Paul le 20 Juin 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.

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Simulink Coder dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by