Content originally posted in LPCWare by NXP_USA on Tue Feb 02 10:38:26 MST 2010
Hi All,
Here is a description of the I/O port behavior.
The LPC111x and LPC134x parts have a single port data register that provides the following behavior:
Port read: This will always read the pin voltages, input pins output driver state for output pins. The bit masking feature should be used for output writes.
Port write: This will set the value of all of the bits/pins in the port data register, that are configured as outputs. The bit values written to pins set in input mode will not be retained.
Set pin mode to input: The high-current drivers will be disabled. The pin voltage can be controlled by pullups/pulldowns if configured in IOCON.
Set pin mode to output: Upon changing a pin to output mode, it drives the level in the data register. This will be the current logic level on the pin, which could be set by the pullup/pulldown or an external signal.
For example:
-Pin is input, floating high-ish (LPCXpresso LED example when pullup enabled- due to LED forward biasing by pullup, it is probably floating at around 2V)
-Pin mode is set to output
-Pin drives high
-Pin is input/pullup, but pulled down externally for some reason
-Pin mode is set to output
-Pin drives low
The pins mirror the current logic level when they are switched from input to output.
Bit masking: There is an address region for the data register. Writes to this region will set or clear individual bits in the port register. The way this works is low bits in the write address are used to create a mask for the data register write. There is one address bit for each pin (12) in the data register. For an example of this, see the gpio.h file in the LPCXpresso example package.
edited on 1/3/2010- removed RMW language as the port pins do not demonstrate this
-NXP