cancel
Showing results for 
Search instead for 
Did you mean: 

Using STM32IDE, is there any way to enter preprocessor defines, as currently when regenerating code from the 'Device Configuration Tool', any defines entered manually for the project appear to be deleted?

EdGi
Associate III

I'm thinking in particular about defines to influence the HAL library code e.g. USE_HAL_TIM_REGISTER_CALLBACKS.

Adding user defines in MX just puts them in main.h and they are not seen by the library code.

2 REPLIES 2
Mundungus
Associate II

There is an hacky ingenious but convoluted suggestion on how to set those defines here: https://community.st.com/s/question/0D50X0000ArRvt6/stmcubeide-usehalregistercallbacks-definition

It seems that CubeMX does not officially support enabling the USE_HAL_*_REGISTER_CALLBACKS options. Can anyone confirm this?

S.Ma
Principal

As HAL files are supposedly read-only and version volatile, I would look for a compiler option. Most decent SW tools provide in project settings the possibility to add global compiler options. This would probably be the way to activate/deactivate REGISTER_CALLBACKS (which to me seems defeating the interrupt routines to be snappy as it causes a switch/case execution). The other way (probably not allowed) would be to have a global user.h file included to all files (including ST source files) which enables same mechanism without being toolchain dependent. (the CMAKE way?)