在线求解答!!在STM32 NVIC配置里,两个中断能不能配置为相同的抢占优先级和响应优先级?
voidNVIC_Configuration(void){NVIC_InitTypeDefNVIC_InitStructure;//中断默认参数NVIC_Priority...
void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;//中断默认参数
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); //选择中断分组1
//********** 串口中断****************************************
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;//通道设置为串口2中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //抢占式中断优先级设置为1
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //响应式中断优先级设置为1
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能中断
NVIC_Init(&NVIC_InitStructure);
//********** 外部中断 ****************************************
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //抢占优先级1
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //响应优先级1
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
} 展开
{
NVIC_InitTypeDef NVIC_InitStructure;//中断默认参数
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); //选择中断分组1
//********** 串口中断****************************************
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;//通道设置为串口2中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //抢占式中断优先级设置为1
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //响应式中断优先级设置为1
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能中断
NVIC_Init(&NVIC_InitStructure);
//********** 外部中断 ****************************************
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //抢占优先级1
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //响应优先级1
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询