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.

CCS/MSP430F6459: switch

Part Number: MSP430F6459


Tool/software: Code Composer Studio

Hi,

i am using switch press opration.how many times i press switch that i m counting. for that m using interrupti method. If i am pressing 1 time that m getting different count like that. how resolve that??. how to use software debousing using c using msp430??

thanks.

  • Hi Trupti,

    There are several button debouncing solutions available online. From a hardware perspective you could use a pull-down capacitor. For the software you would enter the ISR, delay a few microseconds, then check to see that the pin's input value is still in the pressed state and only increment the counter if true.

    Regards,
    Ryan
  • hi,

     Actually giving delay is not working properly.any another way is their?

  • Delay will not work. What you need is a way to temporarily disable the button interrupt and then enable it again after a certain delay.
    This can be done by the following:
    * You receive the first interrupt from the button.
    * You disable the button interrupt (if needs be, also clear the corresponding IFG).
    * You start a timer to interrupt after ~150ms.
    * Inside the timer interrupt, you again enable the button interrupt.
  • Hi,

      i made like this in ISR. then also m not getting proper count

    #pragma vector = PORT1_VECTOR
    __interrupt void PORT_1(void)
    {
    switch(__even_in_range(P1IV,16))
    {
    case 0: break;
    case 2:break;
    case 4: //P1.1
    P1IE &= ~BIT1; //disable interrupt
    count ++;
    {
    Bite_return_status =1;
    P1IE |= BIT1; //Enable interrupt
    TA0CCR0 = 64000; //2 Sec
    TA0CTL |= TASSEL_1 + MC_1 + TACLR + TAIE; //aclk=32khz
    if(DU_press_count > 0)
    Bite_return_status_end =1;
    }
    P1IFG &= ~BIT1;
    break;
    case 6: break;
    case 8:
    break;
    case 10: break;
    case 12: break;
    case 14: break;
    case 16: break;
    default: break;
    }
    }

  • Your code doesn't actually wait for the timer ISR before re-enabling P1IE, furthermore you have not provided the timer ISR itself where we can see the timer disabled and button interrupts re-enabled.

    Regards,
    Ryan

**Attention** This is a public forum