Skip to main content
newdev
Associate
Oct 25, 2022 11:30 AM UTC
Solved

How to stop STM32Cubemx from generating code for specific handlers

I am using Keil MDK to setup a project for STM32 devices. STM32cubemx is integrated into Keil and can be used to generate a skeleton for the project (main.c, stm32XX.c, .h files and stm32CubeMX.ioc, etc).

This is helpful but some of the generated code contain duplicates of some handlers, like "void PendSV_Handler(void)". How do I stop STM32CubeMX from generating these defines?

This topic has been closed for replies.
Semer CHERNI
Semer CHERNIBest answer
ST Employee
Nov 24, 2022 4:09 PM UTC

Hello @Syn_BE​ 

First, I apologize for my late reply.

If I did understand well the situation; you need that CubeMx stop generating the interrupt handlers, you mentioned.

If so, under System Core --> NVIC --> Code generation you will find the list of all the interrupt handlers. You uncheck those you don't need CubeMx to generate:

0693W00000WJS5eQAH.png 

Hope this is a good answer to your question. If yes, please select it as a best one else give me your feedback to be able to provide help.

Kind regards,

Semer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

6 replies

newdev
newdevAuthor
Associate
Oct 25, 2022 11:33 AM UTC

0693W00000Uol9pQAB.png0693W00000UolBVQAZ.png

Semer CHERNI
ST Employee
Nov 1, 2022 3:14 PM UTC

Hello @newdev​ 

First let me thank you for posting.

I trying to reproduce the same behavior you encountered but it works fine from my side.

To be able to push further the analysis could you please provide a minimal project which show the problem.

I'll be waiting for your feedback.

Thx.

Semer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Syn_BE
Associate II
Nov 3, 2022 11:22 AM UTC

I have the same problem here.

I use CubIDE 1.10.1 with integrated CubeMX 6.6.1 for STM32G474.

  • I use "my own" FreeRTOS, not the one of CubeMX (Middleware FreeRTOS is "disabled")
  • I use "generate as a pair of '.c/.h' files per peripheral"

As @newdev​ wrote:

CubeMX is generating handler functions (in file "stm32g4xx_it.c") for

  • PendSV_Handler
  • SVC_Handler
  • SysTick_Handler

which collide with the handlers of "my" RTOS.

How can I prevent the generation of these functions in CubeMX?

Best regards, Andy

Semer CHERNI
Semer CHERNIBest answer
ST Employee
Nov 24, 2022 4:09 PM UTC

Hello @Syn_BE​ 

First, I apologize for my late reply.

If I did understand well the situation; you need that CubeMx stop generating the interrupt handlers, you mentioned.

If so, under System Core --> NVIC --> Code generation you will find the list of all the interrupt handlers. You uncheck those you don't need CubeMx to generate:

0693W00000WJS5eQAH.png 

Hope this is a good answer to your question. If yes, please select it as a best one else give me your feedback to be able to provide help.

Kind regards,

Semer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
newdev
newdevAuthor
Associate
Nov 25, 2022 9:06 AM UTC

This solved the issue. Thanks!

Syn_BE
Associate II
Nov 24, 2022 1:31 PM UTC

Hello,

@Semer CHERNI​ do you have any news to this issue, or do you need anyhing from me to dive deeper into this subject? Just let me know.

Short remark: it seems that this issue has also popped up in the past...

https://community.st.com/s/question/0D50X0000BNunGxSQJ/bug-cubemx-generates-erroneous-svc-and-pendsv-handlers-with-freertos

Best regards, Andy