Skip to main content
Gustavo.Laureano
Senior
March 31, 2017
Question

CubeMX ''user code'' request

  • March 31, 2017
  • 3 replies
  • 1361 views
Posted on March 31, 2017 at 13:35

Hi, I would like to sugest an insertion of 'user code' entry inthe MX_***_Init() functions between the Peripheral init and its NVIC config, like:

......
 GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
 GPIO_InitStruct.Pull = GPIO_PULLUP;
 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> HERE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
/* EXTI interrupt init*/
 HAL_NVIC_SetPriority(EXTI0_IRQn, 5, 0);
 HAL_NVIC_EnableIRQ(EXTI0_IRQn);�?�?�?�?�?�?�?�?�?�?�?
......�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

Because in my application when this code is executed it will generate an INT, hanging my application in an fault (as its posts to an RTOS queue not yet created)

So I would like the option to insert ' __HAL_GPIO_EXTI_CLEAR_IT(0xFF);' before initializing interrupts of the peripheral...

Or better, create one MX_Init Function where all interrupts will be created, so the user can remove the automatic call to this function and call it after cleaning all int bits...

#cubemx #feature-request #bugfix-request
This topic has been closed for replies.

3 replies

Technical Moderator
March 31, 2017
Posted on March 31, 2017 at 14:17

Hi

Laureano_Carneiro_Ca

,

I reported your requestinternally to our CubeMx team for further investigation.

Thank you for your feedback and contribution to the enhancement of our STM32 resources.

Thanks

Imen

"When your question is answered, please close this topic by clicking ""Accept as Solution"".ThanksImen"
Jeanne Joly
Associate
April 3, 2017
Posted on April 03, 2017 at 11:55

Hello

Laureano_Carneiro_Ca

,

for your question :

Or better, create one MX_Init Function where all interrupts will be created, so the user can remove the automatic call to this function and call it after cleaning all int bits...

In fact, you already have this option in CubeMX, go in Configruation tab, NVIC and then Code generation, and click on Init sequence ordering

as below :

0690X00000606h0QAA.png

And you will have in the generated code :

in the main.c :

/* USER CODE END SysInit */

/* Initialize all configured peripherals */

MX_GPIO_Init();

MX_TIM2_Init();

/* Initialize interrupts */

MX_NVIC_Init();

/* USER CODE BEGIN 2 */

/

And MX_NVIC_Init() contains the NVIC configuration :

/** NVIC Configuration

*/

static void MX_NVIC_Init(void)

{

/* EXTI1_IRQn interrupt configuration */

HAL_NVIC_SetPriority(EXTI1_IRQn, 0, 0);

HAL_NVIC_EnableIRQ(EXTI1_IRQn);

}

Hope it will help you.

BR.

Eric

Gustavo.Laureano
Senior
April 3, 2017
Posted on April 03, 2017 at 19:53

Nice, Eric!

This partially fixed my issue, but I am sill not able to execute my own code (inside 'user code area') before calling MX_NVIC_Init() function!

I know that there is an option in project settings > advanced settings > 'Not Generate Function Call', but the MX_NVIC_Init function is not listed there, so I cant inhibit this call and call it manually

Jeanne Joly
Associate
April 10, 2017
Posted on April 10, 2017 at 17:11

Hello Laureg,

See the following pictures, you can add your own code where I wrote ''ADD YOUR OWN CODE HERE, IT WORKS!''  : 

0690X00000606cGQAQ.png

You can't add some code between MX_TIM1_Init(void) and MX_NVIC_Init(void) if it is what you want.

Or else, it can be a change request on our side that we would study if needed.

BR. Eric

valentin
Associate III
April 11, 2017
Posted on April 11, 2017 at 05:14

+1, I would like to see this, too.

Had a similar situation where I had to manually clear the exti flags before the interrupts got enabled.