2024-04-12 07:09 PM
This is for: cubeIDE and the built-in version of cubeMX and STM32F746 disco board.
The autogenerated code from cubeMX generates this Error_Handler() function for every (potential) error from the HAL functions. Every peripheral gets the same function call. I set the option to generate separate files for the peripheral initializations.
Is there a way to add the peripheral name (LTDC, DMAx, FMC, etc.) to the generated Error_Handler() function and also place it in the individual files?
I can do it manually but I don't know how to prevent cubeMX from overwriting the function calls the next time I regenerate the code. Thanks.
2024-04-13 06:42 AM
It might be easier in the long run to create a patch that changes Error_Handler() to a macro in main.h, have that macro substitute in something like My_Error_Handler(__FILE__, __LINE__), and comment out the Error_Handler() definition in the generated main.c. Implement your My_Error_Handler() in your application code outside of what gets scrubbed by CubeMX (or within a USER_CODE block somewhere). Of course you have to remember to run the patch after every CubeMX code generation but over time you're likely to need more mods to the generated code under Core and those changes can be added to the patch as needed.