cancel
Showing results for 
Search instead for 
Did you mean: 

STM32-MAT/TARGET user code in main.c gets overridden

Posted on October 01, 2015 at 14:01

I'm using STM32-MAT/TARGET in Simulink 2014a and STM32CubeMX + KEIL MDK-ARM V5.

My model has custom inputs and outputs, so I have to set/read them before/after the step-function in the main loop.

My problem is, every code i write there gets overridden my simulink code generator, in the whole main.c file.

STM32CubeMX on it's onw does not override user code, only Simulink does.

How can i handle this?

#mat/target #simulink
5 REPLIES 5
Amel NASRI
ST Employee
Posted on October 02, 2015 at 11:53

Hi hieber.jan,

Do you mean that even code in ''USER Code'' sections is overwritten by Simulink?

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Posted on October 04, 2015 at 11:55

Yes.

When i generate code with STM32CubeMX only, the USER sections marked with the comments are not overwritten.

But as soon as MATLAB comes in, it overwrites the whole main.c file.

So when i want to process input/output data from the model before/after the step function, the code is lost every time i generate the code with simulink.
Posted on October 04, 2015 at 13:11

Perhaps the easiest way to tackle this is to keep a primary copy of the app with your modifications, and use something like WinMerge to pull back in the user functionality each time you iterate the design in your generator tools. Probably not as ideal as an integrated solution, but perhaps the path of least resistance.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on October 09, 2015 at 16:16

OK thanks very much.

Can be closed.
Posted on November 06, 2015 at 17:27

Hi All,

modification will be integrated into next STM32-MAT/TARGET version to solve this problem.

A preference will be added to overwrite or not main.c file with Simulink generated one.

Regards