直接跑不带有外部中断的程序,运行一切正常,但如果设置GPIO外部中断,运行几秒钟后,会引起系统复位
这个一般是什么问题引起的?下面为代码
1 设置:
#define PH1 GPIO_PIN_2
#define PH1_PORT GPIOD
//输入
GPIO_Init(PH1_PORT, PH1, GPIO_MODE_IN_PU_IT);
/* Initialize the Interrupt sensitivity */
EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOD, EXTI_SENSITIVITY_FALL_ONLY);
enableInterrupts();
2 在中断文件中设置:
{0x82, (interrupt_handler_t)EXTI_PORTD_IRQHandler}, /* irq6 - External interrupt 3 (GPIOD) */
3 中断实现函数中
#ifdef _COSMIC_
@far @interrupt void EXTI_PORTD_IRQHandler(void)
#else /* _RAISONANCE_ */
void EXTI_PORTD_IRQHandler(void) interrupt 6
#endif /* _COSMIC_ */
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
if ((GPIO_ReadInputData(PH1_PORT) & PH1) == (u8)0x00)
{
/* Toggle GPIO PIN5 */
GPIO_WriteReverse(LED_PORT, LED1);
}
}
/**
代码很简单,单步执行的话,是可以正常进入中断,但全速运行就会复位,百思不得其解,那位大侠指点一下,谢 |