cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX ''user code'' request

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
6 REPLIES 6
Imen.D
ST Employee
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".
Thanks
Imen
Jeanne Joly
Senior III
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

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

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

Posted on April 10, 2017 at 20:07

Actually, I wasn't clear!

When I wrote '

I am sill not able to execute my own code (inside 'user code area') before calling MX_NVIC_Init() function' I meant execute my own code between the 

MX_GPIO_Init() and 

MX_NVIC_Init() calls

So when you wrote:

'

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

It's exactly what I want, because when the 

MX_GPIO_Init() is called it sets some of the EXTI interrupt flags, and when 

MX_NVIC_Init() is called it triggers these interrupts, that's what I need stop.

For doing this the only option is execute '

__HAL_GPIO_EXTI_CLEAR_IT(0xFF)' after the MX_GPIO_Init and before the MX_NVIC_Init

So I would like to keep this suggestion to the CubeMX team!

ATM I am adding this code outside the 'user code' area, so every time I modify something and regenerate the code, I need restore this piece of code from SVN.

valentin
Senior
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.