Hey guys!
I am trying to use the on-board P1.1 button on the MSP430 F5529. However, for some reason the following code is not working correctly. What I am trying to do is to toggle the on-board LED at P1.0 using the on board push button at P1.1. What am I doing wrong? Do I have to debounce the push button somehow?
Here is the code:
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= BIT0; // Set P1.0 to output direction
P1REN |= BIT1; // P1.1 pullup
while (1) // Test P1.4
{
if (P1IN & BIT1)
{
P1OUT ^= BIT0; // if P1.4 set, set P1.0
}
}
}
Thank you!