打印

按下外部中断按键,不进入中断却出现硬故障???

[复制链接]
2322|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wenyu520|  楼主 | 2009-12-18 21:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
把按键配置成外部中断,按下按键却进入硬故障,点IAR的停止运行按钮,程序一直停在这个地方 [img]file:///C:/DOCUME~1/ThinkPad/LOCALS~1/Temp/~FE(%`Z6BF[7OLNG`JQCJCK.jpg[/img] ,这里应该是硬故障吧,请问会是什么问题?不按下外部中断按键的时候,程序运行没有问题,按下外部中断按键程序就死掉了,外部中断配置程序如下:
void GPIO_BottonConfig(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;
  
  GPIO_StructInit(&GPIO_InitStructure);
  /*configure GPIO Botton ports PD3、PD4 as in floating ports*/
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  
  GPIO_Init(GPIOD,&GPIO_InitStructure);
  
}

void EXTI_Config(void)
{
  EXTI_InitTypeDef EXTI_InitStructure;
  NVIC_InitTypeDef NVIC_InitStructure;
  
  NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQChannel;//配置外部中断3的优先级
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  
  NVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQChannel;//配置外部中断4的优先级
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  
  
  GPIO_BottonConfig();//配置PD3、PD4为浮空输入
  
  GPIO_EXTILineConfig(GPIO_PortSourceGPIOD,GPIO_PinSource3);
  
  EXTI_StructInit(&EXTI_InitStructure);
  EXTI_InitStructure.EXTI_Line = EXTI_Line3;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
  
   GPIO_EXTILineConfig(GPIO_PortSourceGPIOD,GPIO_PinSource4);
  
  EXTI_StructInit(&EXTI_InitStructure);
  EXTI_InitStructure.EXTI_Line = EXTI_Line4;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
  
  
}

void NVIC_Configuration(void)
{
  //NVIC_InitTypeDef NVIC_InitStructure;
  
  NVIC_SCBDeInit();//设置外设SCB寄存器为默认值
  
#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
  /* Configure two bit for preemption priority */
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);

}
沙发
wenyu520|  楼主 | 2009-12-25 10:48 | 只看该作者
原来是少调用了一个向量模块

使用特权

评论回复
板凳
15242026| | 2011-3-24 15:44 | 只看该作者
原来是少调用了一个向量模块
wenyu520 发表于 2009-12-25 10:48


少调用了什么模块?能不能说清楚点啊?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

10

主题

33

帖子

0

粉丝