lpcware

LPC11U14 xpresso GPIO Pin toggling (P1.21,P1.22,P1.23)

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by fjarnjak on Thu Jul 12 04:45:25 MST 2012
I have a LPC11U14 board from LPCXpresso (running naked; not inserted into anything and I am scoping pins + debugger).
Below is the code in main() - nothing is set or inited before:


uint32_t dir = 0;
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<16); /* Enable IOCON block */
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);  // Enable GPIO clock

LPC_IOCON->PIO1_21 = 0x90;
LPC_IOCON->PIO1_22 = 0x90;
LPC_IOCON->PIO1_23 = 0x90;
dir = LPC_GPIO->DIR[1];
GPIO_SetDir(PORT1, (1<<21), 1);
dir = LPC_GPIO->DIR[1];
GPIO_SetDir(PORT1, (1<<22), 1);
dir = LPC_GPIO->DIR[1];
GPIO_SetDir(PORT1, (1<<23), 1);
dir = LPC_GPIO->DIR[1];
while(1)
{
GPIO_SetValue(PORT1, (1<<(21)));
GPIO_SetValue(PORT1, (1<<(22)));
GPIO_SetValue(PORT1, (1<<(23)));
for(i=0;i<50;i++);
GPIO_ClearValue(PORT1, (1<<(21)));
GPIO_ClearValue(PORT1, (1<<(22)));
GPIO_ClearValue(PORT1, (1<<(23)));
for(i=0;i<50;i++);
}


I am setting IOCON just in case to default values of after reset (0x90) which sets pins for a GPIO function, as per some previous posts on this board when registers got corrupted (people were initing timers, etc). I have tried with this commented out - same result.

When I scope the pins, I can see only PIO1_21 toggling. PIO1_22 and PIO1_23 are not.

When I step with the debugger, looking at GPIO peripherals, I can see that entry P1B21 is toggling between 1 and 0. P1B22 is always at 0. P1B23 is always at 0.

IOCON for pins debugger shows that it is 0x90 - GPIO function, pull-up enabled, hystersys off, non-inverted, open-drain disable and function set to PIO1_2x (x = 1,2,3).

However, P1W21 is togling between 0xFFFFFFFF and 0 and also P1W22 and P1W23 is toggling the same (as expected).
DIR[1] register is set to 0xE00000 which sets 111 for 21,22,23 and all the rest are 0.


Toggling LED with the same method (attached to PORT0 pin 7) works fine.


I am strugling with this for hours today :mad:.  I am surely missing something?

Outcomes