问答

汇集网友智慧,解决技术难题

21ic问答首页 - HC32F460 的PH2这个脚配置成外部双沿中断

hc32f460 ST tc stc TI ic

HC32F460 的PH2这个脚配置成外部双沿中断

leison20022021-11-29
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);       
         }
}

中断号没有被其他中断用到,这样配置后,会一直进放回调函数,不知会什么?
搜索
复制

回答 +关注 7
1117人浏览 0人回答问题 分享 举报
0 个回答

您需要登录后才可以回复 登录 | 注册