User Code Start - End Structure In Simulink / Embedded Coder

Is there a user code start - end structure in simulink coder frameworks? I am using embedded coder. I am modifying the code generated by the Simulink. But If I change something on the model and re-generate the code, the piece of code that I added / modified is being overwrite.
For example, In the STM32 Cube-MX or other IDEs that support HAL with code generation, there is a User Code Start - End structure that allows code generation without loss of user code.
Let's say we have a piece of code, generated by the Simulink below;
/* User Code Start (1) */
// This piece of code will not be overwrite by the code generator.
foo();
/* User Code End (1) */

2 个评论

I couldn't find a solution for this problem either. Whenever I edit and compile the generating code from Simulink by using Simulink/Embedded Coder, then the code is overwritten.
Simulink Coder/Embedded Coder will always write the entire <model>.c. You should not modify the generated code. If you need to insert hand-written C/C++ code into the Simulink model, you can do this with the C Function block or C Caller block.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Simulink Coder 的更多信息

产品

版本

R2022a

提问:

2022-10-3

评论:

2022-10-23

Community Treasure Hunt

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

Start Hunting!

Translated by