2017-03-31 04:35 AM
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-request2017-03-31 05:17 AM
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
2017-04-03 02:55 AM
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 :
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
2017-04-03 12:53 PM
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
2017-04-10 10:11 AM
Hello Laureg,
See the following pictures, you can add your own code where I wrote ''ADD YOUR OWN CODE HERE, IT WORKS!'' :
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
2017-04-10 01:07 PM
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.
2017-04-10 08:14 PM
+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.