F407外部中断优先级设置问题——求解答

2019-07-20 15:40发布

在实验中发现一个奇怪的情况,将NVIC的抢占优先级设置为0X10,为何中断也能正常工作?程序如下:

/*设置NVIC中断优先级*/
        NVIC_InitStruct.NVIC_IRQChannel=EXTI0_IRQn;//外部中断0
        NVIC_InitStruct.NVIC_IRQChannelCmd=ENABLE;
        NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority=0x00;
        NVIC_InitStruct.NVIC_IRQChannelSubPriority= 0x10;
        NVIC_Init(&NVIC_InitStruct);
       
        NVIC_InitStruct.NVIC_IRQChannel=EXTI2_IRQn;//外部中断2
        NVIC_InitStruct.NVIC_IRQChannelCmd=ENABLE;
        NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority=0x01;//抢占优先级为1
        NVIC_InitStruct.NVIC_IRQChannelSubPriority= 0x10;
        NVIC_Init(&NVIC_InitStruct);
       
        NVIC_InitStruct.NVIC_IRQChannel=EXTI3_IRQn;//外部中断3
        NVIC_InitStruct.NVIC_IRQChannelCmd=ENABLE;
        NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority=0x10;
        NVIC_InitStruct.NVIC_IRQChannelSubPriority= 0x10;
        NVIC_Init(&NVIC_InitStruct);


主函数设置为:NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置系统中断优先级分组为2,即2为抢占优先级和2位响应优先级
为何将抢占优先级和响应优先级设置为0x10,中断也能正常工作???响应优先级和抢占优先级不应该都在0~3内么??还是我理解错了??

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。