Вопрос

With msp430 mcu, i try to handle interrupts on port1 with the bits 0,1,2,3. The problem is it only recognizes for the BUTTON0 (P1.0). I also implemented, P1 direction bits and P1 interrupt enable bits.To do this, i have written this code.

#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);

}
Это было полезно?

Решение 2

It was because that the interrupt enable switches for buttons werent on the correct states. I have adjusted that and problem solved.

Другие советы

I'm not sure if you're using the TI MSP430 LaunchPad, but a great start to this can be found here: MSP430 LaunchPad Push Button.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top