打印

stm32f407的外部中断出现问题 请教高手们解答

[复制链接]
209|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
小蘭|  楼主 | 2018-7-28 07:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
stm32f407 外部中断函数总是被执行是怎么回事下面程序中总是输出 5 ,有知道的请帮回答下呗  (谢谢)废话不多说上源码:
//初始化函数
//初始化 EXTILine6
void EXTILine6_init(void)
{
  EXTI_InitTypeDef   EXTI_InitStructure;
  GPIO_InitTypeDef   GPIO_InitStructure;
  NVIC_InitTypeDef   NVIC_InitStructure;
  /* Enable GPIOB clock */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
  /* Enable SYSCFG clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
  
  /* Configure PB6 pin as input floating */
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
  /* Connect EXTI Line6 to PA6 pin */
  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource6);
  /* Configure EXTI Line6 */
  EXTI_InitStructure.EXTI_Line = EXTI_Line6;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;  
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
  /* Enable and set EXTI Line6 Interrupt to the lowest priority */
  NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0f;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0f;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
}

//初始化 EXTILine7
void EXTILine7_init(void)
  {
   EXTI_InitTypeDef   EXTI_InitStructure;
  GPIO_InitTypeDef   GPIO_InitStructure;
  NVIC_InitTypeDef   NVIC_InitStructure;
  /* Enable GPIOB clock */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
  /* Enable SYSCFG clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
  
  /* Configure PB7 pin as input floating */
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
  /* Connect EXTI Line7 to Pb7 pin */
  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource7);
  /* Configure EXTI Line0 */
  EXTI_InitStructure.EXTI_Line = EXTI_Line7;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;  
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
  /* Enable and set EXTI Line7 Interrupt to the lowest priority */
  NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0f;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0f;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  }
//中断函数
void EXTI9_5_IRQHandler(void)
{
u32 i = 0;
if(EXTI_GetITStatus(EXTI_Line7) != RESET)    //检查指定的EXTI7线路触发请求发生与否
{
  SerialPutChar(0xf);   
  if(GPIOB->IDR & (1<< 7))
  { //上升沿->高电平->有效场同步信号
   EXTI->IMR |= EXTI_Line6;    //使能像素同步中断
   EXTI->EMR |= EXTI_Line6;
   VsyncActive = 1;
  }
  else
  { //下降沿->场同步信号结束
   
   EXTI->IMR &= ~EXTI_Line6;    //关闭像素同步中断
   EXTI->EMR &= ~EXTI_Line6;
   if(VsyncActive == 1)
   { //已经经历了一个完整的场同步阶段
    VsyncActive = 2;
   
    EXTI->IMR &= ~EXTI_Line7;    //关闭场同步中断
    EXTI->EMR &= ~EXTI_Line7;
   }
   else
   {
        //   SerialPutChar('e');
     VsyncActive = 0;
   }
  }
  EXTI_ClearITPendingBit(EXTI_Line7);    //清除EXTI0线路挂起位
  EXTI_ClearFlag(EXTI_Line7);
}                               //   7 6 5 4  3 2 1 0
  if(EXTI_GetITStatus(EXTI_Line6) != RESET)      
{
   
   //  JpegBuffer[JpegDataCnt++] = (u8)(((GPIOC->IDR & 0xc0) >> 6) | ((GPIOE->IDR & 0x03) << 2)
//                          | (GPIOE->IDR & 0x10) | ((GPIOB->IDR & 0x40)>>1)|((GPIOE->IDR & 0x60)<<1)); //存储数据
  SerialPutChar(0xff);
  EXTI_ClearITPendingBit(EXTI_Line6);     //清除EXTI0线路挂起位
  EXTI_ClearFlag(EXTI_Line6);
}
  if(EXTI_GetITStatus(EXTI_Line5) != RESET)
{
     EXTI_ClearITPendingBit(EXTI_Line5);
     SerialPutChar(0x02);
}
  if(EXTI_GetITStatus(EXTI_Line8) != RESET)
{
     EXTI_ClearITPendingBit(EXTI_Line8);
     SerialPutChar(0x03);
}
  if(EXTI_GetITStatus(EXTI_Line9) != RESET)
{
     EXTI_ClearITPendingBit(EXTI_Line9);
     SerialPutChar(0x04);
}

     SerialPutChar(0x05);

}

使用特权

评论回复

相关帖子

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

本版积分规则

451

主题

463

帖子

1

粉丝