大学生
最后登录1970-1-1
在线时间 小时
注册时间2018-1-8
|
遇到了一个问题,请各位大神看下。
主函数中,在while循环时,不论我按何时下按键中断,总是在循环显示(SendGroupData_TA6932该函数是去控制数码管显示)结束后,才进入外部中断函数,百思不得其解呀!!!
难道普通的delay函数比外部中断的优先级高吗????????
还请各位大神指导下
uint8_t key1_int_flag = 0;//按键中断标志位
delay函数void Delay( uint32_t count)
{
for(;count!=0;count--);
}
void EXTI7_GPIOB7_Config(void);
void key_steup_scan(void);//按键设置函数,按键按下后才进入此函数
void SendGroupData_TA6932(unsigned char addr,unsigned char* arr,unsigned char len);//发送显示内容到TA6932
主函数大致如下:
main()
{
EXTI7_GPIOB7_Config();
while(1)
{
if(key1_int_flag == 1)
{
key_steup_scan();
}
else
{
SendGroupData_TA6932(0,TA6932_Data_Un,9);
Delay(0xFFFFFF);
SendGroupData_TA6932(0,TA6932_Data_An,9);
Delay(0xFFFFFF);
SendGroupData_TA6932(0,TA6932_Data_Tem,9);
Delay(0xFFFFFF);
}
}
}
//中断配置函数
void EXTI7_GPIOB7_Config(void)
{
NVIC_InitTypeDef NVIC_InitStruct;
GPIO_InitTypeDef GPIO_InitStruct;
EXTI_InitTypeDef EXTI_InitStruct;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_AFIO, ENABLE);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
//EXTI9_5中断配置,按键1
NVIC_InitStruct.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStruct.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStruct);
//配置按键引脚
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource7);
EXTI_InitStruct.EXTI_Line = EXTI_Line7;
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStruct);
}
//中断函数
void EXTI9_5_IRQHandler(void)
{
if(EXTI_GetFlagStatus(EXTI_Line7)!=RESET)
{
if(key1_int_flag == 0)
{
key1_int_flag = 1;
}
else
{
key1_int_flag =0;
}
EXTI_ClearITPendingBit(EXTI_Line7);
}
}
|
|