LPC812 GPIO input

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC812 GPIO input

848件の閲覧回数
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.

ラベル(1)
0 件の賞賛
返信
2 返答(返信)

830件の閲覧回数
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 件の賞賛
返信

841件の閲覧回数
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 件の賞賛
返信