LPC812 GPIO input

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

LPC812 GPIO input

583 Views
hibino123
Contributor I

Hi All,

I am new to using LPC812.

I am thinking of a program that blinks an LED when a button is pressed.

LEDs are connected to PIO0_0 and buttons are connected to PIO0_14.

This is the program I came up with.

int main(void) {
 SystemCoreClockUpdate();
 SysTick_Config( SYSTICK_DELAY );
 GPIOInit();
 LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
 LPC_GPIO_PORT->DIR0 |= (1<<0);
 LPC_GPIO_PORT->DIR0 &=~ (1<<14);
 volatile int8_t SW1 = 1;
 while(1) {
  SW1 = (LPC_GPIO_PORT->PIN0 & (1<<14));
  if(SW1 == 0){
   LPC_GPIO_PORT->SET0 |= (1<<0);
   delaySysTick(100);
   LPC_GPIO_PORT->CLR0 |= (1<<0);
   delaySysTick(100);
  }
  else{
   LPC_GPIO_PORT->CLR0 |= (1<<0);
  }
 }
 return 0 ;
}

However, this program did not work.

I think the pin is not set up correctly, but I would like to know.

Labels (1)
0 Kudos
2 Replies

565 Views
Badman
Contributor I
I don't know lpc812. Maybe PIO0_14 has a different function than gpio by default. Check in User Manual PIO0_14.
0 Kudos

576 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello ,

Recommend you refer to the gpio demo under LPC824 SDK.

Also set breakpoint to while function,  check whether it can enter while when press button.

 

BR

Alice

0 Kudos