关于IO口外部中断问题

2019-07-20 15:10发布

大神们,我现在在想用PB0和PC0作为外部中断,均下降沿触发,想咨询下 中断初始化的时候需要怎么配,
void EXTIX_Init(void)

{
        NVIC_InitTypeDef   NVIC_InitStructure;
        EXTI_InitTypeDef   EXTI_InitStructure;
               
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);//ê1ÄüSYSCFGê±Öó
        SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource0);//Pb0 ᬽóμ½ÖD¶ÏÏß0
        SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource0);//Pc0 ᬽóμ½ÖD¶ÏÏß0


  EXTI_InitStructure.EXTI_Line = EXTI_Line0;//LINE0
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//ÖD¶Ïê¼t
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //ϽμÑØ′¥·¢
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;//ê1ÄüLINE0
  EXTI_Init(&EXTI_InitStructure);//ÅäÖÃ

EXTI_InitStructure.EXTI_Line = EXTI_Line2;//LINE0
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//ÖD¶Ïê¼t
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //ϽμÑØ′¥·¢
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;//ê1ÄüLINE0
  EXTI_Init(&EXTI_InitStructure);//ÅäÖÃ
       
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;//ía2¿ÖD¶Ï0
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00;//ÇàÕ¼óÅÏ輶0
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;//×óóÅÏ輶2
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//ê1Äüía2¿ÖD¶Ïí¨μà
  NVIC_Init(&NVIC_InitStructure);//ÅäÖÃ

  NVIC_InitStructure.NVIC_IRQChannel = EXTI2_IRQn;//ía2¿ÖD¶Ï2
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01;//ÇàÕ¼óÅÏ輶1
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;//×óóÅÏ輶2
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//ê1Äüía2¿ÖD¶Ïí¨μà
  NVIC_Init(&NVIC_InitStructure);//ÅäÖÃ

}
个人觉得应该是这个地方我        SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource0);
        SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource0);配置错了手册,顺便求助各位大神,
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。