简体   繁体   English

MSP430中断按钮不起作用

[英]msp430 interrupt button not working

With msp430 mcu, i try to handle interrupts on port1 with the bits 0,1,2,3. 使用msp430 MCU,我尝试使用位0、1、2、3处理端口1上的中断。 The problem is it only recognizes for the BUTTON0 (P1.0). 问题在于它只能识别BUTTON0(P1.0)。 I also implemented, P1 direction bits and P1 interrupt enable bits.To do this, i have written this code. 我还实现了P1方向位和P1中断使能位。为此,我编写了这段代码。

#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{

   WDTCTL = WDT_ADLY_250; IFG1 &= ~WDTIFG; /* clear interrupt flag */

  if((P1IN & BUTTON3)!=BUTTON3 ){  

    if(cursor != 6){
      cursor++;
    }
   } 

  else if((P1IN & BUTTON2)!=BUTTON2){ 

    if(cursor != 0){
      cursor--;
    }
  }

 else if((P1IN & BUTTON1)!=BUTTON1){ 

    yapilanDegisiklikler[cursor]++;

  }


  else if((P1IN & BUTTON0)!=BUTTON0){

    yapilanDegisiklikler[cursor]--;
  }

P1IFG &= ~(BUTTON3+BUTTON2+BUTTON1+BUTTON0);

}

我不确定您是否使用TI MSP430 LaunchPad,但是可以在这里找到一个很好的开始: MSP430 LaunchPad按钮

It was because that the interrupt enable switches for buttons werent on the correct states. 这是因为按钮的中断使能开关没有处于正确的状态。 I have adjusted that and problem solved. 我已经调整并解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM