Content originally posted in LPCWare by cfbsoftware on Mon Jul 22 01:22:57 MST 2013
You have to make sure bits 1, 2, 8 and 9 are cleared if you want I2C. Using the 'SET' data type feature of the Oberon programming language I write it like this:
VAR
s: SET;
SYSTEM.GET(MCU.IOCONPIO04, s);
SYSTEM.PUT(MCU.IOCONPIO04, s - {1, 2, 8, 9} + {0});
i.e. I get the existing value and then clear bits 1, 2, 8 and 9 and set bit 0 before writing it back again. It looks to me as though you have your bit mask inverted compared to what it should be. I haven't tested it but I believe the equivalent in C is:
LPC_IOCON->PIO0_4 = (LPC_IOCON->PIO0_4 & 0xFFFFFCF9) | BIT_0