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.
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.
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?