leison2002 发表于 2021-11-29 20:20

HC32F460的PH2端口配置成外部中断后,不断进入回调函数

void PortH_Init()
{
      stc_exint_config_t stcExtiConfig;
      stc_irq_regi_conf_t stcIrqRegiConf;
      stc_port_init_t stcPortInit;
      /* configuration structure initialization */
      MEM_ZERO_STRUCT(stcExtiConfig);
      MEM_ZERO_STRUCT(stcIrqRegiConf);
      MEM_ZERO_STRUCT(stcPortInit);
      /**************************************************************************/
      /* External Int Ch.2                                                    */
      /**************************************************************************/
      stcExtiConfig.enExitCh = ExtiCh02;   
      /* Filter setting */
      stcExtiConfig.enFilterEn = Enable;
      stcExtiConfig.enFltClk = Pclk3Div64;
      stcExtiConfig.enExtiLvl = ExIntBothEdge;
      EXINT_Init(&stcExtiConfig);
      /* Set External Int */
      MEM_ZERO_STRUCT(stcPortInit);
      stcPortInit.enPullUp = Enable;
      stcPortInit.enExInt = Enable;
      PORT_Init(PortH,Pin02, &stcPortInit);   
      /* Select External Int Ch.2 */
      stcIrqRegiConf.enIntSrc = INT_PORT_EIRQ2;   
      /* Register External Int to Vect.No.000 */
      stcIrqRegiConf.enIRQn = Int015_IRQn;                                                
      /* Callback function */
      stcIrqRegiConf.pfnCallback = &PORTH_PIN2_Callback;
      /* Registration IRQ */
      enIrqRegistration(&stcIrqRegiConf);
      /* Clear pending */
      NVIC_ClearPendingIRQ(stcIrqRegiConf.enIRQn);
      /* Set priority */
      NVIC_SetPriority(stcIrqRegiConf.enIRQn, DDL_IRQ_PRIORITY_DEFAULT);
      /* Enable NVIC */
      NVIC_EnableIRQ(stcIrqRegiConf.enIRQn);
}

void PORTH_PIN2_Callback()
{
      if (Set == EXINT_Irq**Get(ExtiCh02))
         {
                EXINT_Irq**Clr(ExtiCh02);      
         }
}

中断号没有被其他中断用到,这样配置后,在电平没有变化的情况下,一直进入回调函数,不知为什么?

wubangmi 发表于 2021-11-30 10:45

你好像初始化的时候只设置了上拉和外部中断使能,没有设置IO口为输入模式,不知道是不是这个影响的

martinhu 发表于 2021-11-30 14:41

你确定PH2的电平没有变化吗?最好用示波器看一下,用双边沿触发模式。

xiaos200800 发表于 2021-11-30 16:04

你试着修改下中断优先级。我之前也遇到过,修改中断优先级就会解决。有可能是这个问题,
欢迎大家加入Q群280250936,一起探讨华大开发技术问题。

leison2002 发表于 2022-1-1 21:57

是他的中断号与其他中断重复了

cyclefly 发表于 2022-1-7 14:15

原来是中断号重复了,这种没有报错吧,不好查
页: [1]
查看完整版本: HC32F460的PH2端口配置成外部中断后,不断进入回调函数