/* Configure the NVIC Preemption Priority Bits配置优先级组 */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
/* 2 bits for pre-emption priority:0-3
2 bits for subpriority:0-3*/
/* Enable the USART3 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority =1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* enabling TIM1 interrupt */ //抢占级0,响应级0 采样点间隔计时器0.5ms
NVIC_InitStructure.NVIC_IRQChannel=TIM1_CC_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the TIM3 gloabal Interrupt */ //采样周期计时器20ms
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority =3;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_SetPriority(SysTick_IRQn,15);
}
如上程序,我设的抢占优先级为2位(0-3),亚优先级也是2位(0-3),然后设的Systick的优先级为15(默认的优先级),这样话Systick中断到底比其他的优先级都低呢还是都高呀 |