MSP430 Prevent Bouncing
You have to use the delay after spotting the first flank, not at some random location in the code. The most crude version would be this (pseudo code):
uint8_t pin=0;
uint8_t prev=0;

while(1)
{
  pin = PORTX;
  if(pin != prev) // edge detected
    break;
  prev = pin;
}

busy_delay();  // some 5 to 20 ms usually
pin = PORTX;  // read when the switch is done bouncing
// now you can use the value of pin

The more professional version involves a circular interrupt which reads the port at even time intervals and compares with previous read and stores the result if it's the same.