多个中断在一起怎么配置啊!

2019-07-21 01:12发布

串口中断、外部中断1.外部中断2.还有定时器中断,一个有四个中断,我不知道是不是后面的配置把前面的配置给覆盖了,就是没有外部中断,但是我如拿出单个实现,外部中断又可行。 [mw_shl_code=c,true]void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure; /* 配置中断使用组合1*/ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); /* USART*/ NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =3; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /*TIM2*/ NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = EXTI2_IRQn; //选择中断通道2 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //抢占式中断优先级设置为0 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //响应式中断优先级设置为0 NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE; //使能中断 NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQn; //选择中断通道3 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; //抢占式中断优先级设置为1 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; //响应式中断优先级设置为1 NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE; //使能中断 NVIC_Init(&NVIC_InitStructure);[/mw_shl_code] 这是中断向量配置
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。