cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove autogenerated code generated by MxCube?

MFolk.1
Senior

I have used MxCube to enable an ISR that is triggered from an external GPIO input pin. MxCube enables this ISR from the autogenerated MX_GPIO_Init() function by calling HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); at the very end of this function. I don't want to enable this ISR until later in the program when the rest of my system is ready and it is safe to do so.

How do I properly remove this line of code so that MxCube doesn't undo my change every time I go to update the MxCube file?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Bob S
Principal

Gotta love old vaudville jokes (they were old even when they were new)

A couple of options, at least:

  1. Config the pin in CubeMX as a normal input pin. Then when you are ready to enable the EXTI function on that pin, re-config the pin as EXTI and call HAL_NVIC_EnableIRQ(). Probably your best option.
  2. Call HAL_NVIC_DisableIRQ() in the "user code" block after the call to MX_GPIO_Init(). Can get "interesting" if it is possible for that IRQ to appear during startup before you disable the IRQ.

View solution in original post

3 REPLIES 3
MFolk.1
Senior

---------- UPDATE -----------

So I figured out that if I edit the gpio_c_HalCompliant.ftl file within the CubeMx installation folder it works. The file is located at: C:\ST\STM32CubeIDE_1.6.1\STM32CubeIDE\plugins\com.st.stm32cube.common.mx_6.5.0.202202251913\db\templates

HOWEVER,

I need a better solution than this because I need to be able to push this to a repository to share with others and therefore I can't rely on modifying installation files. Is there a way for me to add a user defined template file within the ...\db\extra_templates\ folder and add that in my MxCube settings to either override the gpio_c_HalCompliant.ftl template file or somehow modify it dynamically to eliminate the HAL_NVIC_EnableIRQ from being generated? If so, perhaps I could save this file elsewhere outside of the installation files so I can save this as part of my project repo.

Piranha
Chief II

The patient says, "Doctor, it hurts when I do this."

"Then don't do that!"

/Henny Youngman/

Bob S
Principal

Gotta love old vaudville jokes (they were old even when they were new)

A couple of options, at least:

  1. Config the pin in CubeMX as a normal input pin. Then when you are ready to enable the EXTI function on that pin, re-config the pin as EXTI and call HAL_NVIC_EnableIRQ(). Probably your best option.
  2. Call HAL_NVIC_DisableIRQ() in the "user code" block after the call to MX_GPIO_Init(). Can get "interesting" if it is possible for that IRQ to appear during startup before you disable the IRQ.