cancel
Showing results for 
Search instead for 
Did you mean: 

How do I change the priorities for the TIM2?

StephanMair
Senior

Hi, I'm using STM32WB55x series mcu, I wanna know how I should configure/change the relevant priority for the TIM2?

In the old days we use this:

void NVIC_Configuration(void)  
 
{
 
	NVIC_InitTypeDef NVIC_InitStructure;
 
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
 
	 
 
	NVIC_InitStructure.NVIC_IRQChannel=TIM2_IRQn;  
 
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0;  
 
	NVIC_InitStructure.NVIC_IRQChannelSubPriority=1; 
 
	NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;  
 
	
 
	NVIC_Init(&NVIC_InitStructure);
 
}

I don't know what we should do now given it's the day and age of HAL and CubeMX.

What should I do? If there's a register manipulating solution, it would be better.

13 REPLIES 13

As I've said it previously, NVIC is already set to a maximum group priorities after reset. Therefore for a typical usage there is no reason in calling NVIC_SetPriorityGrouping() at all.

https://community.st.com/s/question/0D53W00000XHZKb/nested-interrupts-stm32l4

Hey thanks for your help as always TDK.

The family of MCUs that I'm using is the W series, so like a member noted below, it's a newer family and SPL support isn't all that robust.

As a result, I'm manipulating the registers directly.

You don't recommend me doing the register manipulation myself? Can I please ask why?

Aren't one thing great about MCUs is that you can go down to the bottom layer and do things?

You can go direc the most useful settingtly for the registers but in this particular case it's counterproductive. The NVIC register are part of the processor core and the functions to access them are provided by ARM and are well established.

Piranha also says that you don't need to change the priority grouping as they are set to the most useful setting by reset.

JW