2011-12-18 08:11 AM
What is the meaning of Preemppriority and subpriority?
If the number allocated to them is higher, does it mean that they are prioritized for the service than the others which are allocated less number or it is the opposite? Do i need to categorize Priority Groups if i have several interrupt service routine? I have the following priorities in my program: TIM2 (HIGH Priority) DMA (HIGH Priority) EXTI7 (HIGH Priority) TIM1 (HIGH Priority) EXTI0 (LOW Priority) TIM4 (Low Priority) Among the HIGH PRIORITY TIM2 and DMA should not be made to wait at all. In my program i wrote: NVIC_PriorityGroupConfig(NVIC_PriorityGroupConfig[NVIC_PriorityGroup_2]; NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; NVIC_InitStructure.NVIC_IRQChannel = TIM1_CC_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; Lines irrelevant to the discussion are avoided. Should i edit the NVIC_PriorityGroup?? I request some-one to help me on this. Thanks in advance. #nvic-priority-group2011-12-18 10:17 AM
I'm sure this gets good coverage in ARM's manuals, and Joseph Yiu's Cortex M3 book.
If you want and interrupt to interrupt another interrupt you need a lower PreEmption level. Interrupts within the *same* PreEmption level will be serviced based on the lowest SubPriority, but will be delayed until those ahead complete. The goal is NOT to have PreEmption = SubPriority, but to understand what interrupts are occurring, and which you have the preference to service first, to the extent you can control that.2011-12-18 11:57 AM
In addition to what Clive references, I also found the comment block in misc.c to be helpful.
2016-02-09 04:01 AM
So if I set the group to 0 , I will have 4 bits meaning 16 priorities levels to asign for my interrupts
for group 1 : I will have 1 bit for preemption(P) 3 for subpriority(s)P:0 s: 0,1,2,3,4,5,6,7P:1 s: 0,1,2,3,4,5,6,7for group 2 I will have 2 bits for preemption (P) and 2 bits for subpriority (s) : P: 0 s: 0, 1 ,2, 3P 1 s: 0, 1 ,2, 3P 2 s: 0, 1 ,2, 3P 3 s: 0, 1 ,2, 3An irq with (P,s)=(0,1) will wait to be executed for an irq with (P,s)= (0,0). Also al other irqs with (P,s)=(x,y); x>0, y=0..3 wil wait after irq with (P,s)=(0,1)Is that correct?2016-02-09 04:05 AM
And another question : when the group is set to zero , do I have to set the Preemption priority for my IRQs ?
The same question when the group is 4 , do I have to set the subpriority for my IRQs?2016-02-09 07:30 AM
I would set unused structure fields to zero.