2022-06-30 12:08 AM
Hi, I am using CubeMX generates the application that contains MCSDK, The generated code has both stmg4xx_mc_it.c and stm32g4xx_it.c. I noticed that all the motor control related ISR code are coded in stm32g4xx_mc_it.c and I am confused with 2 issues:
Your kindly help is greatly appreciated.
Solved! Go to Solution.
2022-06-30 01:16 AM
Hello,
About the prototypes of ISR functions defined in stmg4xx_mc_it.c, there are #defines that change these names into the ones defined in startup_stm32g474xx.s. These defines can be found in file parameters_conversion_g4xx.h and in file mcp_config.h. Here are the defines for STM32G4:
#define TIMx_UP_M1_IRQHandler TIM1_UP_TIM16_IRQHandler
#define TIMx_BRK_M1_IRQHandler TIM1_BRK_TIM15_IRQHandler
#define USARTA_IRQHandler USART2_IRQHandler
#define MCP_RX_IRQHandler_A DMA2_Channel2_IRQHandler
It is probably best to add your own ISR handlers in file stm32g4xx_it.c. But beware: if you configure additional ISR, you should probably configure the related peripherals in STM32CubeMx. Then, the ISR Handlers would be generated for you by STM32CubeMx in file stm32g4xx_it.c. Then, you can fill the USER SECTIONS with your own code if/where needed. For all details on that, please have a look at the STM32CubeMx documentation.
I hope it will help.
Best Regards
Fred
2022-06-30 01:16 AM
Hello,
About the prototypes of ISR functions defined in stmg4xx_mc_it.c, there are #defines that change these names into the ones defined in startup_stm32g474xx.s. These defines can be found in file parameters_conversion_g4xx.h and in file mcp_config.h. Here are the defines for STM32G4:
#define TIMx_UP_M1_IRQHandler TIM1_UP_TIM16_IRQHandler
#define TIMx_BRK_M1_IRQHandler TIM1_BRK_TIM15_IRQHandler
#define USARTA_IRQHandler USART2_IRQHandler
#define MCP_RX_IRQHandler_A DMA2_Channel2_IRQHandler
It is probably best to add your own ISR handlers in file stm32g4xx_it.c. But beware: if you configure additional ISR, you should probably configure the related peripherals in STM32CubeMx. Then, the ISR Handlers would be generated for you by STM32CubeMx in file stm32g4xx_it.c. Then, you can fill the USER SECTIONS with your own code if/where needed. For all details on that, please have a look at the STM32CubeMx documentation.
I hope it will help.
Best Regards
Fred