2022-11-08 01:27 AM
Is there a rule where to put code into main.c so that it stays there permanently? It happended to me now a couple of times that I added an interrupt callback function which suddenly disappeared. Are there areas in main.c where to safely put those?
Solved! Go to Solution.
2022-11-08 02:49 AM
Hello @chriskuku,
You should add the functions in the User Code section:
/* USER CODE BEGIN */
(..)
/* USER CODE END */
Ensure that following option is checked: "Keep User Code when re-generating". In this case, the user sections defined by STM32CubeMX are preserved.
Note that when upgrading to a new version of STM32CubeMX, make sure to always backup your projects before loading the new project (especially when the project includes user code).
I hope that this brings some help to you.
Foued
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.
2022-11-08 02:49 AM
Hello @chriskuku,
You should add the functions in the User Code section:
/* USER CODE BEGIN */
(..)
/* USER CODE END */
Ensure that following option is checked: "Keep User Code when re-generating". In this case, the user sections defined by STM32CubeMX are preserved.
Note that when upgrading to a new version of STM32CubeMX, make sure to always backup your projects before loading the new project (especially when the project includes user code).
I hope that this brings some help to you.
Foued
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.