Add custom code before each "step" function call in Embedded Coder

Greetings,
currently I'm developing an application firmware for my custom real-time hardware. Because of that, I want to be able to add a custom source before each "model step" is executed because of my custom device driver handler.
Currently I have the custom S blocks placed inside the model itself and scheduled with Scheduler Editor, and it works, but I want to place it outside the visible model. I've looked at the menues in "Configuration Parameters", but only thing I could find is "Aditional Source Code" that does not include what I need.
Is there a way to place the custom source cleanly without mixing it with the visible model itself?

回答 (1 件)

Adarsh
Adarsh 2026 年 4 月 8 日 8:53

0 投票

Hi @Luka,
I understand that you are trying to add a custom code to the model "Step" function in simulink code generation process.
Based on the MathWorks documentation resources, the best and ideal way is to use the S-Function approach which you are already using, due to its better visibility within the model.
However, it should be possible to incorporate the custom code using the "STF_make_rtw_hook" file. You can find more information on the following documentation page:
I hope this helps!

カテゴリ

ヘルプ センター および File ExchangeDeployment, Integration, and Supported Hardware についてさらに検索

製品

リリース

R2025b

質問済み:

2026 年 3 月 23 日 0:19

回答済み:

2026 年 4 月 8 日 8:53

Community Treasure Hunt

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

Start Hunting!

Translated by