1
\$\begingroup\$

I've been trying to get 2 input push-buttons working on my MSP430 FF529.

I've been successful with 1, but not the other, which leads me to think the one not working is broken, since I'm doing the exact same thing for both.

The two push-buttons on this board are attached to ports P1.1 and P2.1

I got P2.1 to work fine by doing:

P2DIR = 0x00;    //set as input
P2REN |= 0x02;   //enable pullup for p2.1

Now for Port 1, I also need an LED attached to P1.0 as output, so I have done:

P1DIR = 0x01;  //set p1.0 as output, and p1.1 as input
P1REN |= 0x02; //enable pullup for p1.1

So P2.1 is working perfectly fine. The default value is HIGH, and I can see it switch to LOW when I press the button. But this is not the case for P1.1. The default value for this is LOW, and pressing the button has no effect. Am I missing something obvious? Or something different about this port than the other port?

The parts I'm referring to are in green boxes.

MSP430 FF529

enter image description here

enter image description here

\$\endgroup\$
  • \$\begingroup\$ You checked the button connection? many models have 4 pins, but connected as two pairs. Perhaps, instead of connecting terminals of the switch, you connected a pair of common pins. \$\endgroup\$ – Martin Petrei Sep 8 '14 at 19:09
  • \$\begingroup\$ @Tinchito I forgot to mention these are pushbuttons soldered directly onto the MSP430 FF529 board. I am not working with any external components. \$\endgroup\$ – krb686 Sep 8 '14 at 19:15
  • \$\begingroup\$ Can you verify that P1SEL is at its default 0x0000? \$\endgroup\$ – venny Sep 8 '14 at 19:38
  • \$\begingroup\$ @venny Yes, I had that in my code again, forgot to mention it above. So at this point, I have ports P1 and P2 doing literally the exact same thing just to see if I could get the correct behavior, but ending up with different values. For both I have: PxSEL=0x00, PxDIR=0x00, PxREN=0xFF, and PxOUT=0xFF, and both are different values. At run-time, port P1 has the value 0x00, and P2 has the value 0xFF. \$\endgroup\$ – krb686 Sep 8 '14 at 19:41
  • 1
    \$\begingroup\$ Ok I'm an idiot. I had an else condition further up in my code that was writing P1OUT = 0x00 when it shouldn't have been, so I guess it was changing P1 to pull-down. Doh \$\endgroup\$ – krb686 Sep 8 '14 at 20:01
1
\$\begingroup\$

As OP has noted in the comments, issue was due to code changing the state of the Port 1 Output P1OUT. When PxREN is enabled for a given port and pin, the corresponding bit for the same port and pin in PxOUT controls whether the builtin Pull-Up (Logic 1) or Pull-Down (Logic 0) is connected. PxDIR must also be set to Logic 0 for the port and pin to be an input.

Consequently, Op had set the P1.1 Button Input to pull-down to Gnd, when the button is also tied to Gnd when pressed.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.