STM32之NVIC學(xué)習(xí)
NVIC_InitTypeDef NVIC_InitStructure;
/* Configure the NVIC Preemption Priority Bits */
/* Configure one bit for preemption priority */
/*優(yōu)先級組說明了搶占優(yōu)先級所用的位數(shù),和子優(yōu)先級所用的位數(shù)在這里是1,7 */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
/* Enable the USART1 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = UART5_IRQn; //設(shè)置串口5中斷
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //搶占優(yōu)先級0
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //子優(yōu)先級為0
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能
NVIC_Init(&NVIC_InitStructure);
其中IRQChannel在stm32f2xx.h中查找。UART5_IRQn為UART5中斷通道。