This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

关于msp430f149外部中断



用单片机接收TCRT的5000光电开关模块的信号控制继电器开闭
程序我做了一个,但是就是中断触发不了,开关直接接继电器是能工作的。
#include <msp430x14x.h>
void Init_Port1(void);
void main(void)
{   
    WDTCTL=WDTPW+WDTHOLD;                 //关闭看门狗
    TACTL |= TASSEL_2 + ID_3;
        Init_Port1();                      //初始化
        _EINT();                             //开启中断允许
        while (1)                            //无限循环
        {
                LPM3;                        //进入低功耗模式3。I/O口中断唤醒  
               
        }
}
#pragma vector=PORT1_VECTOR                 //中断函数     
__interrupt void Port_1()
{      
        
        
        if(P1IN==0x00)
                {
                     P3OUT=0x04;                  //继电器输入端输入低电平
                }
                else
                {
                    P3OUT=0x03;
                }     
                                  
        P1IFG=0;                            //清除P1IFG
}
       
void Init_Port1(void)                    //初始化函数
{
                              
        P1DIR&=~BIT0;                       //P1.0设置为输入方向
        P1SEL&=~BIT0;
        P1IE|=BIT0;                         //打开中断允许
        P1IES=BIT0;                         //选择下沿触发
        P1IFG&=~BIT0;                       //清除P1IFG
        P3DIR=BIT1+;                       //P3.0~P3.2设置为输出方向
        P3OUT=0x03;                     /*P3.0、P3.1输出高电平,
                                              P3.2输出低电平*/
}