cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMx Code generation duplicating lines in main.c

rasem
Associate II

Hi. I am using NUCLE-F439ZI board

STM32CubeIDE Version: 1.16.0
Build: 21983_20240628_1741 (UTC)

Lately I am experiencing problem, when I make changes in .IOC file and save and generate code

it is messing my main.c file. It is copying big portion of main.c lines and adding them again in main.c file.

It is impossible to continue working. Is this a setting problem or a bug in the software?

Please help.

Thank you.

Rasem

6 REPLIES 6
TDK
Guru

Are you modifying the USER CODE lines? What lines is it copying/adding? Your code should only be put within a USER CODE block.

Include your main.c file here.

If you feel a post has answered your question, please click "Accept as Solution".
SofLit
ST Employee

Hello,

Are you putting your custom code between:

/* USER CODE BEGIN XXX */

<Your custom code>

/* USER CODE END XXX  */

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.

HI SofLit,

Thanks for the reply.

Yes, all codes are between the user specified locations. The problem happens when I copy and paste some code from

another project, and then I make changes in .IOC file, Save  and generate code.

Now, I am trying now to Build the project every time I paste a new code, and before I make changes in .IOC and before

Generating code. It seems to be working without problem.

This is my assumption of the problem, I hope it will solve future problems.

Rasem

 

Could you please describe the exact operation you are doing?

Could you please share the exact code you are copying/pasting in the generated code and where? Is the code you are copying contains /* USER CODE BEGIN XXX */ and /* USER CODE END XXX  */ ?

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.

Hi SofLit,

Thank you for your reply.

Here is the main.c

 

Rasem

But you didn't answer these questions: 

Could you please describe the exact operation you did?

Could you please share the exact code you are copying/pasting in the generated code and where?

We need to know which code was generated and which user code you paste and were?

For that, we need from you to:

1- Provide the original main.c generated code

2- Provide the user code and where you paste it? at which lines

3- Attach the .ioc file to reproduce the behavior.

Thank you.

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.