中断配置如下:
NVIC_InitTypeDef NVIC_InitStructure;
//key4中断优先级配置
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 10;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
//key5中断优先级配置
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
中断处理程序:
EXTI_Line9:
//key4
if ( EXTI_GetITStatus(EXTI_Line9) != RESET )
{
EXTI_ClearITPendingBit(EXTI_Line9);
while(isToPause && !isToResume){
RGB_yellow();
RGB1_red();
int cnt = 5000000;
while(cnt --);
RGB1_yellow();
RGB_red();
cnt = 5000000;
while(cnt --);
printf("key4 is Pressed\r\n");
if(isToResume) break;
}
//printf("key4 is Press\r\n");
}
EXTI_Line15:
//key5
if (EXTI_GetITStatus(EXTI_Line15) != RESET)
{
EXTI_ClearITPendingBit(EXTI_Line15);
isToResume = 1;
while(1){
int cnt = 5000000;
while(cnt --);
printf("key5 Button is Press\r\n");
}
}
如果中断优先级生效的话,key5应该是可以打断key4的,debug中看NVIC中断优先级key5是高于key4的,但是实际操作中不能实现效果,请问有哪位知道这是为什么,怎么才能实现想要的效果?? |