LPC2131 problem reading IO pins
Function of the pins was not correctly selected. When microcontroller reset, value of P1.20 determines how the pins P1.16 till P1.23 will behave. In my case, when P1.20 was set to zero, it didn't work, and when set to one it worked.

Fix: manually set pin functions using PINSEL2 register:

    PINSEL2 &amp;= ~(0x8);
    IODIR1 &amp;= ~(PORT_ADDRESS);