SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on how to get your MSP JTAG programmer up and running.
By goose
#93611
Hello.

I am trying to connect an external button to the msp430fg4618
its a standard button 3 pins (common,normally open, normally close).
i am also using a 2x1.5 volt batteries.
the hardware was connect like so:
power source to the common, normally open pin to PORT6.0, and MSP to ground.
the software:
P6SEL &= ~0x01; // port6.0
P6DIR &= ~0x01; // port6.0 as input.

this is basically it.

now, when i press to button i get that P6IN = 0x03 meaning port6.0 and 6.1 gets logic "1", when i want only port6 to get "1".

when i connect to port 6.2 i get the 6.0 & 6.1 & 6.2 gets "1".

what am i doing wrong ???


thanks.
By gm
#93637
I would not try to use those port pins as they are connected to the microphone input circuit. Why don't you use the switches that are provided on the board (connected to P1.0 and P1.1)?

That being said, the only reason I can see that P6IN should return those values when only P6.0 is an input is that P6OUT must contain something other than zero. Try writing zero to P6OUT and see if that helps.

Another thing that you might try is that the standard way to test the logic level of a pin would be something like this:

if ( (P6IN & BIT0) == BIT0 )
{ your code here }

HTH,

gm