Skip to main content
ThorstenO
Associate
September 9, 2021
Question

[CubeMX] Where can the template for the generated file "stm32g4xx_it.c" be found?

  • September 9, 2021
  • 2 replies
  • 1301 views

Hello,

I would like to add some code in the generated file "stm32g4xx_it.c" but I can't find any template.

Does anybody know how persistent code can be added to that file?

I know that there are user code sections but I'm using Simulink to generate code and my code is overwritten by Simulink...

This topic has been closed for replies.

2 replies

Igor Cesko
ST Employee
September 15, 2021

Hi TOtt.1 ,

The template is inside the CubeMX code and can't be probably changed.

For your problem is there solution: Simulink will generate code into separate file and this file will be included into "stm32g4xx_it.c" in the section :

/* USER CODE BEGIN Includes */

#include "simulink_code.c"

/* USER CODE END Includes */

By this solution you can independently generate Simulink code and CubeMX code.

Regards

Igor

ThorstenO
ThorstenOAuthor
Associate
September 15, 2021

Hi Igor,

thank you very much for the solution!

In the meantime I found another solution which also works:

In the STM32 Matlab board support package resides a file with the name "customRoutineProcess.tlc". This tlc file tells Simulink to create the file "stm32g4xx_it.c". If this is used as a 'template' for the CubeMX tool and code is written in the user code section this code is also not overwritten by CubeMX.

BTW: We would appreciate it if ST would proceed with developing the STM32 Matlab board support package!

Regards

Thorsten