cancel
Showing results for 
Search instead for 
Did you mean: 

CUBE MX Regenerates main.c to original example

TWood.4
Associate III

I have created a project from one of the Example Applications in STM32 WB CUBE.

I exported the whole of the code and renamed the project with the intention that it be independent of the original example.

My development environment is STMCubeIDE.

I made a few changes of variable names in main.c

When I edit the project .ioc file from inside the IDE using MXCube, the variables I'd changed in main revert to their names in the original example.

How is this happening? Is it possible to stop it happening?

1 ACCEPTED SOLUTION

Accepted Solutions
KDJEM.1
ST Employee

Hi @TWood.4​ and welcome to the Community :),

A similar question is asked here.

Please insert your code change between USER CODE BEGIN and USER CODE END in main.c to solve this problem.

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Thank you

Kaouthar

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.

View solution in original post

2 REPLIES 2
KDJEM.1
ST Employee

Hi @TWood.4​ and welcome to the Community :),

A similar question is asked here.

Please insert your code change between USER CODE BEGIN and USER CODE END in main.c to solve this problem.

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Thank you

Kaouthar

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.

Harvey White
Senior III

The main.c code is generated automatically by the program based on the *.ioc file. Everything is rewritten in the main.c (which tracks changes in the *.ioc file) with the exception of user code. However, user code is ONLY between USER CODE BEGIN and USER CODE END sections. That code will not be wiped out by the automatic code generation. Each routine in main.c should have a user code section. Note that main.c will have a slightly different configuration depending on whether or not you use AZURE, FREERTOS, or no operating system at all.