필터 지우기
필터 지우기

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 CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by