Tool/software: Code Composer Studio
Hi all,
While I was fiddling around with the GPIO input ports, I tried to use the P1.1 pushbutton of the MSP430F5529LP LaunchPad with the pull-up configuration, all worked fine and good, with all the necessary adjustments. On the other hand, when I try to use the pull-down resistor configuration, the P1IN register does not change to 1 when I press the pushbutton. I followed the instructions on the User Guide (SLAU208) - setting the respective bit in P1OUT to 0 in order to use the pull-DOWN configuration on the pin, and enabling the respective P1REN bit to 1 in order to enable such resistor. Below are the codes for the pull-up and for the pull-down configurations, where the latter does not work. I am very confused.
#include <msp430.h> #define LED BIT0 #define BTN BIT1 /** * main.c */ int main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer P1DIR |= LED; P1DIR &= ~BTN; P1OUT |= BTN | LED; // set as pull-up and LED initially on P1REN = BTN; // enable pull-up resistor while(1) { if((P1IN & BTN) != 0) P1OUT ^= LED; } return 0; }
#include <msp430.h> #define LED BIT0 #define BTN BIT1 /** * main.c */ int main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer P1DIR |= LED; P1DIR &= ~BTN; P1OUT &= BTN | LED; // set as pull-down and LED initially off P1REN = BTN; // enable pull-down resistor while(1) { if((P1IN & BTN) != 0) P1OUT ^= LED; } return 0; }
Thanks in advance.