GPIO reading

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

GPIO reading

291 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by amelendez@dibal.com on Tue Nov 29 06:31:31 MST 2011
I cannot read properly the GPIO1_0.

I've programmed as output PIO1_11, PIO1_10, PIO1_9, PIO1_8, PIO1_4, PIO1_2 and initializated as 0. PIO1_0 has been programmed as an interruption input. PIO1_1 as output.

For testing it, I've shortcircuited PIO1_0 to gnd (for reading 0)

In my application, I'm trying to read PIO1_0 using the next sentence
puerto1 = (LPC_GPIO1-> [COLOR=#0000c0][COLOR=#0000c0]DATA[/COLOR][/COLOR] )

But I got in the 'Variabl' window 0xe3 instead of 0xe2
In the 'Memory Data' window I can read:
Register: GPIO1_DATA
Address: 0x50013ffc
Value: 0xe2 (what it's expected)

How can I read the true value of the GPIO1_0 value?
0 Kudos
3 Replies

265 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_Europe on Sun Jan 08 14:26:40 MST 2012
hello [EMAIL=amelendez@dibal.com]amelendez@dibal.com[/EMAIL]

there is no delay ... it is the same as if reading a register.

In the datasheet rise times and fall times are mentioned of max 5 nS, but this has to do with dynamic characteristics of outputs.
0 Kudos

265 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by amelendez@dibal.com on Tue Nov 29 10:02:13 MST 2011
Thanks. Now it works. I think that the problem was in the time needed to wait since the port initialization and the moment when the input value can be read.

Does anyone know if there is a settling time for waiting before any input measurement?
0 Kudos

265 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Nov 29 08:22:29 MST 2011
Read the bit, not the port :eek:

 if(LPC_GPIO1->DATA & (1<<0))    //read bit 0 of GPIO1
 {
                                //bit high
 }
 else
 {
                                //bit low
 }
0 Kudos