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/MSP430FR5969: Trying to create a simple code to switch an on-board LED ON and OFF on the launchpad using an on-board button

Part Number: MSP430FR5969

Tool/software: Code Composer Studio

Hi I am new to the embedded land and am trying to create a simple code to switch on and off the on board LED on my launchpad. I want to have the default state LED ON and LED OFF if the button is pushed. If I create a pull-up manually to the switch my code works, otherwise it does not. I think I am doing something incorrectly with the pull-up (P1REN) register. 

What am I doing wrong? 

Code: 

#include <msp430.h>

void main(void) {

WDTCTL = WDTPW | WDTHOLD;  // Stop watchdog timer

PM5CTL0 &= ~LOCKLPM5_L;  //Disable Low Power Mode

PASEL0 = 0;

PAOUT = 0;

PADIR = 0xFFFF;

P1REN = 0b00000010;

P1DIR &= ~(BIT1);

while (1){

if ((P1IN & 0x02) == 0x00)

{

P1OUT = 0b00000000; //P1OUT = Pull Up Resistor Configurations (P1 OUT = 0 OUTPUT IS PULLED DOWN, P1OUT = 1 OUTPUT IS PULLED UP)

}

else

{

P1OUT = 0b00000001; //P1OUT = Pull Up Resistor Configurations (P1 OUT = 0 OUTPUT IS PULLED DOWN, P1OUT = 1 OUTPUT IS PULLED UP)

}

}

}

**Attention** This is a public forum