lpc1114 GPIO setting problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

lpc1114 GPIO setting problem

368 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wuchienhung2002 on Sun Dec 07 08:22:37 MST 2014
Hi,

I have a problem,please help,thanks

problem description:
1.lpc1114/302
2.GPIO control:

#include  "config.h"
int main(void)
{
  uint8 i=0;
   /*SystemInit();*/
   LPC_GPIO2->DIR= 0xFF;

  while(1)
  {
if((LPC_GPIO0->DATA & 1<1)==0) LPC_GPIO2->DATA= ~(i++);
if((LPC_GPIO0->DATA & 1<2)==0) LPC_GPIO2->DATA= ~(i--);
/*Delay_ms(100);*/
  }
}

This LPC_GPIO2->DATA value is 111111011111,but in target board PIO2_5 is output high always,can you Teach me to solve this problem
0 Kudos
Reply
5 Replies

328 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Wed Dec 10 15:33:58 MST 2014

Quote: wuchienhung2002

This LPC_GPIO2->DATA value is 111111011111,but in target board PIO2_5 is output high always,can you Teach me to solve this problem



Well these are probably not what you wanted and are most likely wrong.

if((LPC_GPIO0->DATA & 1<1)==0) LPC_GPIO2->DATA= ~(i++);
if((LPC_GPIO0->DATA & 1<2)==0) LPC_GPIO2->DATA= ~(i--);


I think you probably wanted to do a left shift to get the value of either bit 1 or bit 2 in the LPC_GPIO->DATA register and compare that bit value to 0.  Then if the bit value is 0 the assignment to LPC_GPIO2->DATA will occur.

if((LPC_GPIO0->DATA & (1 << 1) ) == 0) LPC_GPIO2->DATA = ~(i++);
if((LPC_GPIO0->DATA & (1 << 2) ) == 0) LPC_GPIO2->DATA = ~(i--);


Or did you just type those into the post incorrectly, instead of copying and pasting the actual code you are using.

By the way, in either case, yes you have a problem.
0 Kudos
Reply

328 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wuchienhung2002 on Wed Dec 10 05:35:25 MST 2014
Hi R2D2,

Thanks for your help very much.

your are right,LPCXpresso Silkscreen text PIO2_5 location is wrong.

I have no problem.

Rick
0 Kudos
Reply

328 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue Dec 09 10:08:53 MST 2014

Quote: wuchienhung2002
Teach me to solve this problem



#1 Describe your hardware: Are we talking about a LPCXpresso board?
 
     If so, note that LPCXpresso Silkscreen text PIO2_5 at J6-47 is wrong. PIO2_5 is at J6-37  :((

#2 Post your software / project: Is it a LPCXpresso CMSIS project?

Without informations it's difficult to help you  :((
0 Kudos
Reply

328 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wuchienhung2002 on Tue Dec 09 09:33:01 MST 2014
Hi Serge,

Thanks for your help.

I double confirm this two item,it is setting ok,but still can not solve the problem.
so i try to find and study solution now.

thanks

Rick
0 Kudos
Reply

328 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by serge on Mon Dec 08 01:29:17 MST 2014


You could check the IOCON_PIO2_5 register to see if PIO2_5 is GPIO or CT32B0_MAT0.
GPIO pins can have alternate functions.

And have you turned on the clock for GPIO?

I have no experience with the LPC1114/302 but the above are common mistakes amongst beginners.
0 Kudos
Reply