标题: 求指点:ATMEG128外部中断进不去 [打印本页]

作者: 明月轻风    时间: 2013-10-27 19:37
标题: 求指点:ATMEG128外部中断进不去
#include <iom128v.h>
#include <macros.h>
#progma interrupt_handler int2_interrupt:4
/******************************************************************************/
/*函数功能:外部中断初始化(按钮下降沿产生中断,中断源INT2)
/*输入参数:无
/*返回值: 无                         
/******************************************************************************/
void extinterrupt_init()
{
  DDRD&=~BIT(2);//PD2设为输入
  EICRA=0x65;//INT2 下降沿触发
  EIMSK=0X04;//INT2  外部中断使能
  SEI();
}

/******************************************************************************/
/*函数功能:外部中断源2产生下降沿触发中断,按钮按下动作
/*输入参数:
/*返回值: 无                         
/******************************************************************************/
void int2_interrupt()
{  

   PORTE&=~BIT(4);//点亮LED
}  
void main()
{

  CLI();
  DDRE|=BIT(4);
  PORTE|=BIT(4);//LED熄灭
  extinterrupt_init();
  while(1)
  {
    ;
  }

}








欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1