项目使用两个按键,发现偶然性的进HardFault_Handler,如果频繁快速的按,就不一会就HardFault_Handler了,实在没招了,不知道哪位大神有没有寓到这样的问题,帮忙看看,是不是哪里的标志没有清除。以下是代码:
void Zero_callback()
{
EXINT_Irq**Clr(ExtiCh12);
Zero_Key_flag=1;
}
void Switch_callback(void)
{
EXINT_Irq**Clr(ExtiCh02);
Switch_Key_flag=1;
}
void Init_intruppt2()
{
stc_exint_config_t stcExtiConfig; /* 外部中断配置结构体 */
stc_irq_regi_conf_t stcIrqRegiConf; /*irq配置结构体 */
stc_port_init_t stcPortInit; /*管脚配置结构体 */
/* configuration structure initialization */
MEM_ZERO_STRUCT(stcExtiConfig);
MEM_ZERO_STRUCT(stcIrqRegiConf);
MEM_ZERO_STRUCT(stcPortInit);
/* Set PD06 as External Int Ch.6 input */
stcPortInit.enExInt = Enable;
stcPortInit.enPinMode = Pin_Mode_In;
stcPortInit.enInvert=Enable;
PORT_Init(PortD, Pin02, &stcPortInit);
stcExtiConfig.enExitCh = ExtiCh02;
stcExtiConfig.enFilterEn = Enable;
stcExtiConfig.enFltClk = Pclk3Div8;
stcExtiConfig.enExtiLvl = ExIntRisingEdge;
EXINT_Init(&stcExtiConfig);
stcIrqRegiConf.enIntSrc = INT_PORT_EIRQ2;
stcIrqRegiConf.enIRQn = Int034_IRQn;
stcIrqRegiConf.pfnCallback = &Switch_callback;
enIrqRegistration(&stcIrqRegiConf);
/* Clear Pending */
NVIC_ClearPendingIRQ(stcIrqRegiConf.enIRQn);
/* 配置优先级 */
NVIC_SetPriority(stcIrqRegiConf.enIRQn, DDL_IRQ_PRIORITY_14);
/* 使能 NVIC */
NVIC_EnableIRQ(stcIrqRegiConf.enIRQn);
}
void Init_intruppt1()
{
stc_exint_config_t stcExtiConfig_pin12; /* 外部中断配置结构体 */
stc_irq_regi_conf_t stcIrqRegiConf_pin12; /*irq配置结构体 */
stc_port_init_t stcPortInit_pin12;
/* configuration structure initialization */
MEM_ZERO_STRUCT(stcExtiConfig_pin12);
MEM_ZERO_STRUCT(stcIrqRegiConf_pin12);
MEM_ZERO_STRUCT(stcPortInit_pin12);
/* Set PD06 as External Int Ch.6 input */
stcPortInit_pin12.enExInt = Enable;
stcPortInit_pin12.enPinMode = Pin_Mode_In;
stcPortInit_pin12.enInvert=Enable;
PORT_Init(PortC, Pin12, &stcPortInit_pin12);
stcExtiConfig_pin12.enExitCh = ExtiCh12;
stcExtiConfig_pin12.enFilterEn = Enable;
stcExtiConfig_pin12.enFltClk = Pclk3Div8;
stcExtiConfig_pin12.enExtiLvl = ExIntRisingEdge;
EXINT_Init(&stcExtiConfig_pin12);
stcIrqRegiConf_pin12.enIntSrc = INT_PORT_EIRQ12;
stcIrqRegiConf_pin12.enIRQn = Int035_IRQn;
stcIrqRegiConf_pin12.pfnCallback = &Zero_callback;
enIrqRegistration(&stcIrqRegiConf_pin12);
/* Clear Pending */
NVIC_ClearPendingIRQ(stcIrqRegiConf_pin12.enIRQn);
/* 配置优先级 */
NVIC_SetPriority(stcIrqRegiConf_pin12.enIRQn, DDL_IRQ_PRIORITY_15);
/* 使能 NVIC */
NVIC_EnableIRQ(stcIrqRegiConf_pin12.enIRQn);
} |