Content originally posted in LPCWare by gbm on Tue Nov 09 12:53:16 MST 2010
LPC11xx ports are little tricky here.
When the pin is set to input, data written to it is ignored. When the pin is switched to output, it's output value is set to the logic level present on it (externally forced) while switching.
To switch from input to output without unwanted transients, do the following:
While the pin is still in input mode but not driven externally, set pullup (if the initial output value should be 1) or pulldown (for initial output 0). Alternatively, you may use the bus hold function to keep the last externally-forced level. Then switch the direction to output. If you want to be double sure, set the output level again by writing to port register.