Dojo
Dojo

Reputation: 5684

STM32CubeMx: How to add your own "USER CODE BEGIN / END" section?

I have a project where I need to add a few lines to one of the generated C files. However, the place where I want to add the change does not have a "USER CODE BEGIN / END" section. So whenever, I regenerate code, the changes are overwritten. I tried adding my own user code section as shown below but even that got overwritten. It seems, CubeMX is looks for a predefined set of USER CODE blocks, and overwrites everything else.

/* USER CODE BEGIN 8 */

/* USER CODE END 8 */

I would like to be able to define my own user code blocks so that I can write custom code in places where CubeMX has not already provided a user code block.

Upvotes: 7

Views: 8718

Answers (1)

Sid
Sid

Reputation: 613

Adding custom user code sections is not supported by CubeMX.

See this support post:

https://community.st.com/s/question/0D50X0000ALxNlmSQF/is-it-possible-to-add-custom-user-code-sections

Upvotes: 6

Related Questions