AT89LV52的外部中断怎么会多次触发?
我用AT89LV52模拟一个I2C功能,用C51编写,Keil uVision2,
i2c_SDA = P3.2 (/INT0),
i2c_SCL = P3.1,
INT0设为下降沿触发。
void init_interrupt(void)
{
EX0 = 1; /* 1=Enable External interrupt 0 */
ET0 = 1; /* 1=Enable Timer 0 interrupt */
EX1 = 0; /* 1=Enable External interrupt 1 */
ET1 = 0; /* 1=Enable Timer 1 interrupt */
ES = 0; /* 1=Enable Serial port interrupt */
ET2 = 0; /* 1=Enable Timer 2 interrupt */
IT0 = 1; /* 1 =INT0 Trigger on fall slope */
EA = 1; /* 0=Disable all interrupts */
}
void edge_detect(void) interrupt 0
{
disable_interrupt0();
disable_keypad();
ctrl_1 = !ctrl_1;
i2c_receive_packet();
ctrl_1 = !ctrl_1;
enable_keypad();
enable_interrupt0();
}
void disable_interrupt0(void)
{
EX0 = 0; /* 1=Enable External interrupt 0 */
}
void enable_interrupt0(void)
{
EX0 = 1; /* 1=Enable External interrupt 0 */
}
当I2C数据来时,触发外部中断0,进入中断程序,在中断程序内部先禁止中断0,避免后面的数据下降沿触发中断。接收完数据后,开中断0后返回。
现在我发现接收完一个完整的数据包退出中断后,立即又触发了一次中断,进入了中断服务程序。请问各位大虾这可能是什么原因。
发表时间:2003年7月13日13:19:33