请教一个中断配置的问题?

2019-07-21 02:18发布

我的中断配置代码如下,想问一下,为什么进入不了中断响应函数呢?谢谢
void EXTILine_Config(void)
{
NVIC_InitTypeDef   NVIC_InitStructure;
EXTI_InitTypeDef   EXTI_InitStructure;

GPIO_InitTypeDef  GPIO_InitStructure;

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
 
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_9|GPIO_Pin_6; 
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100M
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_Init(GPIOC, &GPIO_InitStructure);

 
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

 
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource0|EXTI_PinSource1|EXTI_PinSource9|EXTI_PinSource6);


  EXTI_InitStructure.EXTI_Line = EXTI_Line0|EXTI_Line1;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; 
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);

NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn|EXTI1_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);


  EXTI_InitStructure.EXTI_Line = EXTI_Line6;//LINE0
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);


  EXTI_InitStructure.EXTI_Line = EXTI_Line9;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; 
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel= EXTI9_5_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority= 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority= 1;
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void EXTI9_5_IRQHandler(void) 

int i; 

if(EXTI_GetITStatus(EXTI_Line9)!=RESET) 

EXTI_ClearFlag(EXTI_Line9); 
EXTI_ClearITPendingBit(EXTI_Line9);
sendFlag=0;
if(X1==0)
{
i=0;
}
else if(X1==1)
{
i=1;
}
if(PA9X==1)
{
if(HDir==1)
x=x+settings.pulse_equivalent_x/2;
else
x=x-settings.pulse_equivalent_x/2;
//PA9X=1;
}
if(PA11Z==1)
{
if(HDir==1)
z=z+settings.pulse_equivalent_z/2;
else
z=z-settings.pulse_equivalent_z/2;
//PA11Z=1;
}



if(EXTI_GetITStatus(EXTI_Line6)!=RESET) 

EXTI_ClearFlag(EXTI_Line6); 
sendFlag=0;
}
}

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
4条回答
homo
1楼-- · 2019-07-21 02:37
还有一个问题,就是在PF8端口上加电压,竟然进入了EXTI9_5_IRQHandler中断响应函数,奇怪啊!
八度空间
2楼-- · 2019-07-21 04:59
 精彩回答 2  元偷偷看……
homo
3楼-- · 2019-07-21 10:46
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource0|EXTI_PinSource1|EXTI_PinSource9|EXTI_PinSource6);这段语句是将PC9,PC6连接到中断线上,没有配置PF8啊?
正点原子
4楼-- · 2019-07-21 15:58
好好学习下我们的例程先吧。

一周热门 更多>