lpcware

p2.9 as gpio on lpcxpresso1769

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by dragilla on Mon Aug 27 12:04:41 MST 2012
Hi,
I'm trying to read p2.9 pin on my lpcxpresso1769.
I set it as input gpio and select pull-down.
But when I let it float my program shows 1.
Only when I connect it to ground it reads 0.
Shouldn't the internal pull-down malke it 0 when it's floating?

My code is very simple:

int main(void)
{
PINSEL_CFG_Type PinCfg; // Pin configuration
uint8_t x;

// set p2.9 as input
PinCfg.Funcnum = 0;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = PINSEL_PINMODE_PULLDOWN;
PinCfg.Portnum = 2;
PinCfg.Pinnum = 9;
PINSEL_ConfigPin(&PinCfg);

// setup pin direction
FIO_ByteSetDir(2, 1, 0b00000010, 0);

while(1) {
x = (FIO_ByteReadValue(2, 1) & 0b00000010) >> 1;
x = 0; // breakpoint here
}
}


Help me understand please.

regards,
--
Luke

Outcomes