How know if a GPIOpin is connected

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How know if a GPIOpin is connected

988 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pollo89 on Tue Sep 25 01:16:05 MST 2012
Hi guys,
I need to know an input GPIO status: if it is in a 1Logic, 0Logic or if it's not connected.

I used they blinky project in my LPC11C24 board and the GPIO pin is GPIO0_0

my GPIOGetValue:
uint32_t GPIOGetValue( uint32_t portNum, uint32_t bitPosi )
{
  return !! LPC_GPIO[portNum]->MASKED_ACCESS[(1<<bitPosi)];
}
in my main:
uint32_t temp;
GPIOInit();
GPIOSetDir( 0 , 0 , 0 );
temp = GPIOGetValue( 0, 0 );
temp after GPIOGetValue Function is 1 but my pin isn't connect.
How I can know if my pin is connected or not?

EDIT: add code ini GPIOinit
LPC_IOCON->RESET_PIO0_0 &= ~0x07;    /*  P0_0 I/O config */
LPC_IOCON->RESET_PIO0_0 |= 0x01;     /* NOT RESET */
0 Kudos
8 Replies

914 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pollo89 on Tue Sep 25 06:27:57 MST 2012
Thank you again, Zero.
You were right.
It's OK if use PIO0_2 or PIO0_3
0 Kudos

914 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Sep 25 06:06:54 MST 2012

Quote:
Sorry for my bad knowledge but if there is an external pull-up resistor...

Use EA LPCXpresso11C24 schematic: http://www.embeddedartists.com/sites/default/files/docs/schematics/LPCXpressoLPC11C24revB.pdf

Quote:

Cannot I pull-down? Is this resistor only connected to PIO0_0?

PIO0_0 is used as RESET, therefore pulled up. Internal pullups/pulldowns are weak, so in this case internal pulldown isn't strong enough.

Quote:

I edited my code for PIO0_2 but nothig changes...

Then you code is faulty ;)
Use debugger to control/switch IOCON / GPIO0 settings via Peripherals view :)


Quote:
I consulted my User Manual and  at page 73 it tells me that i can set PullDown resistore mode on  GPIO0_0 and i read nothing on "external pull-up resistor"

Writers of this manual are no clairvoyants, so they don't know if or if not pullups are used on a board :eek:
0 Kudos

914 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pollo89 on Tue Sep 25 05:40:22 MST 2012
Sorry for my bad knowledge but if there is an external pull-up resistor, Cannot I pull-down? Is this resistor only connected to PIO0_0?
I edited my code for PIO0_2 but nothig changes...

edit: I consulted my User Manual and at page 73 it tells me that i can set PullDown resistore mode on GPIO0_0 and i read nothing on "external pull-up resistor"
0 Kudos

914 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Sep 25 05:26:06 MST 2012

Quote: pollo89
My HW should be http://www.nxp.com/products/microcontrollers/cortex_m0/lpc11c00/LPC11C24FBD48.html



That's a LPCXpresso11C24 and therefore including R31 = 12k external pullup at PIO0_0 as mentioned already ;)
0 Kudos

914 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pollo89 on Tue Sep 25 05:20:43 MST 2012

Quote: Zero
#1 Don't OR here. Reset MODE value is pullup = 0b10, if you OR 0b01 here you're in 'Repeater mode' = 0b11 :eek:


Sry, i saw it. I done in this way
LPC_IOCON->RESET_PIO0_0 &= ~0x1F;    /*  P0_0 I/O config */
LPC_IOCON->RESET_PIO0_0 |= 0x01<<3 | 0x01;     /* PULLDOWN resistor, NOT RESET */

Quote: Zero
#2 As already mentioned above: Is your hardware (LPCXpresso :confused:) including an external pullup at PIO0_0?


My HW should be http://www.nxp.com/products/microcontrollers/cortex_m0/lpc11c00/LPC11C24FBD48.html
0 Kudos

914 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Sep 25 05:14:32 MST 2012

Quote: pollo89
LPC_IOCON->RESET_PIO0_0[COLOR=Red] |=[/COLOR] 1<<3 | 0x01;  /* PULLDOWN resistor,NOT RESET */
But nothing changes


#1 Don't OR here. Reset MODE value is pullup = 0b10, if you OR 0b01 here you're in 'Repeater mode' = 0b11 :eek:

#2 As already mentioned above: Is your hardware (LPCXpresso :confused:) including an external pullup at PIO0_0?
0 Kudos

914 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pollo89 on Tue Sep 25 05:06:01 MST 2012
Thanks for the answer.
I edit my line into my GPIOInit with:
LPC_IOCON->RESET_PIO0_0 |= 1<<3 | 0x01;  /* PULLDOWN resistor,NOT RESET */
But nothing changes
0 Kudos

914 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Sep 25 03:33:08 MST 2012

Quote: pollo89
...my LPC11C24...


#1 Are we talking about LPCXpresso11C24 board with 12k pullup (R31) :eek:

#2 If you want to detect a high level, use pull-down setting of IOCON ;)
0 Kudos