新手入门
积分 25
金钱 25
注册时间 2015-6-18
在线时间 0 小时
5 金钱
去年的一个程序,一直在正常使用,前几天程序更新了部分功能,烧录后发现外部中断不响应,而更新的部分并没有涉及到外部中断这一块,
最初怀疑是电脑系统版本导致,在win7-32位、64bi位下均重新编译了更新前和更新后的程序,烧录到芯片中,外部中断都不能响应,而且换了3块板子都是一个样,编译软件是Keil MDK4.70a,库函数版本V3.5.0,程序更新前后都没变。
后来查了资料,发现加上" EXTI_GenerateSWInterrupt(EXTI_Line0)",产生软件中断,外部中断才能正常使用,
中断相关部分程序贴出来,请大家帮我看看是什么原因
void NVIC_Configuration(void)
{
#ifdef VECT_TAB_RAM
/* Set the Vector Table base location at 0x20000000 */
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else /* VECT_TAB_FLASH */
/* Set the Vector Table base location at 0x08000000 */
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif
}
void Exti_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE); //关闭JTAG
//GPIOA.0--中断线映射
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource0);
/* Configure one bit for preemption priority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;//PA0
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;//上拉输入
GPIO_Init(GPIOA, &GPIO_InitStructure);
//EXTI_GenerateSWInterrupt(EXTI_Line0);//加上产生软件中断,外部中断才能正常
EXTI_InitStructure.EXTI_Line = EXTI_Line0;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;//下降沿触发
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void EXTI0_IRQHandler(void)
{
OSIntEnter();
if(EXTI_GetITStatus(EXTI_Line0) != RESET)
{
//
EXTI_ClearITPendingBit(EXTI_Line0);
}
OSIntExit();
}
我来回答