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.

MSP-EXP430FR5969: MSP430

Part Number: MSP-EXP430FR5969

Hello,

I am following an example on Youtube to implement an ISR to toggle LED, P1.0, through the onboard switch P1.1.

All is good, except the switch bouncing - I am wondering how one can handle debouncing a switch through software, particularly when the action is handled in an interrupt?

Here is my code:

//Begin Main
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;

P1DIR    |= BIT0;                               // 'Set' P1.0 / LED2 DIR register (1=output)
P1OUT  &= ~BIT0;                          // 'Clear' P1.0 / LED2 OUT register initially (0=low)

P1DIR   &= ~BIT1;                           // Clear P1.1 (SWITCH1; 0=input)
P1REN  |= BIT1;                             // Enable PU/PD resistor
P1OUT  |= BIT1;                             // Sets resistor as PU
P1IES    |= BIT1;                               // Interrupt edge sensitivity set H-to-L

PM5CTL0 &= ~LOCKLPM5;          // Unlock digital I/O

P1IE  |= BIT1;                                 // Enable P1.1 IRQ
__enable_interrupt();                     // Enable maskable IRQs
P1IFG &= ~BIT1;                           // Clear P1.1 IRQ flag

while (1) {}

return 0;
}

// Set ISRs
#pragma vector = PORT1_VECTOR
__interrupt void ISR_Port1_S1 (void)
{
P1OUT ^= BIT0;
P1IFG &= ~BIT1;
}

**Attention** This is a public forum