Skip to main content
Visitor II
February 7, 2026
Question

User code have been coverd while regenerated using stm32cubeMX even the code is bewteen USERCODE zone.

  • February 7, 2026
  • 3 replies
  • 155 views

Hi,

I encountered a strange problem while using stm32cubeMX in a new project.

Everytime i saved the code files and then regenerated the code using stm32cubeMX,the user code will gone.

1.png

A example,"#include "led.h" " have been insert in the user code zone,then i saved the project,and regenerated code using stm32cubeMX.

2.png

then "#include "led.h" " is missing...

3.png

"Keep User Code When re-generating" already been checked as shown in the figure。

stm32cubeMX version 6.16.1.

any advise will be appreciated,thx.

 

3 replies

TDK
Super User
February 7, 2026

Please include your ioc file to see if it can be duplicated.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Ghofrane GSOURI
Technical Moderator
February 9, 2026

Hello @solaidee 

As mentioned by @TDK  Could you please attach your IOC so we can investigate what might have gone wrong?

THX

Ghofrane

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.
Ghofrane GSOURI
Technical Moderator
February 12, 2026

Hello @solaidee 

Any updates regarding this issue?  Did MX work correctly for you?

If you still need help, please either share your IOC file or, at a minimum, describe the exact steps to reproduce the issue.

THX

Ghofrane

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.