Skip to main content
Associate II
July 12, 2026
Solved

User code overwritten by SMDCube IDE

  • July 12, 2026
  • 3 replies
  • 90 views

Dear Community,

 

I’m struggling to find a way to prevent SMDCube IDE code generation to overwrite a changed #define. I’ve tried the usual wrapping with /* USER CODE BEGIN …   with no result, and also try to dig online for some similar issue, but no luck.

Any hint on how I can actually make this work?

 

Details:

STM32U595

STM32CubeIDE Version: 1.19.0

 

specific define ( in STM32U5xx_HAL_CONF )

#define USE_HAL_ADC_REGISTER_CALLBACKS 1U /* ADC register callback disabled */

this one is overwritten each time code generation is run from the graphic GUI

 

Goal is to have ADC complete callback registrable to multiple functions.

 

When I force the above define to 1, all works as expected, but when I have to run code generation then the define is rolled back to the standard “0U”, which obviously is not desirable.

Tried also to override the define from outside the file, but this creates a neverending chain of errors.

 

Best Regards,

Anton

 

Best answer by Saket_Om

Hello ​@Anton_2 

Did you enable register callback for ADC peripheral on STM32CubeMX? 

 

3 replies

David Littell
Senior II
July 12, 2026

I’m pretty sure you can’t just drop in your own “/* USER CODE <blah> */” entries in the post-generated code and expect them to stick.  It sounds like a related device feature isn’t properly enabled in CubeMX.

Saket_OmBest answer
ST Technical Moderator
July 13, 2026

Hello ​@Anton_2 

Did you enable register callback for ADC peripheral on STM32CubeMX? 

 

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
Anton_2Author
Associate II
July 13, 2026

Hello ​@Saket_Om 

 

brilliant, this properly solves the issue.

 

Best Regards,

Anton