LPC2138 pins P0.2 and P0.3 are not working as outputs

Hello, I have olimex lpc-p2138 board(http://www.olimex.com/dev/lpc-p2138.html). The problem is that P0.2 and P0.3 are not working as outputs. Tried both with legacy and fast gpio. FIO0DIR register seems to be ok(all 1’s), but can’t write to corresponding bits in FIO0PIN. 2nd and 3rd bits in FIO0PIN act as input(reads pin value). Bits 4-7 in PINSEL0 are set to 0’s. Is there something that i’m missing? Please help.

Thanks.

If you want to use the FIO functions for Port 0 you need to set bit 0 in the System Control and Status Flag (SCS) register. See Section 6.1. in the User Manual (UM10139).

If you still can’t get it to work, post the snippet of code showing how you are setting FIODIR, PINSEL and SCS.

If I am not wrong, P0.2 and P0.3 are I2C port pins and are open collector. On many schematics, pull-ups are added on these pins. I can’t see them on this board’s schematics.

Angelo

Yes, I changed this flag(before I tried with legacy gpio and it’s the same).

Yes these are also I2C pins, but PINSEL0 register description in user manual shows that it can also be used as GPIO.

Here’s initialization code.

I2C0CONCLR |= (1<<6); // clear I2C enable flag
GPIO0M = 1; // Set fast gpio mode
PINSEL0 = (PINSEL0 & 15); // leave first 4bits as they are and set all others to 0's
FIO0DIR = 0xFFFF; // set all PORT0 pins to outputs

and switching(in delayed loop)

FIO0PIN ^= 0xFFFF; // toggle PORT0

Edit:

Oh, I am starting to understand what you are saying… So outputing value to P0.2 and P0.3 means connecting or disconnecting it from ground?

juxas:
Here’s initialization code.

I2C0CONCLR |= (1<<6); // clear I2C enable flag

Do not use the |= operator (read / modify / write) on CLR and SET registers. The correct statement to clear the I2C enable flag is:

I2C0CONCLR = (1<<6); // clear I2C enable flag

I don’t know if has anything to do with your problem but it should be fixed anyway as the effects could be unpredictable.

GPIO0M = 1; // Set fast gpio mode

That also looks odd. How is GPIO0M defined / declared / used? I would have expected to see something like:

SCS |= GPIO0M;

Thanks for pointing out mistakes. I mistakenly defined GPIO0M instead of SCS :).

Thanks for answers :). Indeed that’s an open drain output, checked with tester and resistor:)