Skip to main content
Associate II
July 28, 2026
Question

[STMCubeMX2] - Not generating mx_hal_def.h with all peripherals

  • July 28, 2026
  • 1 reply
  • 45 views

Greetings for the day,

I am working on STMC5 microcontroller and with that since we need to use the STMCubeMX2 for code generation, I end up generating a code that doesn’t have all the peripherals initialised in mx_system.c and not included in mx_hal_def.h. Any idea why that is happening ? Am I missing some configuration in the tool ?

 

It can be seen that mx_hal_def.h doesn’t contain all the peripheral headers. This is the issue.

1 reply

Associate
July 28, 2026

Hello Srikar,

I
 have an idea to what might cause this, that you can try.
It might have to do with your HAL System Init configuration.  

To find it go to “Project Settings” → “Global Services” → “configure”. 

 


This will then open the HAL System Init page, where you get an overview of what peripherals are generated and called. 

 



------------------------------------------------------------------------------------------------------------------------------------

There is also a setting called “Resource initialization code generation”, in every Peripheral Tab, where you can choose from:
Generated / Callable / Not Generated. 

When “Generated” is selected, the user must handle Init of the peripheral manually. 
When “Callable” is selected, MX2 should create and call the Init code for the peripheral automatically. 

Let me know if this helps!

Sincerely
Fabian Steiner