cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX NVIC setting

rbenesh
Associate II
Posted on January 19, 2016 at 19:10

I ran my project settings through the CubeMX program to see if there would be any difference in the settings CubeMX makes. I made one observation that seemed worth mentioning. 

The systick IRQ priority is set twice:

in main.c:

void SystemClock_Config(void)

{..........

  /* SysTick_IRQn interrupt configuration */

  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

}

in stm32fxxx_hal_msp.c:

void HAL_MspInit(void)

{

  /* USER CODE BEGIN MspInit 0 */

  /* USER CODE END MspInit 0 */

  __SYSCFG_CLK_ENABLE();

  /* System interrupt init*/

  /* SysTick_IRQn interrupt configuration */

  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

  /* USER CODE BEGIN MspInit 1 */

  /* USER CODE END MspInit 1 */

}

To me, this seems wrong. In my working project, I have it set in the MSP file and not in main. 

Has someone experienced this and have any insight on this?

#stm32cube #bug #hal #systick
1 REPLY 1
stm32cube-t
Senior III
Posted on February 05, 2016 at 15:57

You are correct:

From the main.c file, the NVIC_setPriority is called 3 times:

1/ once via the HAL_Init

that calls HAL_MspInit() 

that calls HAL_NVIC_SetPriority.

2/ via SystemClock_Config

that calls HAL_SYSTICK_Config

that calls SysTick_Config (CMSIS-core function hard coding priority value)

that calls NVIC_SetPriority

3/ via SystemClock_Config,

 Last call is HAL_NVIC_SetPriority(SysTick_IRQn, 4, 0); This latter one reflects actual user configuration done in MX user interface.