STM32之NVIC学习
扫描二维码
随时随地手机看文章
NVIC_InitTypeDef NVIC_InitStructure;
/* Configure the NVIC Preemption Priority Bits */
/* Configure one bit for preemption priority */
/*优先级组说明了抢占优先级所用的位数,和子优先级所用的位数在这里是1,7 */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
/* Enable the USART1 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = UART5_IRQn; //设置串口5中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //抢占优先级0
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //子优先级为0
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能
NVIC_Init(&NVIC_InitStructure);
其中IRQChannel在stm32f2xx.h中查找。UART5_IRQn为UART5中断通道。