Hi
I require that the port 2.6 of MSP430G2231 microcontroller should be configured as input for a switching application. The whole idea is to detect a high or a low. When a high is detected(3.3V), I set a flag G_Charge_Start=1, if a low is detected(i.e 0V) I set G_Charge_Start=0. How ever I find that the P2.6 is always detecting a high in-spite of the switch on my application being low. The reason being by default when no voltage is applied to pin 2.6, I see that a 1.2-1.5V can be detected at port 2.6. But when I Isolate the controller from my application I see that on my hardware board the is no voltage (0V) when my switch is turned off. the 1.2V-1.5V is from my controller.Can somebody tell me if I have configured the ports correctly. I have pasted my code below. Please give me some suggestions. Thanks in advance.
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
// INIT_PORTS();
P2IN&=~BIT6;
//P1DIR|=BIT0;
//P1OUT&=~BIT0;
while (1)
{
// battery_voltage = analogRead(port1);
if (P2IN & BIT6){
G_Charge_Start=1;
} else if( !(P2IN & BIT6)) {
G_Charge_Start=0;
}
}
}