User Code Start - End Structure In Simulink / Embedded Coder
Show older comments
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 Comments
OGUZ AYDIN
on 3 Oct 2022
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.
Mark McBroom
on 23 Oct 2022
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.
Answers (0)
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!